You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bundles/org.openhab.binding.ntfy/README.md
+29-27Lines changed: 29 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,20 +4,21 @@ The Ntfy binding enables openHAB to publish notifications to Ntfy-compatible ser
4
4
5
5
Ntfy is a simple HTTP-based notification service and message broker; see [ntfy.sh](https://ntfy.sh) for details and public servers.
6
6
7
-
It is intended for integrations where openHAB should push alert or informational messages to mobile or desktop clients that support the Ntfy protocol. The binding supports basic text messages as well as common rich features supported by the protocol: message priority, tags, icon URLs, attachments, click actions and simple action buttons.
7
+
It is intended for integrations where openHAB should push alert or informational messages to mobile or desktop clients that support the Ntfy protocol.
8
+
The binding supports basic text messages as well as common rich features supported by the protocol: message priority, tags, icon URLs, attachments, click actions and simple action buttons
8
9
9
10
Typical uses include doorbell alerts, security notifications, system health messages, or any automation that should notify users in real time via an Ntfy-compatible notification channel.
10
11
11
12
## Supported Things
12
13
13
-
This binding provides the following Thing types. The Thing type IDs match the definitions in `src/main/resources/OH-INF/thing/thing-types.xml`.
14
+
This binding provides the following Thing types:
14
15
15
-
-`ntfy:ntfyConnection` (bridge) — Represents a connection to an Ntfy server. Configure the bridge with the server hostname (for example `https://ntfy.sh`) and optional credentials (username/password). The bridge holds shared connection settings (hostname, username, password, connectionTimeout) which are used by topic Things.
16
-
-`ntfy:ntfyTopic` (Thing) — Represents a topic/channel on a configured Ntfy server. Each topic Thing must be associated with an `ntfyConnection` bridge and requires the `topicname` configuration parameter.
16
+
-`server` (bridge) — Represents a connection to an Ntfy server. The bridge holds shared connection settings (hostname, username, password, connectionTimeout) which are used by topic Things.
17
+
-`ntfy-Topic` (Thing) — Represents a topic/channel on a configured Ntfy server. Each topic Thing must be associated with a `server` bridge.
17
18
18
19
## Thing Configuration
19
20
20
-
### `ntfyConnection` Bridge Configuration
21
+
### `server` Bridge Configuration
21
22
22
23
| Name | Type | Description | Default | Required | Advanced |
@@ -26,45 +27,44 @@ This binding provides the following Thing types. The Thing type IDs match the de
26
27
| password | text | Optional password - if username is provided basic auth is used else Bearer token is used | N/A | no | no |
27
28
| connectionTimeout | integer | WebSocket / HTTP connection timeout ms | 60000 | no | yes |
28
29
29
-
Configure the `ntfyConnection` as a bridge to hold shared server and authentication settings. Topic Things reference the bridge to reuse these settings. For authentication with access token only set the password and leave the username empty.
30
+
Configure the `server` as a bridge to hold shared server and authentication settings.
31
+
For authentication with access token only set the password and leave the username empty.
30
32
31
-
### `ntfyTopic` Thing Configuration
33
+
### `ntfy-topic` Thing Configuration
32
34
33
35
| Name | Type | Description | Default | Required | Advanced |
|last-message | String | R | Last received message payload (read-only) |
46
+
|last-message-time| DateTime | R | Timestamp of the last message (read-only) |
47
+
|last-message-id| String | R | ID of the last message (read-only) |
46
48
47
49
## Full Example
48
50
49
-
Below are examples for textual configuration files showing a bridge (`ntfyConnection`), a topic Thing (`ntfyTopic`), Items bound to the Thing's channels, and a simple sitemap to display the last message and its timestamp.
51
+
Below are examples for textual configuration files showing a bridge (`server`), a topic Thing (`ntfy-topic`), Items bound to the Thing's channels, and a simple sitemap to display the last message and its timestamp.
Thing ntfy:ntfyTopic:home "Front Door Notifications" (ntfy:ntfyConnection:myConn) [ topicname="home" ]
58
+
Thing ntfy:ntfy-topic:home "Front Door Notifications" (ntfy:server:myConn) [ topicname="home" ]
57
59
```
58
60
59
-
If your server requires authentication, supply `username` and `password` in the bridge configuration. The `topicname` must be provided for each `ntfyTopic` Thing.
60
-
61
61
### Item Configuration (items file)
62
62
63
63
Bind Items to the read-only channels exposed by the topic Thing to show the last received message and its timestamp:
64
64
65
-
```items
66
-
String FrontDoorLastMessage "Front Door Message" { channel="ntfy:ntfyTopic:home:lastMessage" }
Note: Sending notifications from openHAB to ntfy is done via the binding's Actions from rules (the binding exposes Actions to publish/delete messages). The channels above are read-only and show incoming or last-state values.
@@ -73,7 +73,7 @@ Note: Sending notifications from openHAB to ntfy is done via the binding's Actio
73
73
74
74
Simple sitemap demonstrating how to display the last message and its timestamp:
75
75
76
-
```sitemap
76
+
```perl
77
77
sitemap notifications label="Notifications"
78
78
{
79
79
<Frame label="Front Door">
@@ -85,9 +85,11 @@ Simple sitemap demonstrating how to display the last message and its timestamp:
85
85
86
86
## Actions (Rules DSL and JavaScript)
87
87
88
-
This binding exposes Rule Actions to send and manage messages on a configured topic. Actions are available for use from the Rules DSL and the ECMAScript/JavaScript automation scripts. The actions support a builder-style API to configure a message (message text, priority, tags, icon, attachments, actions, sequence id, ...) and then send it.
88
+
This binding exposes Rule Actions to send and manage messages on a configured topic.
89
+
Actions are available for use from the Rules DSL and the ECMAScript/JavaScript automation scripts.
90
+
The actions support a builder-style API to configure a message (message text, priority, tags, icon, attachments, actions, sequence id, ...) and then send it.
89
91
90
-
Important: Always check that the returned actions object is not null (the Thing must exist and be handled by the binding) before invoking methods.
92
+
Important: Always check that the Thing exist before invoking methods.
91
93
92
94
### Available action methods
93
95
@@ -118,7 +120,7 @@ For more information about ntfy features and the notification format, see the nt
118
120
119
121
```rules
120
122
// Obtain the Thing-specific actions and use the builder to send a message
121
-
val bindingActions = getActions("ntfy", "ntfy:ntfyTopic:frontdoor")
123
+
val bindingActions = getActions("ntfy", "ntfy:ntfy-topic:frontdoor")
122
124
if (bindingActions !== null) {
123
125
// simple one-liner: send a message
124
126
val msgId = bindingActions.withMessage("Someone is at the door").withPriority(4).send()
@@ -144,7 +146,7 @@ In ECMAScript scripts you can obtain the Thing Actions and use the same builder
144
146
145
147
```javascript
146
148
// get the Thing actions for the topic Thing
147
-
var bindingActions =actions.get("ntfy", "ntfy:ntfyTopic:frontdoor");
149
+
var bindingActions =actions.get("ntfy", "ntfy:ntfy-topic:frontdoor");
148
150
if (bindingActions) {
149
151
// send a simple message
150
152
var id =bindingActions.withMessage("Garage opened").withPriority(3).send();
Copy file name to clipboardExpand all lines: bundles/org.openhab.binding.ntfy/src/main/java/org/openhab/binding/ntfy/internal/NtfyConnectionHandler.java
0 commit comments