Using ntfy.sh from Home Assistant

While surfing Reddit one day I ran across a post about Unified Push and setting up ones own self hosted push notification system. A push notification system that can be self hosted and isn’t owned by any of the big tech companies, which I’m all for. So I decided to test it out by setting up home assistant notifications through it. While here I won’t be installing and setting up my own ntfy.sh server right now, I will probably be doing that part in the future.

Pre-Reqs on Home Assistant

  • No additional add-ons needed
  • No additional integrations needed
  • No HACS add-ons needed
  • No HACS integrations needed

Yes it really just works (TM) in baseline home assistant with no additional customizations needed.

Home Assistant Config Addition

Update your home assistant configuration to include the new notification platform. If you already have the “notify” tag in your yaml, you can just add this into your already existing list of notification agents.

notify:
- name: ntfy
platform: rest
method: POST_JSON
data:
topic: secret-topic
title_param_name: title
message_param_name: message
resource: https://ntfy.sh

For my topic, I picked a name that was logical for me, and then I had bitwarden generate a small random string to tack into the end of it. If you’re worried about security, just make that string longer. It makes it hard to type it in to something, but hard for someone to guess as well in case you don’t want someone knowing what your notifications are.

Now in this case, all your home assistant notifications will use the same topic, if you need multiple topics, you can add additional ntfy agents all with unique names, or us the topic as another input when calling it from a script or automation.

Usage in Automations / Scripts

Using it in a notification couldn’t be easier. Simply provide the message and title for the notification and fire it away.

service: notify.ntfy
data:
message: world
title: hello

I can also give a script demo on using it too, just as easy as an automation.

alias: Test ntfy
sequence:
- service: notify.ntfy
data:
message: world
title: hello
mode: single

Phone Setup

I installed the ntfy.sh app via FDroid on my phone and all it required to receive the notification was the topic name that we set in home assistant. With that set, we have a push notification channel open.

Conclusion

This was super easy to set up and seems to get the notifications much faster than using SMS (the previous way I had set up my notifications). While it does still rely on an external service, that service can be self hosted someplace to remove reliance on any entity.

Resources

Leave a Reply