Alert notification actions

Hi all,
I have several html5 push notification on low/high temperature alerts in the rooms and I want to add actions callback on them so I can acknowledge them from notification action button, turn on AC and so on. Here is example config:

binary_sensor:
  - platform: template
    sensors:
      bedroom_temp_low:
        value_template: >
        {% if states('sensor.temperature_bedroom') == 'unknown' %}False{% else %}
        {{ states('input_number.bedroom_temp') | int - states('input_number.temp_margin') | int > states('sensor.temperature_bedroom') | int }}
        {% endif %}
        friendly_name: "Low temperature in Bedroom"
        device_class: cold

      bedroom_temp_high:
        value_template: >
        {% if states('sensor.temperature_bedroom') == 'unknown' %}False{% else %}
        {{ states('input_number.bedroom_temp') | int + states('input_number.temp_margin') | int < states('sensor.temperature_bedroom') | int }}
        {% endif %}
        friendly_name: "High temperature in Bedroom"
        device_class: heat
alert:
  bedroom_temp_low:
    name: "Low temperature in bedroom"
    done_message: "Temperature is OK now"
    entity_id: binary_sensor.bedroom_temp_low
    repeat: 5
    skip_first: True
    notifiers:
      - google

  bedroom_temp_high:
    name: "High temperature in bedroom"
    done_message: "Temperature is OK now"
    entity_id: binary_sensor.bedroom_temp_high
    repeat: 5
    skip_first: True
    notifiers:
      - google

The one option was to add notification type group and from there to add actions, but I can’t get trigger entity to differentiate what action to send.
Do you know any other options how to achieve this?

@masarliev, I came across this thread looking for information on how to do the same thing. I don’t know if you ever got this to work but I just did (both in the mobile app and HTML5)!!

I wanted to get notified if I did something to the network that caused my DNS queries count to exceed a limit so I built this notifier that handles it for me. On the notification I wanted an option to quiet the continuous notifications by hitting the alert., this works…

input_number:
  pihole_dns_queries_threshold:
    name: PiHole DNS Queries Threshold
    initial: 70000
    min: 50000
    max: 200000
    step: 10000

binary_sensor:
  - platform: template
    sensors:
      pihole_queries_high:
        value_template: "{{ states('sensor.pi_hole_a_dns_queries_today')|int > states('input_number.pihole_dns_queries_threshold')|int }}"
        friendly_name: PiHole Queries High

alert:
  pihole_queries_high:
    name: PiHole Queries High
    entity_id: binary_sensor.pihole_queries_high
    repeat: 30
    notifiers:
      - mobile_app_pixel_4_xl
      - vapid_my_computer
    title: >
      PiHole Queries {% if states('sensor.pi_hole_a_dns_queries_today')|int > states('input_number.pihole_dns_queries_threshold')|int -%}High{%- else -%}Normal{%- endif %}
    message: >
      WARNING, PiHole-A DNS queries are now {{ states('sensor.pi_hole_a_dns_queries_today') }} which is over the {{ states('input_number.pihole_dns_queries_threshold') }} warning threshold!
    done_message: >
      NOTICE, PiHole-A DNS queries are now {{ states('sensor.pi_hole_a_dns_queries_today') }} which is below the {{ states('input_number.pihole_dns_queries_threshold') }} warning threshold.
    data:
      tag: pihole_alert
      priority: high
      actions:
        - action: pihole_queries_high_alert_off
          title: Turn alert off
      channel: Alert
      importance: high
      vibrationPattern: "100, 100, 100, 100, 100, 20, 20, 20, 20, 20, 20"
      ledColor: "green"

automation:
  - id: turn_off_pihole_queries_high_alert
    alias: Turn off PiHole queries high alert
    initial_state: true
    trigger:
      - platform: event
        event_type: html5_notification.clicked
        event_data:
          action: pihole_queries_high_alert_off
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: pihole_queries_high_alert_off
    action:
      - service: homeassistant.turn_off
        entity_id: alert.pihole_queries_high
      - service: html5.dismiss
        data:
          data:
            tag: pihole_alert
      - service: notify.mobile_app_pixel_4_xl
        data:
          message: clear_notification
          data:
            tag: pihole_alert

group:
  pihole_alert:
    name: PiHole Alert
    entities:
      - alert.pihole_queries_high
      - input_number.pihole_dns_queries_threshold
      - sensor.pi_hole_a_dns_queries_today
      - binary_sensor.pihole_queries_high
      - automation.turn_off_pihole_queries_high_alert

The only problem with this that I’ve discovered so far is that when the done_message is sent it also contains the button to “Turn alert off” which is dumb because it doesn’t apply. Not sure if there’s a way around this.

I have the same problem, I’d like not to have the actions when the alert is done.

For example, the alert for my front door being unlocked has a “Lock Door” action, and when I get notified that it’s locked I don’t want to see the action to lock the door again on that “Locked” notification.

Did you figure out how to do this?

I also have the same problem, the done_message notification also contains the Turn off button. Did you guys figure it out? @thomasvs @SpikeyGG