-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation and test case about notifications via ntfy
- Loading branch information
Showing
4 changed files
with
34 additions
and
5 deletions.
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 | ||
|
||
|