I have been using ntfy for quite a while now to stay informed about my home automation events. While it’s easy to trigger via HTTP, I grew tired of manually constructing complex API requests using sendHttpPostRequest or executeCommandLine curls in my rules. It felt cluttered and was a pain to maintain across different scripts. So, I decided to build a native binding to make the integration as clean and “openHAB-native” as possible.
Hosting & Privacy
One of the best things about ntfy is its flexibility regarding hosting. You can choose what fits your setup best:
Public Service: Use it out-of-the-box with ntfy.sh (no account required for public topics).
Self-Hosted: For maximum privacy, you can easily host your own instance. It’s available as a lightweight Docker image, a Go binary, or can be installed via Linux packages. This makes it a perfect companion for those already running openHABian or a home server.
Why use ntfy?
Privacy first: It’s open-source and can be easily self-hosted (e.g., via Docker).
No “Cloud” needed: While it works with the public ntfy.sh server, you have full control if you host it yourself.
Instant: Notifications are delivered in near real-time.
Simple: No heavy APIs—just simple HTTP calls under the hood.
Features
Rule Actions: Send notifications from any rule (DSL, JS, Blockly).
Customization: Support for titles, priorities (1-5), tags (emojis), and click-URLs.
Authentication: Supports public topics as well as private instances requiring credentials.
Bridge/Thing Architecture: Configure your ntfy server as a Bridge and create “Topics” as Things.
Installation & Testing
I’m looking forward to your feedback! Please let me know if you encounter any issues or have ideas for additional features.
If you post this to the marketplace, following the template provided when you create the post, users can install and use your new binding from the add-on store just like official add-ons.
I’ve been self-hosting an instance of ntfy and have it set up to use access tokens for authentication. I’d like to help you test this binding but will need you to add this capability to authenticate using an access token to the Bridge configuration.
I am testing on a 5.2.0 build. Using the UI to add the thing configurations.
I reinstalled the binding, Restarted OpenHab, and recreated the Bridge and Topic thing. For the bridge configuration I left the username empty and entered a token in the password field. The bridge came online after saving it.
Then I created a Topic thing, associated it with bridge. Added a topic name and saved it. As soon as I did that, the bridge and topic started going offline and with the Topic showing the Bridge Offline.
I changed logging to debug. Here’s a series of log entries. It seems the token is not accepted - getting a 401 unauthorized error.
ant 15:05:38.285 DEBUG
org.openhab.binding.ntfy.internal.network.NtfyWebSocket
Connection failed: Failed to upgrade to websocket: Unexpected HTTP Response Status Code: 429 Too Many Requests
info_circle 15:05:38.290 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:server:31650a9d68' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Failed to upgrade to websocket: Unexpected HTTP Response Status Code: 429 Too Many Requests
info_circle 15:05:38.291 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:ntfy-topic:31650a9d68:5bb1e0ac46' changed from OFFLINE to OFFLINE (BRIDGE_OFFLINE)
info_circle 15:06:08.298 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:server:31650a9d68' changed from OFFLINE (COMMUNICATION_ERROR): Failed to upgrade to websocket: Unexpected HTTP Response Status Code: 429 Too Many Requests to ONLINE
info_circle 15:06:08.300 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:ntfy-topic:31650a9d68:5bb1e0ac46' changed from OFFLINE (BRIDGE_OFFLINE) to UNKNOWN
info_circle 15:06:08.444 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:ntfy-topic:31650a9d68:5bb1e0ac46' changed from UNKNOWN to OFFLINE
info_circle 15:06:08.448 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:server:31650a9d68' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): 401 Unauthorized
info_circle 15:06:08.450 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:ntfy-topic:31650a9d68:5bb1e0ac46' changed from OFFLINE to OFFLINE (BRIDGE_OFFLINE)
ant 15:06:08.450 DEBUG
org.openhab.binding.ntfy.internal.network.NtfyWebSocket
Connection failed: 401 Unauthorized
info_circle 15:06:38.452 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:server:31650a9d68' changed from OFFLINE (COMMUNICATION_ERROR): 401 Unauthorized to ONLINE
info_circle 15:06:38.453 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:ntfy-topic:31650a9d68:5bb1e0ac46' changed from OFFLINE (BRIDGE_OFFLINE) to UNKNOWN
ant 15:06:38.601 DEBUG
org.openhab.binding.ntfy.internal.network.NtfyWebSocket
Connection failed: Failed to upgrade to websocket: Unexpected HTTP Response Status Code: 429 Too Many Requests
info_circle 15:06:38.603 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:ntfy-topic:31650a9d68:5bb1e0ac46' changed from UNKNOWN to OFFLINE
info_circle 15:06:38.604 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:server:31650a9d68' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Failed to upgrade to websocket: Unexpected HTTP Response Status Code: 429 Too Many Requests
info_circle 15:06:38.607 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:ntfy-topic:31650a9d68:5bb1e0ac46' changed from OFFLINE to OFFLINE (BRIDGE_OFFLINE)
info_circle 15:07:08.604 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:server:31650a9d68' changed from OFFLINE (COMMUNICATION_ERROR): Failed to upgrade to websocket: Unexpected HTTP Response Status Code: 429 Too Many Requests to ONLINE
info_circle 15:07:08.608 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:ntfy-topic:31650a9d68:5bb1e0ac46' changed from OFFLINE (BRIDGE_OFFLINE) to UNKNOWN
info_circle 15:07:08.744 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:ntfy-topic:31650a9d68:5bb1e0ac46' changed from UNKNOWN to OFFLINE
info_circle 15:07:08.746 INFO
openhab.event.ThingStatusInfoChangedEvent
Thing 'ntfy:server:31650a9d68' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): 401 Unauthorized
ant 15:07:08.747 DEBUG
org.openhab.binding.ntfy.internal.network.NtfyWebSocket
Connection failed: 401 Unauthorized
This is the error you get when the server is throttling. Is this some BS service with a “premium” plan that you have to buy unless you use it very infrequently? If so, that would explain the 429. Alternatively, the binding sends requests to rapidly. Sometimes, you have to wait a little bit between requests, or risk a 429.
FYI and for what its worth I’m self-hosting this Ntfy server and the only one that uses it and don’t have any restrictions set other than the usual defaults…
You should look in the server logs and see if you can find the reason for the 429’s then. A 429 literally means “too many requests” (within some timeframe), it’s not something you see if there’s something else wrong with the request (then you would get that error instead). Maybe you have some “DOS protection” or similar running on the server that blocks if requests arrive too rapidly?
I assumed there was a default timeout set, but added 60000 ms (1 min) to the config. Not sure if that helped, but not seeing 429 messages just 401 unauthorized…
Are you referring to the web server config now? I’m not sure why a timeout would impact this. Does the server support websockets? It seems to fail when it tries to upgrade the “regular” HTTP connection to a websockets connection.
I have way too little knowledge of how you configure such a server to be of much help troubleshooting this, maybe somebody else has the necessary knowledge. Is there some way you can connect to your server, using websockets, from something else, so that you know that the server itself is working like it should?