Notifications for family

Hi everyone,

I tried to have everyone in my family a notification for the cat litter when it needs to be change.

I succes it (pretty simple). Now I would like to cancel the notification on ALL device when someone touch the “c’est fait” (“it’s done” in french).

I saw that everyone with this question seems to find the answer here: Introduction | Home Assistant Companion Docs

But I must miss something because I don’t really understand how to clear notification on all device (it’s working just on the device used).

This is my code:

action: notify.mobile_app_tatoune
metadata: {}
data:
  message: Vider la litière.
  title: Chats
  data:
    persistent: true
    tag: litiere
    actions:
      - action: clear_notification
        title: C'est fait.
        data:
          tag: litiere
  

I have this automation for each member of my family. Maybe not the smartest way.

Thanks a lot for your help.
And sorry for my english, have a nice day.

There is a pretty comprehensive example of how to do Actionable Notifications in the Companion App’s documentation.

https://companion.home-assistant.io/docs/notifications/actionable-notifications#building-notification-action-scripts

You would need to use the Clear action as the action after the Wait for Trigger.

You could set up a Notifier Group for the whole family.

Thanks a lot.

I did this, thanks !

Thanks a lot. I start to understand how it’s working (or should work :smiley: )

That’s my new code:

- alias: test
  variables:
    action_ok: clear_notification
    action_nonok: ""
- alias: Lumière allumée
  description: ""
  triggers:
    - type: turned_on
      ....
  actions:
    - action: notify.telephones_famille
      metadata: {}
      data:
        message: Salon allumé
        data:
          persistent: true
          tag: lumiere
          notification_icon: mdi:lightbulb
          actions:
            - action: {{ action_ok }}
              title: C'est fait
            - action: {{ action_nonok }}
              title: RAS
- alias: wait for response
  wait_for_trigger:
    - platform: event
      event_type: mobile_app_notification_action
      event_data:
        action: {{ action_ok }}
- alias: perform the action
  choose:
      - conditions: {{ wait.trigger.event.data.action == action_ok }}
        sequence:
          action: clear_notification
          tag: lumiere
      - conditions: {{ wait.trigger.event.data.action == action_nonok }}
        sequence:
          action: nothing
mode: single
    

But I got an error message at the end. I can’t find the problem.

Issues:

  1. You seem to have made a mash-up of configuration syntax from an action sequence (like the example) and that used in automations.yaml.
  2. The “wait for response” and “perform the action” actions need to be indented properly.
  3. There’s no need to use a Choose if only one of the notification actions does anything.
  4. Neither “clear_notification” nor “nothing” are valid actions.
  5. All templates must be surrounded by quote marks or preceded by a YAML multi-line quote symbol.
#The following is set up following the format used in automations.yaml

- alias: Lumière allumée
  description: ""
  triggers:
    - type: turned_on
      .... #THIS IS INCOMPLETE
  actions:
    - alias: test
      variables:
        action_ok: "clear_notification_{{context.id}}"
    - alias: send actionable notification
      action: notify.telephones_famille
      metadata: {}
      data:
        message: Salon allumé
        data:
          persistent: true
          tag: lumiere
          notification_icon: mdi:lightbulb
          actions:
            - action: "{{ action_ok }}"
              title: C'est fait
            - action: "nonok"
              title: RAS
    - alias: wait for ok response
      wait_for_trigger:
        - platform: event
          event_type: mobile_app_notification_action
          event_data:
            action: "{{ action_ok }}"
    - alias: clear the notification
      action: notify.telephones_famille
        data:
          message: "clear_notification"
          data:
            tag: lumiere
  mode: single

Thanks a lot,

I understood some of my errors and I will work on the others after a good night of sleep.

I try your code but I got:

“bad intendantion of a mapping entry (line:34 …)”

Most likely that the mode: single at the bottom… looks like I missed that one when I did the others. Make sure you fix the incomplete trigger too.

Yes I deleted this part on purpose because I didn’t know if it was some private information :smiley:

I just want this automation to work once, why is it a problem ?

It wasn’t indented properly, I have now fixed it in my post above.

Thanks,

- alias: Lumière allumée
  description: ""
  triggers:
    - type: turned_on
      device_id: 27cfbbf2ed18f828410d37d400773c03
      entity_id: 5cd494c23fbd9ee57dee099f8e202ed1
      domain: light
      trigger: device
  conditions: []
  actions:
    - alias: test
      variables:
        action_ok: "clear_notification_{{context.id}}"
    - alias: send actionable notification
      action: notify.telephones_famille
      metadata: {}
      data:
        message: Salon allumé
        data:
          persistent: true
          tag: lumiere
          notification_icon: mdi:lightbulb
          actions:
            - action: "{{ action_ok }}"
              title: C'est fait
            - action: "nonok"
              title: RAS
    - alias: wait for ok response
      wait_for_trigger:
        - platform: event
          event_type: mobile_app_notification_action
          event_data:
            action: "{{ action_ok }}"
    - alias: clear the notification
      action: notify.telephones_famille
        data:
          message: "clear_notification"
          data:
            tag: lumiere
  mode: single

I got this with the right trigger (I guess) but I got the same error.

Seem to be the penultimate data which is an error.