-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add documentation and test case about notifications via ntfy #610
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -378,6 +378,7 @@ _mqttwarn_ supports a number of services (listed alphabetically below): | |
* [mythtv](#mythtv) | ||
* [nntp](#nntp) | ||
* [nsca](#nsca) | ||
* [ntfy](#ntfy) | ||
* [desktopnotify](#desktopnotify) | ||
* [osxsay](#osxsay) | ||
* [pastebinpub](#pastebinpub) | ||
|
@@ -562,7 +563,7 @@ Apprise to E-Mail, an HTTP endpoint, and a Discord channel. | |
|
||
```ini | ||
[defaults] | ||
launch = apprise-mail, apprise-json, apprise-discord | ||
launch = apprise-mail, apprise-json, apprise-discord, apprise-ntfy | ||
|
||
[config:apprise-mail] | ||
; Dispatch message as e-mail. | ||
|
@@ -589,9 +590,16 @@ baseuri = 'json://localhost:1234/mqtthook' | |
module = 'apprise' | ||
baseuri = 'discord://4174216298/JHMHI8qBe7bk2ZwO5U711o3dV_js' | ||
|
||
[config:apprise-ntfy] | ||
; Dispatch message to ntfy. | ||
; https://github.com/caronc/apprise/wiki/URLBasics | ||
; https://github.com/caronc/apprise/wiki/Notify_ntfy | ||
module = 'apprise_single' | ||
baseuri = 'ntfy://user:password/ntfy.example.org/topic1/topic2' | ||
|
||
[apprise-single-test] | ||
topic = apprise/single/# | ||
targets = apprise-mail:demo, apprise-json, apprise-discord | ||
targets = apprise-mail:demo, apprise-json, apprise-discord, apprise-ntfy | ||
format = Alarm from {device}: {payload} | ||
title = Alarm from {device} | ||
``` | ||
|
@@ -624,6 +632,7 @@ module = 'apprise_multi' | |
targets = { | ||
'demo-http' : [ { 'baseuri': 'json://localhost:1234/mqtthook' }, { 'baseuri': 'json://daq.example.org:5555/foobar' } ], | ||
'demo-discord' : [ { 'baseuri': 'discord://4174216298/JHMHI8qBe7bk2ZwO5U711o3dV_js' } ], | ||
'demo-ntfy' : [ { 'baseuri': 'ntfy://user:password/ntfy.example.org/topic1/topic2' } ], | ||
'demo-mailto' : [ { | ||
'baseuri': 'mailtos://smtp_username:[email protected]', | ||
'recipients': ['[email protected]', '[email protected]'], | ||
|
@@ -634,7 +643,7 @@ targets = { | |
|
||
[apprise-multi-test] | ||
topic = apprise/multi/# | ||
targets = apprise-multi:demo-http, apprise-multi:demo-discord, apprise-multi:demo-mailto | ||
targets = apprise-multi:demo-http, apprise-multi:demo-discord, apprise-multi:demo-mailto, apprise-multi:demo-ntfy | ||
format = Alarm from {device}: {payload} | ||
title = Alarm from {device} | ||
``` | ||
|
@@ -2026,6 +2035,15 @@ def check_temperature(data): | |
Requires: | ||
* [pynsca](https://github.com/djmitche/pynsca). | ||
|
||
|
||
### `ntfy` | ||
|
||
Support for [ntfy] is provided through Apprise, see [apprise_single](#apprise_single) | ||
and [apprise_multi](#apprise_multi). | ||
|
||
[ntfy]: https://ntfy.sh/ | ||
|
||
|
||
### `desktopnotify` | ||
|
||
It invokes desktop notifications, using the fine | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,6 +189,11 @@ you an idea how to pass relevant information on the command line using JSON:: | |
pip install mqttwarn-contrib | ||
mqttwarn --plugin=mqttwarn_contrib.services.cloudflare_zone --config='{"auth-email": "foo", "auth-key": "bar"}' --options='{"addrs": ["0815", "www.example.org", ""], "message": "192.168.0.1"}' | ||
|
||
# Submit notification to "ntfy", using Apprise service plugin. | ||
mqttwarn --plugin=apprise \ | ||
--config='{"baseuri": "ntfy://user:[email protected]/topic1/topic2"}' \ | ||
--options='{"addrs": [], "title": "Example notification", "message": "Hello world"}' | ||
|
||
|
||
Also, the ``--config-file`` parameter can be used to optionally specify the | ||
path to a configuration file. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ def test_apprise_multi_basic_success(apprise_asset, apprise_mock, srv, caplog): | |
addrs=[ | ||
{"baseuri": "json://localhost:1234/mqtthook"}, | ||
{"baseuri": "json://daq.example.org:5555/foobar"}, | ||
{"baseuri": "ntfy://user:[email protected]/topic1/topic2"}, | ||
], | ||
title="⚽ Message title ⚽", | ||
message="⚽ Notification message ⚽", | ||
|
@@ -31,15 +32,18 @@ def test_apprise_multi_basic_success(apprise_asset, apprise_mock, srv, caplog): | |
call(asset=mock.ANY), | ||
call().add("json://localhost:1234/mqtthook"), | ||
call().add("json://daq.example.org:5555/foobar"), | ||
call().add("ntfy://user:[email protected]/topic1/topic2"), | ||
call().notify(body="⚽ Notification message ⚽", title="⚽ Message title ⚽"), | ||
call().notify().__bool__(), | ||
] | ||
|
||
assert outcome is True | ||
assert ( | ||
"Sending notification to Apprise. target=None, addresses=[" | ||
"{'baseuri': 'json://localhost:1234/mqtthook'}, {'baseuri': 'json://daq.example.org:5555/foobar'}]" | ||
in caplog.messages | ||
"{'baseuri': 'json://localhost:1234/mqtthook'}, " | ||
"{'baseuri': 'json://daq.example.org:5555/foobar'}, " | ||
"{'baseuri': 'ntfy://user:[email protected]/topic1/topic2'}" | ||
"]" in caplog.messages | ||
) | ||
assert "Successfully sent message using Apprise" in caplog.messages | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Submitting a notification message to ntfy should work like this from the command line. Can someone who is following here, verify this command, and report back afterwards?