{"id":2326,"date":"2023-05-15T11:12:22","date_gmt":"2023-05-15T16:12:22","guid":{"rendered":"https:\/\/lab.rapternet.us\/?p=2326"},"modified":"2023-08-18T09:45:22","modified_gmt":"2023-08-18T14:45:22","slug":"using-ntfy-sh-from-home-assistant","status":"publish","type":"post","link":"https:\/\/lab.rapternet.us\/?p=2326","title":{"rendered":"Using ntfy.sh from Home Assistant"},"content":{"rendered":"\n<p>While surfing Reddit one day I ran across a <a rel=\"noreferrer noopener\" href=\"https:\/\/www.reddit.com\/r\/selfhosted\/comments\/zsqx9y\/unifiedpush_a_decentralized_opensource_push\/j19kgbm?utm_medium=android_app&amp;utm_source=share&amp;context=3\" target=\"_blank\">post about Unified Push<\/a> and setting up ones own self hosted push notification system. A push notification system that can be self hosted and isn&#8217;t owned by any of the big tech companies, which I&#8217;m all for. So I decided to test it out by setting up home assistant notifications through it. While here I won&#8217;t be installing and setting up my own ntfy.sh server right now, I will probably be doing that part in the future.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Pre-Reqs on Home Assistant<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>No additional add-ons needed<\/li>\n\n\n\n<li>No additional integrations needed<\/li>\n\n\n\n<li>No HACS add-ons needed<\/li>\n\n\n\n<li>No HACS integrations needed<\/li>\n<\/ul>\n\n\n\n<p>Yes it really just works (TM) in baseline home assistant with no additional customizations needed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Home Assistant Config Addition<\/h2>\n\n\n\n<p>Update your home assistant configuration to include the new notification platform. If you already have the &#8220;notify&#8221; tag in your yaml, you can just add this into your already existing list of notification agents.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">notify:<br>  - name: ntfy<br>    platform: rest<br>    method: POST_JSON<br>    data:<br>      topic: secret-topic<br>    title_param_name: title<br>    message_param_name: message<br>    resource: https:\/\/ntfy.sh<br><\/pre>\n\n\n\n<p>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&#8217;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&#8217;t want someone knowing what your notifications are.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Usage in Automations \/ Scripts<\/h2>\n\n\n\n<p>Using it in a notification couldn&#8217;t be easier. Simply provide the message and title for the notification and fire it away.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">service: notify.ntfy<br>data:<br>  message: world <br>  title: hello<br><\/pre>\n\n\n\n<p>I can also give a script demo on using it too, just as easy as an automation.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">alias: Test ntfy<br>sequence:<br>  - service: notify.ntfy<br>    data:<br>      message: world<br>      title: hello<br>mode: single<br><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Phone Setup <\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/community.home-assistant.io\/t\/ntfy-notification-via-cli-curl-does-not-work\/442383\/4\" target=\"_blank\">Home Assistant Forums<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.ntfy.sh\">ntfy.sh Documentation<\/a><\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/f-droid.org\/2022\/12\/18\/unifiedpush.html\" target=\"_blank\">Unified Push<\/a><\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/unifiedpush.org\/users\/apps\/\" target=\"_blank\">Apps Supporting Unified Push<\/a><\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/caronc\/apprise\/wiki\/Notify_ntfy\" target=\"_blank\">More NTFY information<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t owned by any of the big tech companies, which I&#8217;m all for. So I decided to test it out by setting &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lab.rapternet.us\/?p=2326\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Using ntfy.sh from Home Assistant&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[39,98,49],"class_list":["post-2326","post","type-post","status-publish","format-standard","hentry","category-how-to","tag-home-assistant","tag-ntfy","tag-smart-home"],"_links":{"self":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/2326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2326"}],"version-history":[{"count":3,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/2326\/revisions"}],"predecessor-version":[{"id":2726,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/2326\/revisions\/2726"}],"wp:attachment":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}