Just a quick note if you want to use ntfy.sh with Home Assistant.

Setup

I added the following section to my /config/configuration.yaml file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
shell_command:
    ntfy: >
        curl
        -X POST
        --url 'https://ntfy.sh/{{ topic }}'
        --data '{{ message }}'
        --header 'X-Title: {{ title }}'
        --header 'X-Tags: {{ tags }}'
        --header 'X-Priority: {{ priority }}'
        --header 'X-Delay: {{ delay }}'
        --header 'X-Actions: {{ actions }}'
        --header 'X-Click: {{ click }}'
        --header 'X-Icon: {{ icon }}'{% endraw %}        

Usage

To send send a notification, I use this YAML action in an Automation. It’s not necessary to provide all parameters. I ran with these four. As far as I know: Theoretically only topic is required by ntfy. But this simple shell_command action does not check if you set a topic.

1
2
3
4
5
6
7
service: shell_command.ntfy
alias: Send ntfy.sh
data:
  tags: monocle_face
  topic: test
  title: Waschmaschine
  message: Die Waschmaschine ist fertig!{% endraw %}

Set default values

If you want to, you can also define default values. For example in this codeblock I’ve set the default topic to “test”. So if I don’t specify a topic when calling the command, it will fallback to test.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
shell_command:
    ntfy: >
        curl
        -X POST
        --url 'https://ntfy.sh/{{ topic | default("test") }}'
        --data '{{ message }}'
        --header 'X-Title: {{ title }}'
        --header 'X-Tags: {{ tags }}'
        --header 'X-Priority: {{ priority }}'
        --header 'X-Delay: {{ delay }}'
        --header 'X-Actions: {{ actions }}'
        --header 'X-Click: {{ click }}'
        --header 'X-Icon: {{ icon }}'{% endraw %}