I am going crazy as I can’t figure out what I am doing wrong. I would like to set-up an actionable notifcation where you can choose between yes and a script gets called and no and nothing happens.
I simply can’t get the script being called when clicked on yes.
alias: Neue Automatisierung
description: ""
trigger:
- platform: state
entity_id:
- person.XXX
to: home
condition:
- condition: time
weekday:
- fri
action:
- service: notify.mobile_app_xxx_iphone
data:
message: Message
title: Title
data:
actions:
- action: script.test
title: Ja
mode: single
I feel it is something stupid, as the docs do not help me too.
The configuration key action shown above is just a name/identifier that you are setting up to send from your phone back to Home Assistant.
It is not the same as a service call or other action in script syntax.
As shown in the Actionable Notification docs you need to set a Wait for Trigger action to listen for the response event from when you press the button.
The basic version would be:
alias: Neue Automatisierung
description: ""
trigger:
- platform: state
entity_id:
- person.XXX
to: home
condition:
- condition: time
weekday:
- fri
action:
- service: notify.mobile_app_xxx_iphone
data:
message: Message
title: Title
data:
actions:
- action: Yes_Run_Test_Script
title: Ja
- alias: "Wait for a response"
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: Yes_Run_Test_Script
- alias: "Perform the action"
service: script.test
data: {}
mode: single
thanks for the reply, that does indeed the trick. So basically the “- action:” is something I can freely choose which, when being passed back to HA tells HA to proceed with the action that I would like to happen, when this button is pushed.
Keep in mind that action identifiers should be as unique as possible so the Wait for Trigger has something specific to listen for. That is why the example in the docs and @samuelthng’s blueprint above include context.id with each action. It makes the action identifier specific not only to which button was pressed, but also specific to that run of the automation. It is both more accurate and easier in the long run than manually created actions.