Hi guys, Iam reading the tutorials over and over again. Am I missing something?
I have an automation checking in the evening if I closed my Garage. If its unlocked I receive an Notification in HA app. I wanted to add an action within the notification that offers me to directly close the Garage. How can I trigger directly a Script within the Action? The documentation mentions this concept but as always doesnt provide proper example
Defining the Action as Script.xyz doesnt work.
Any ideas?
action:
- service: notify.mobile_app_pixel_6
data:
title: Die Garage ist noch offen!
message: ""
data:
color: "#ff0000"
notification_icon: mdi:garage-alert-variant
visibility: public
actions:
- action: test
title: Garage schließen
This is mentioned but I dont find any example. The mentioning alarm events and making plenty of examples around that topic. I just want to see how I can execute any script or even just go for an entity that is switched on
Ok, seems like iam dumb or the documentation could be optimized
The “action” in my script called “test” is the actual event that is send to Home Assistant.
You need then to create a new automation that gets triggered by the event “test”.
You do the automation like mentioned in my start post.
The line “-action: test” is basically an event name.
So when I want to close the garage door I hit the word “Garage schließen” in my notification bar.
What then happens is that the word “test” is fired as an event.
I then created a new automation that “listens” to that trigger word and as action basically closes the garage.
This automation looks like this:
alias: Garage - Push Notification mit Action
description: ""
trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: test
And as soon as the event “test” comes in, the automation is fired to do anything.
Hi, I’ve been banging my head on how to get the notification to trigger an automation. Below is my notification yaml, which I believe is wrong at the end because I need to call an automation. I don’t know what code does that.
Notification YAML:
alias: Door lock status notif
description: ""
trigger:
- platform: state
entity_id:
- input_boolean.lock_switch_2
from: "off"
for:
hours: 0
minutes: 5
seconds: 0
condition: []
action:
- service: notify.mobile_app_first_iphone
data:
message: Check the door if it should be locked
title: Door lock is open
data:
actions:
- action: lock
title: Lock?
service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.lock_switch_2
mode: single
I created the automation but don’t know what code to use for the trigger here:
Set up an actionable notification. The action can be of any name like STOP_THE_SIREN.
When you press the button on the notification of the app, a trigger mobile_app_notification_action with eventdataSTOP_THE_SIREN is fired.
You use the trigger in #2 to trigger ANOTHER automation.
In this automation, do everything you want.
Here’s my result:
Automation 1: Send the notification until turned off
alias: Repeat Notification when Siren Switch Turned On
description: ""
trigger:
- platform: state
entity_id:
- input_boolean.siren_switch
from: null
to: "on"
condition: []
action:
- repeat:
sequence:
- service: notify.notify
data:
message: Button pressed
title: Warning
data:
sound:
name: default
actions:
- action: TURN_OFF_SIREN
title: Turn off
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
until:
- condition: state
entity_id: input_boolean.siren_switch
state: "off"
mode: single
Automation 2: Listen to the app action and then turn off the siren switch
alias: Turn off siren switch using mobile app
description: ""
trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: TURN_OFF_SIREN
condition: []
action:
- service: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.siren_switch
mode: single
I think the official document is written in a way that not everyone can understand. Thanks for the YouTube video https://www.youtube.com/watch?v=QZsY5a7R10c . Hope this helps.