I’ve tried to add ntfy as a notification service to my Home Assistant instance. I wrote a command-line script, that takes either STDIN or CLI arguments as input and then uses curl to my self-hosted notification server. For debugging purposes it even sends out a notification even if the message is missing. Everything works fine when I ssh into my HA and run the script from command line (execution rights are fine). But whatever I try, I seem unable to use this as a notification service in HA.
I’ve tried multiple variations of this configuration:
It does show up in the dev section, and I can trigger it without errors – but no notification is sent. Does anybody have an idea what I am doing wrong? Did I miss something?
I have still to try shell_command as suggest in some other threads – if I understand it correctly, I would lose the ability to notify with a custom message. But I might be wrong here.
Thanks!
Home Assistant 2022.7.6
Supervisor 2022.07.0
Operating System 8.2
Frontend 20220707.1 - latest
I am trying to send ntfy.sh via HA. It works fine with the title and body, but I can’t send the priority and tag. Here is my configuration:
notify.yaml
- name: ntfy
platform: rest
method: POST_JSON
data:
topic: test
title_param_name: title
message_param_name: message
resource: https://ntfy.sh
script:
alias: Test ntfy
sequence:
- service: notify.ntfy
data:
message: Nachricht
title: Titel
mode: single
Tag and priority work in Tasker with this command:
I didn’t tried it myself. There is a Matrix group for ntfy. I guess, there you have the biggest chance to get an answer, because ntfy isn’t widely known yet.
But now I don’t always want to send the same message via a ‘shell_command’ in the configuration.yaml. How could I fill the command with variables? I can create the command line by:
If you configure your ntfy rest_command with templates, you can override the values when the service is called. So start by adding this to your configuration:
rest_command:
notify_phone:
url: https://ntfy.sh/<put your topic here>
method: POST
headers:
title: "{{ title }}"
priority: "{{ priority | default('default') }}"
tags: "{{ tags | join(',') }}"
payload: "{{ message }}"
Then, and automation like this will send a default priority notification:
service: rest_command.notify_phone
data:
title: Heater pump has been running long
message: is it clogged?
tags:
- warning
And this will send an urgent one:
service: rest_command.notify_phone
data:
title: Water sensor detected water
message: {{ trigger.to_state.name }}
priority: urgent
tags:
- droplet
(I haven’t actually seen the water sensor one work - but I have the same templated message for an HA notification that does work.)