Skip to content

Commit fd5575b

Browse files
committed
Add documentation and test case about notifications via ntfy
https://ntfy.sh/
1 parent 8166e02 commit fd5575b

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

HANDBOOK.md

+21-3
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ _mqttwarn_ supports a number of services (listed alphabetically below):
377377
* [mythtv](#mythtv)
378378
* [nntp](#nntp)
379379
* [nsca](#nsca)
380+
* [ntfy](#ntfy)
380381
* [desktopnotify](#desktopnotify)
381382
* [osxsay](#osxsay)
382383
* [pastebinpub](#pastebinpub)
@@ -547,7 +548,7 @@ Apprise to E-Mail, an HTTP endpoint, and a Discord channel.
547548
548549
```ini
549550
[defaults]
550-
launch = apprise-mail, apprise-json, apprise-discord
551+
launch = apprise-mail, apprise-json, apprise-discord, apprise-ntfy
551552
552553
[config:apprise-mail]
553554
; Dispatch message as e-mail.
@@ -574,9 +575,16 @@ baseuri = 'json://localhost:1234/mqtthook'
574575
module = 'apprise'
575576
baseuri = 'discord://4174216298/JHMHI8qBe7bk2ZwO5U711o3dV_js'
576577
578+
[config:apprise-ntfy]
579+
; Dispatch message to ntfy.
580+
; https://github.com/caronc/apprise/wiki/URLBasics
581+
; https://github.com/caronc/apprise/wiki/Notify_ntfy
582+
module = 'apprise_single'
583+
baseuri = 'ntfy://user:password/ntfy.example.org/topic1/topic2'
584+
577585
[apprise-single-test]
578586
topic = apprise/single/#
579-
targets = apprise-mail:demo, apprise-json, apprise-discord
587+
targets = apprise-mail:demo, apprise-json, apprise-discord, apprise-ntfy
580588
format = Alarm from {device}: {payload}
581589
title = Alarm from {device}
582590
```
@@ -612,6 +620,7 @@ module = 'apprise_multi'
612620
targets = {
613621
'demo-http' : [ { 'baseuri': 'json://localhost:1234/mqtthook' }, { 'baseuri': 'json://daq.example.org:5555/foobar' } ],
614622
'demo-discord' : [ { 'baseuri': 'discord://4174216298/JHMHI8qBe7bk2ZwO5U711o3dV_js' } ],
623+
'demo-ntfy' : [ { 'baseuri': 'ntfy://user:password/ntfy.example.org/topic1/topic2' } ],
615624
'demo-mailto' : [ {
616625
'baseuri': 'mailtos://smtp_username:smtp_password@mail.example.org',
617626
'recipients': ['foo@example.org', 'bar@example.org'],
@@ -622,7 +631,7 @@ targets = {
622631
623632
[apprise-multi-test]
624633
topic = apprise/multi/#
625-
targets = apprise-multi:demo-http, apprise-multi:demo-discord, apprise-multi:demo-mailto
634+
targets = apprise-multi:demo-http, apprise-multi:demo-discord, apprise-multi:demo-mailto, apprise-multi:demo-ntfy
626635
format = Alarm from {device}: {payload}
627636
title = Alarm from {device}
628637
```
@@ -2016,6 +2025,15 @@ def check_temperature(data):
20162025
Requires:
20172026
* [pynsca](https://github.com/djmitche/pynsca).
20182027
2028+
2029+
### `ntfy`
2030+
2031+
Support for [ntfy] is provided through Apprise, see [apprise_single](#apprise_single)
2032+
and [apprise_multi](#apprise_multi).
2033+
2034+
[ntfy]: https://ntfy.sh/
2035+
2036+
20192037
### `desktopnotify`
20202038
20212039
It invokes desktop notifications, using the fine

tests/services/test_apprise_multi.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def test_apprise_multi_basic_success(apprise_asset, apprise_mock, srv, caplog):
2020
addrs=[
2121
{"baseuri": "json://localhost:1234/mqtthook"},
2222
{"baseuri": "json://daq.example.org:5555/foobar"},
23+
{"baseuri": "ntfy://user:password/ntfy.example.org/topic1/topic2"},
2324
],
2425
title="⚽ Message title ⚽",
2526
message="⚽ Notification message ⚽",
@@ -31,15 +32,18 @@ def test_apprise_multi_basic_success(apprise_asset, apprise_mock, srv, caplog):
3132
call(asset=mock.ANY),
3233
call().add("json://localhost:1234/mqtthook"),
3334
call().add("json://daq.example.org:5555/foobar"),
35+
call().add("ntfy://user:password/ntfy.example.org/topic1/topic2"),
3436
call().notify(body="⚽ Notification message ⚽", title="⚽ Message title ⚽"),
3537
call().notify().__bool__(),
3638
]
3739

3840
assert outcome is True
3941
assert (
4042
"Sending notification to Apprise. target=None, addresses=["
41-
"{'baseuri': 'json://localhost:1234/mqtthook'}, {'baseuri': 'json://daq.example.org:5555/foobar'}]"
42-
in caplog.messages
43+
"{'baseuri': 'json://localhost:1234/mqtthook'}, "
44+
"{'baseuri': 'json://daq.example.org:5555/foobar'}, "
45+
"{'baseuri': 'ntfy://user:password/ntfy.example.org/topic1/topic2'}"
46+
"]" in caplog.messages
4347
)
4448
assert "Successfully sent message using Apprise" in caplog.messages
4549

0 commit comments

Comments
 (0)