iobroker.ntfy-client 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 lubepi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,318 @@
1
+ ![Logo](admin/ntfy-client.png)
2
+
3
+ # ioBroker.ntfy-client
4
+
5
+ [![NPM version](https://img.shields.io/npm/v/iobroker.ntfy-client.svg)](https://www.npmjs.com/package/iobroker.ntfy-client)
6
+ [![Downloads](https://img.shields.io/npm/dm/iobroker.ntfy-client.svg)](https://www.npmjs.com/package/iobroker.ntfy-client)
7
+ ![Number of Installations](https://iobroker.live/badges/ntfy-client-installed.svg)
8
+ ![Current version in stable repository](https://iobroker.live/badges/ntfy-client-stable.svg)
9
+
10
+ [![NPM](https://nodei.co/npm/iobroker.ntfy-client.png?downloads=true)](https://nodei.co/npm/iobroker.ntfy-client/)
11
+
12
+ **Tests:** [![Test and Release](https://github.com/lubepi/ioBroker.ntfy-client/workflows/Test%20and%20Release/badge.svg)](https://github.com/lubepi/ioBroker.ntfy-client/actions?query=workflow%3A%22Test+and+Release%22)
13
+
14
+ Unofficial ntfy.sh client adapter for ioBroker
15
+
16
+ Send and receive notifications via [ntfy.sh](https://ntfy.sh) directly from ioBroker. This adapter is a community project and not affiliated with ntfy LLC.
17
+
18
+ ### Features
19
+
20
+ - **Publish notifications** with full ntfy parameter support
21
+ - **Subscribe to topics** and receive messages in real-time via SSE (Server-Sent Events)
22
+ - **Account statistics** – view usage stats (messages, emails, calls, attachments, reservations)
23
+ - **Server version check** – detect available updates for self-hosted ntfy instances
24
+ - **Connection status** – monitor the adapter's connection to the ntfy server with dynamic health checks
25
+ - Basic authentication and bearer token support
26
+ - Custom server URLs (or the standard ntfy.sh instance)
27
+ - **Integrated `sendTo` Blockly blocks** for graphic scripts (send and manage)
28
+ - **Dismiss (clear) and delete notifications** by sequence ID
29
+ - File upload attachments via PUT
30
+
31
+ ### Supported Notification Parameters
32
+
33
+ | Parameter | Description |
34
+ | -------------- | ---------------------------------------------------------------------------------- |
35
+ | `message` | Notification message text (defaults to "triggered" if empty) |
36
+ | `topic` | Target topic (falls back to configured default topic) |
37
+ | `title` | Notification title |
38
+ | `priority` | Priority level: 1 (min), 2 (low), 3 (default), 4 (high), 5 (max) |
39
+ | `tags` | Tags or emoji shortcodes (comma-separated string or array) |
40
+ | `click` | URL opened when notification is clicked |
41
+ | `attach` | URL of file to attach |
42
+ | `attach_file` | Local file path to upload as attachment (uses PUT) |
43
+ | `filename` | Custom filename for the attachment |
44
+ | `actions` | Action buttons (JSON string or object) |
45
+ | `markdown` | Enable Markdown formatting (`true`/`false`) |
46
+ | `delay` | Delay delivery (e.g. "30s", "5m", "2h") |
47
+ | `email` | Forward notification to this email address |
48
+ | `call` | Phone number to call with TTS (requires ntfy Pro) |
49
+ | `icon` | Icon URL displayed next to the notification |
50
+ | `sequence_id` | Replace/update an existing notification with the same Sequence-ID |
51
+ | `disable_cache` | Set to `true`/`yes` to disable server-side caching |
52
+ | `disable_firebase` | Set to `true`/`yes` to disable forwarding to Firebase Cloud Messaging (Android) |
53
+ | `unified_push` | Set to `1` to enable UnifiedPush support |
54
+ | `template` | Use `true`/`yes` for inline templates, or a name like `github` for predefined ones |
55
+ | `data` | JSON data object or string to be used for the template context |
56
+
57
+ ### Topic Subscription (Receive Messages)
58
+
59
+ Configure topics in the adapter settings under the **Topics** tab. The adapter subscribes to these topics via SSE and creates states for each topic under `ntfy-client.0.topics.<topicName>`:
60
+
61
+ | State | Description |
62
+ | ----------------------- | ----------------------------------------- |
63
+ | `lastMessage` | Last received message text |
64
+ | `lastTitle` | Last received title |
65
+ | `lastPriority` | Last received priority |
66
+ | `lastTags` | Last received tags (comma-separated) |
67
+ | `lastClick` | Last received click URL |
68
+ | `lastIcon` | Last received icon URL |
69
+ | `lastActions` | Last received actions (JSON) |
70
+ | `lastAttachmentUrl` | Last received attachment URL |
71
+ | `lastAttachmentName` | Last received attachment name |
72
+ | `lastAttachmentType` | Last received attachment MIME type |
73
+ | `lastAttachmentSize` | Last received attachment size (bytes) |
74
+ | `lastAttachmentExpires` | Last received attachment expiry timestamp |
75
+ | `lastTimestamp` | Last message timestamp |
76
+ | `lastExpires` | Last message expiry timestamp |
77
+ | `lastMessageId` | Last message ID |
78
+ | `lastSequenceId` | Last sequence ID (for managing messages) |
79
+ | `lastTopic` | Last received topic name |
80
+ | `lastEvent` | Last received event type |
81
+ | `lastJson` | Full JSON of last received message |
82
+ | `subscribed` | Whether the subscription is active |
83
+
84
+ ### Account Statistics
85
+
86
+ When authentication is configured, the adapter fetches account statistics every 15 minutes and stores them under `ntfy-client.0.stats`:
87
+
88
+ - **Messages**: published, remaining, limit, expiry duration
89
+ - **Emails**: sent, remaining, limit
90
+ - **Phone calls**: made, remaining, limit
91
+ - **Reserved topics**: count, remaining, limit
92
+ - **Attachments**: storage used/remaining/limit, expiry duration, file size limit, bandwidth limit
93
+ - **Account**: subscription tier
94
+
95
+ ### Connection Status & Health Checks
96
+
97
+ The adapter monitors the connection to the ntfy server via the `info.connection` state:
98
+
99
+ | State | Description |
100
+ | ---------------------- | ------------------------------------------- |
101
+ | `info.connection` | Connection status to the ntfy server |
102
+ | `info.serverVersion` | Current ntfy server version |
103
+ | `info.latestVersion` | Latest available version (self-hosted only) |
104
+ | `info.updateAvailable` | Whether a server update is available |
105
+
106
+ The health check runs against the `/v1/health` endpoint with **dynamic intervals**:
107
+
108
+ - **Every 6 hours** when the server is healthy
109
+ - **Every 5 minutes** when the last check failed (for faster recovery)
110
+
111
+ Additionally, the connection status is automatically set to **connected** when:
112
+
113
+ - A notification is successfully sent
114
+ - An SSE subscription connects successfully
115
+ - A message is received on a subscribed topic
116
+
117
+ ### Blockly Examples
118
+
119
+ Under the **Sendto** category, use the following blocks:
120
+
121
+ #### 1. ntfy-client notification (send)
122
+
123
+ Dispatch a message with all supported parameters:
124
+
125
+ 1. Set the **Instance**.
126
+ 2. Set the **Message**.
127
+ 3. Set the **Topic** (or leave empty to use the default topic).
128
+ 4. Optionally add more parameters via the **mutator** (gear icon): title, priority, tags, icon, click URL, actions, attachments, delay, email, call, etc.
129
+ 5. Use **Sequence ID** if you want to update/overwrite an existing notification later.
130
+
131
+ #### 2. ntfy-client management (manage)
132
+
133
+ Clear or delete an existing notification:
134
+
135
+ 1. Set the **Instance**.
136
+ 2. Set the **Action** (mark as read and dismiss, or delete).
137
+ 3. Set the **Topic**.
138
+ 4. Set the **Sequence ID** of the message you want to manage.
139
+
140
+ > **Note on IDs:** Each notification is assigned a unique `id` (Message ID) by the server.
141
+ >
142
+ > - If you **provide** a `sequence_id` when sending, you **must use this `sequence_id`** for all management actions (dismiss, delete).
143
+ > - If you **do not provide** a `sequence_id`, the server-generated `id` (Message ID) serves as the `sequence_id` for management.
144
+ >
145
+ > Multiple messages sharing the same `sequence_id` form a sequence — only the latest message in a sequence is displayed.
146
+
147
+ ### JavaScript Examples
148
+
149
+ #### Send a notification
150
+
151
+ ```javascript
152
+ sendTo("ntfy-client.0", "send", {
153
+ message: "Motion detected in the backyard!",
154
+ title: "Security Alert",
155
+ topic: "home_alerts_xyz",
156
+ priority: "high",
157
+ tags: "warning,motion",
158
+ click: "https://example.com",
159
+ markdown: true,
160
+ });
161
+ ```
162
+
163
+ #### Send with email forwarding and icon
164
+
165
+ ```javascript
166
+ sendTo("ntfy-client.0", "send", {
167
+ message: "Temperature above threshold!",
168
+ topic: "home_alerts_xyz",
169
+ email: "admin@example.com",
170
+ icon: "https://example.com/icon.png",
171
+ priority: "4",
172
+ });
173
+ ```
174
+
175
+ #### Send with file attachment
176
+
177
+ ```javascript
178
+ sendTo("ntfy-client.0", "send", {
179
+ message: "Security camera snapshot",
180
+ topic: "home_alerts_xyz",
181
+ attach_file: "/tmp/snapshot.jpg",
182
+ filename: "camera_snapshot.jpg",
183
+ });
184
+ ```
185
+
186
+ #### Send with action buttons
187
+
188
+ ```javascript
189
+ sendTo("ntfy-client.0", "send", {
190
+ message: "Doorbell rang!",
191
+ topic: "home_alerts_xyz",
192
+ actions: [
193
+ { action: "view", label: "Open Camera", url: "https://camera.example.com" },
194
+ {
195
+ action: "http",
196
+ label: "Turn on Light",
197
+ url: "https://ha.example.com/api/light/on",
198
+ method: "POST",
199
+ },
200
+ ],
201
+ });
202
+ ```
203
+
204
+ #### Send with template (Inline / Manual)
205
+
206
+ Use the `message` field as your template string and provide the JSON context in the `data` field:
207
+
208
+ ```javascript
209
+ sendTo("ntfy-client.0", "send", {
210
+ topic: "home_alerts_xyz",
211
+ template: true,
212
+ message: "Current temperature is {{.temp}}°C from {{.sensor}}",
213
+ data: { temp: 42, sensor: "living_room" },
214
+ });
215
+ ```
216
+
217
+ #### Send with template (Predefined / e.g. GitHub)
218
+
219
+ For predefined templates like `github`, provide the original webhook JSON data in the `data` field. The data structure must match what the original service sends ([see template source](https://github.com/binwiederhier/ntfy/blob/main/server/templates/github.yml)):
220
+
221
+ ```javascript
222
+ sendTo("ntfy-client.0", "send", {
223
+ topic: "github_webhooks",
224
+ template: "github",
225
+ data: {
226
+ action: "opened",
227
+ issue: {
228
+ number: 42,
229
+ title: "Found a bug",
230
+ html_url: "https://github.com/my/repo/issues/42",
231
+ user: { html_url: "https://github.com/octocat" },
232
+ },
233
+ repository: {
234
+ full_name: "my/repo",
235
+ html_url: "https://github.com/my/repo",
236
+ },
237
+ },
238
+ });
239
+ ```
240
+
241
+ > **Note:** Predefined templates expect the **exact data structure** from the original service. Missing or misnamed fields will show as `<no value>`. For full control over formatting, use an inline template (`template: true`) instead.
242
+
243
+ #### Dismiss a notification
244
+
245
+ ```javascript
246
+ sendTo("ntfy-client.0", "dismiss", {
247
+ topic: "home_alerts_xyz",
248
+ sequence_id: "abc123",
249
+ });
250
+ ```
251
+
252
+ #### Delete a notification
253
+
254
+ ```javascript
255
+ sendTo("ntfy-client.0", "delete", {
256
+ topic: "home_alerts_xyz",
257
+ sequence_id: "abc123",
258
+ });
259
+ ```
260
+
261
+ ### Authentication
262
+
263
+ Ntfy supports a few variations:
264
+
265
+ - **None**: Suitable for standard ntfy.sh servers (topics are public!).
266
+ - **Basic Auth**: Setup a local server with Username and Password.
267
+ - **Access Token**: Create tokens and use Bearer token validation for your topic.
268
+
269
+ ### Commands
270
+
271
+ | Command | Description |
272
+ | ------------------- | ---------------------------------------------------- |
273
+ | `send` / `publish` | Send a notification |
274
+ | `dismiss` / `clear` | Dismiss (mark as read) a notification by sequence_id |
275
+ | `delete` | Delete a notification by sequence_id |
276
+
277
+ ## Changelog
278
+
279
+ ### 0.1.0
280
+
281
+ - (lubepi) Initial release with full ntfy.sh support
282
+ - Subscribe to topics via SSE (receive messages in real-time)
283
+ - Publish notifications with all ntfy parameters (title, priority, tags, click, attach, actions, markdown, delay, email, call, icon, sequence_id, disable_cache, disable_firebase, unified_push, template)
284
+ - File upload attachments via PUT
285
+ - Dismiss and delete notifications by sequence_id
286
+ - Account statistics (messages, emails, calls, attachments, reservations)
287
+ - Server version check for self-hosted instances
288
+ - Dynamic connection status monitoring with health checks
289
+ - Blockly blocks for sending and managing notifications
290
+ - Full i18n support (en, de, ru, pt, nl, fr, it, es, pl, uk, zh-cn)
291
+
292
+ ## License
293
+
294
+ MIT License
295
+
296
+ Copyright (c) 2026 lubepi
297
+
298
+ Permission is hereby granted, free of charge, to any person obtaining a copy
299
+ of this software and associated documentation files (the "Software"), to deal
300
+ in the Software without restriction, including without limitation the rights
301
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
302
+ copies of the Software, and to permit persons to whom the Software is
303
+ furnished to do so, subject to the following conditions:
304
+
305
+ The above copyright notice and this permission notice shall be included in all
306
+ copies or substantial portions of the Software.
307
+
308
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
309
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
310
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
311
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
312
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
313
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
314
+ SOFTWARE.
315
+
316
+ ## Legal Notice
317
+
318
+ This adapter is **NOT** an official product of ntfy LLC. The name **ntfy**, the logo and branding are trademarks of ntfy LLC. This adapter is a community project to provide integration into ioBroker.