@@ -223,22 +223,22 @@ template arguments. mqttwarn supports propagating them from either the
223
223
`` baseuri `` configuration setting, or from its data dictionary to the Apprise
224
224
plugin invocation.
225
225
226
- So, for example, you can propagate parameters to the [ Apprise Ntfy plugin ]
227
- by either pre-setting them as URL query parameters, like
226
+ So, for example, you can propagate parameters to the [ Apprise JSON HTTP POST
227
+ Notifications plugin ] by either pre-setting them as URL query parameters, like
228
228
```
229
- ntfy ://user:password@ntfy.example.org/topic1/topic2?email=test@example.org
229
+ json ://localhost/?:sound=oceanwave
230
230
```
231
231
or by submitting them within a JSON-formatted MQTT message, like
232
232
``` json
233
- {"priority " : " high " , "tags" : " foo,bar" , "click" : " https://httpbin.org/headers" }
233
+ {":sound " : " oceanwave " , "tags" : " foo,bar" , "click" : " https://httpbin.org/headers" }
234
234
```
235
235
236
236
237
237
[ Apprise ] : https://github.com/caronc/apprise
238
238
[ Apprise documentation ] : https://github.com/caronc/apprise/wiki
239
239
[ Apprise URL Basics ] : https://github.com/caronc/apprise/wiki/URLBasics
240
240
[ Apprise Notification Services ] : https://github.com/caronc/apprise/wiki#notification-services
241
- [ Apprise Ntfy plugin ] : https://github.com/caronc/apprise/wiki/Notify_ntfy
241
+ [ Apprise JSON HTTP POST Notifications plugin ] : https://github.com/caronc/apprise/wiki/Notify_Custom_JSON
242
242
243
243
244
244
### ` apprise_single `
@@ -256,7 +256,7 @@ Apprise to E-Mail, an HTTP endpoint, and a Discord channel.
256
256
257
257
``` ini
258
258
[defaults]
259
- launch = apprise-mail, apprise-json, apprise-discord, apprise-ntfy
259
+ launch = apprise-mail, apprise-json, apprise-discord
260
260
261
261
[config:apprise-mail]
262
262
; Dispatch message as e-mail.
@@ -283,16 +283,9 @@ baseuri = 'json://localhost:1234/mqtthook'
283
283
module = ' apprise_single'
284
284
baseuri = ' discord://4174216298/JHMHI8qBe7bk2ZwO5U711o3dV_js'
285
285
286
- [config:apprise-ntfy]
287
- ; Dispatch message to ntfy.
288
- ; https://github.com/caronc/apprise/wiki/URLBasics
289
- ; https://github.com/caronc/apprise/wiki/Notify_ntfy
290
- module = ' apprise_single'
291
- baseuri = ' ntfy://user:password@ntfy.example.org/topic1/topic2'
292
-
293
286
[apprise-single-test]
294
287
topic = apprise/single/#
295
- targets = apprise-mail:demo, apprise-json, apprise-discord, apprise-ntfy
288
+ targets = apprise-mail:demo, apprise-json, apprise-discord
296
289
format = Alarm from {device}: {payload}
297
290
title = Alarm from {device}
298
291
```
@@ -325,7 +318,6 @@ module = 'apprise_multi'
325
318
targets = {
326
319
' demo-http' : [ { ' baseuri' : ' json://localhost:1234/mqtthook' }, { ' baseuri' : ' json://daq.example.org:5555/foobar' } ],
327
320
' demo-discord' : [ { ' baseuri' : ' discord://4174216298/JHMHI8qBe7bk2ZwO5U711o3dV_js' } ],
328
- ' demo-ntfy' : [ { ' baseuri' : ' ntfy://user:password@ntfy.example.org/topic1/topic2' } ],
329
321
' demo-mailto' : [ {
330
322
' baseuri' : ' mailtos://smtp_username:smtp_password@mail.example.org' ,
331
323
' recipients' : [' foo@example.org' , ' bar@example.org' ],
@@ -336,7 +328,7 @@ targets = {
336
328
337
329
[apprise-multi-test]
338
330
topic = apprise/multi/#
339
- targets = apprise-multi:demo-http, apprise-multi:demo-discord, apprise-multi:demo-mailto, apprise-multi:demo-ntfy
331
+ targets = apprise-multi:demo-http, apprise-multi:demo-discord, apprise-multi:demo-mailto
340
332
format = Alarm from {device}: {payload}
341
333
title = Alarm from {device}
342
334
```
@@ -1746,10 +1738,151 @@ Requires:
1746
1738
1747
1739
### ` ntfy `
1748
1740
1749
- Support for [ ntfy] is provided through Apprise, see [ apprise_single] ( #apprise_single )
1750
- and [ apprise_multi] ( #apprise_multi ) .
1741
+ > [ ntfy] (pronounce: _ notify_ ) is a simple HTTP-based [ pub-sub] notification service.
1742
+ > It allows you to send notifications to your phone or desktop via scripts from
1743
+ > any computer, entirely without signup, cost or setup.
1744
+ > [ ntfy is also open source] ( https://github.com/binwiederhier/ntfy ) , if you want to
1745
+ > run an instance on your own premises.
1746
+
1747
+ ntfy uses topics to address communication channels. This topic is part of the
1748
+ HTTP API URL.
1749
+
1750
+ To use the hosted variant on ` ntfy.sh ` , just provide an URL including the topic.
1751
+ ``` ini
1752
+ [config:ntfy]
1753
+ targets = {
1754
+ ' test' : ' https://ntfy.sh/testdrive' ,
1755
+ }
1756
+ ```
1757
+
1758
+ When running your own instance, you would use a custom URL here.
1759
+ ``` ini
1760
+ [config:ntfy]
1761
+ targets = {
1762
+ ' test' : ' http://username:password@localhost:5555/testdrive' ,
1763
+ }
1764
+ ```
1765
+
1766
+ In order to specify more options, please wrap your ntfy URL into a dictionary
1767
+ under the ` url ` key. This way, additional options can be added.
1768
+ ``` ini
1769
+ [config:ntfy]
1770
+ targets = {
1771
+ ' test' : {
1772
+ ' url' : ' https://ntfy.sh/testdrive' ,
1773
+ },
1774
+ }
1775
+ ```
1776
+
1777
+ :::{important}
1778
+ [ ntfy publishing options] outlines different ways to marshal data to the ntfy
1779
+ HTTP API. mqttwarn is using HTTP headers for serializing values, because the
1780
+ HTTP body will already be used for the attachment file. Because of this, you
1781
+ are not able to use UTF-8 characters within your message text, they will be
1782
+ replaced by placeholder characters like ` ? ` .
1783
+ :::
1784
+
1785
+ {#ntfy-remote-attachments}
1786
+ #### Remote attachments
1787
+ In order to submit notifications with an attachment file at a remote location,
1788
+ use the ` attach ` field. Optionally, the ` filename ` field can be used to assign
1789
+ a different name to the file.
1790
+ ``` ini
1791
+ [config:ntfy]
1792
+ targets = {
1793
+ ' test' : {
1794
+ ' url' : ' https://ntfy.sh/testdrive' ,
1795
+ ' attach' : ' https://unsplash.com/photos/spdQ1dVuIHw/download?w=320' ,
1796
+ ' filename' : ' goat.jpg' ,
1797
+ },
1798
+ }
1799
+ ```
1800
+
1801
+ {#ntfy-local-attachments}
1802
+ #### Local attachments
1803
+ By using the ` attachment ` option, you can add an attachment to your message, local
1804
+ to the machine mqttwarn is running on. The file will be uploaded when submitting
1805
+ the notification, and ntfy will serve it for clients so that you don't have to. In
1806
+ order to address the file, you can provide a path template, where the transformation
1807
+ data will also get interpolated into.
1808
+ ``` ini
1809
+ [config:ntfy]
1810
+ targets = {
1811
+ ' test' : {
1812
+ ' url' : ' https://ntfy.sh/testdrive' ,
1813
+ ' attachment' : ' /tmp/ntfy-attachment-{slot}-{label}.png' ,
1814
+ }
1815
+ }
1816
+ ```
1817
+ :::{important}
1818
+ In order to allow users to ** upload** and attach files to notifications, you will
1819
+ need to enable the corresponding ntfy feature by simply configuring an attachment
1820
+ cache directory and a base URL (` attachment-cache-dir ` , ` base-url ` ), see
1821
+ [ ntfy stored attachments] .
1822
+ :::
1823
+ :::{note}
1824
+ When mqttwarn processes a message, and accessing the file raises an error, it gets
1825
+ handled gracefully. In this way, notifications will be triggered even when attaching
1826
+ the file fails for whatever reasons.
1827
+ :::
1828
+
1829
+ #### Publishing options
1830
+ You can use all the available [ ntfy publishing options] , by using the corresponding
1831
+ option names listed within ` NTFY_FIELD_NAMES ` , which are: ` message ` , ` title ` , ` tags ` ,
1832
+ ` priority ` , ` actions ` , ` click ` , ` attach ` , ` filename ` , ` delay ` , and ` email ` .
1833
+
1834
+ You can obtain ntfy option fields from _ three_ contexts in total, as implemented
1835
+ by the ` obtain_ntfy_fields ` function. Effectively, that means that you can place
1836
+ them either within the ` targets ` address descriptor, within the configuration
1837
+ section, or submit them using a JSON MQTT message and a corresponding decoder
1838
+ function into the transformation data dictionary.
1839
+
1840
+ For example, you can always send a ` priority ` field using MQTT/JSON, or use one of
1841
+ those configuration snippets, which are equivalent.
1842
+ ``` ini
1843
+ [config:ntfy]
1844
+ targets = {
1845
+ ' test' : {
1846
+ ' url' : ' https://ntfy.sh/testdrive' ,
1847
+ ' priority' : ' high' ,
1848
+ }
1849
+ }
1850
+ ```
1851
+ ``` ini
1852
+ [config:ntfy]
1853
+ targets = {
1854
+ ' test' : {
1855
+ ' url' : ' https://ntfy.sh/testdrive' ,
1856
+ }
1857
+ }
1858
+ priority = high
1859
+ ```
1860
+
1861
+ The highest precedence takes data coming in from the transformation data dictionary,
1862
+ followed by option fields coming in from the per-recipient ` targets ` address descriptor,
1863
+ followed by option fields defined on the ` [config:ntfy] ` configuration section.
1864
+
1865
+ #### Examples
1866
+
1867
+ 1 . This is another way to write the "[ remote attachments] ( #ntfy-remote-attachments ) "
1868
+ example, where all ntfy options are located on the configuration section, so they
1869
+ will apply for all configured target addresses.
1870
+ ``` ini
1871
+ [config:ntfy]
1872
+ targets = {' test' : ' https://ntfy.sh/testdrive' }
1873
+ attach = https://unsplash.com/photos/spdQ1dVuIHw/download?w =320
1874
+ filename = goat.jpg
1875
+ ```
1876
+
1877
+ 2 . The tutorial [ ] ( #processing-frigate-events ) explains how to configure mqttwarn to
1878
+ notify the user with events emitted by Frigate, a network video recorder (NVR)
1879
+ with realtime local object detection for IP cameras.
1880
+
1751
1881
1752
1882
[ ntfy ] : https://ntfy.sh/
1883
+ [ ntfy publishing options ] : https://docs.ntfy.sh/publish/
1884
+ [ ntfy stored attachments ] : https://docs.ntfy.sh/config/#attachments
1885
+ [ pub-sub ] : https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern
1753
1886
1754
1887
1755
1888
### ` desktopnotify `
0 commit comments