Actionable notifications and wait_for_trigger

I read this nice idea about Yes/No notifications with wait for trigger:


Unfortunately there was no example code and I’m trying to figure out how to achieve this “Yes/No” notification and action in a single automation?

Lets say I leave home and forget to lock my door.
I want to trigger on to: “not home”
Get a notification: "You forgot to lock the door (again), should I lock it for you? “Yes” or “No”
Where pressing “Yes” continues the automation with an action and “No” just aborts or runs a different action.

Anyone have something ready to share? Would be much appreciated.

Thanks and best regards

The example code is there you just have to set the trigger to the event you set up and then delegate the actions properly. Follow the linked example and use it alongside the companion docs: https://companion.home-assistant.io/docs/notifications/actionable-notifications

Thanks but I don´t fully understand how to handle yes/no.
example:

automation:
  - trigger:
      - platform: SOME TRIGGER
    action:
      service: notify.mobile_app_<your_device_id_here>
      data:
        message: "You forgot to lock your door again! Should I lock it?"
        data:
          actions:
            - action: "YES"
              title: "YES"
            - action: "NO"
              title: "NO"
      - wait_for_trigger:
          - platform: event
            event_type: mobile_app_notification_action
            event_data:
              action: YES
        continue_on_timeout: false
      - service: notify.notify
        data:
          message: You pressed "YES"

So above handles one of the actions (YES), but how to handle both in one automation?

You will need to use templating to achieve that

Ok, then it´s above my skill level for now, thanks anyway.