Sometimes you may want to stop a running automation for instance if the automation is setting an alarm system or if an automation has a wait for action there doesn’t seem to be a way for another automation to cancel that running automation. Modes get you there but only if you use restart but you may want to stop it entirely.
Wait but this turns off the automation. I just want to stop the actions. I would need to do an automation.turn_off with the stop_actions attribute then turn the automation back on right?
Correct; there’s no service call to just abort an in-progress automation.
BTW, what is the application you have that requires one automation to abort the execution of another automation?
The current use case is that I have an automation that waits for a service to trigger to make sure my alarm is set. IF it doesn’t get set for whatever reason it sends me a critical notification telling me the alarm didn’t set, but this can be an issue if I went in and disarmed the alarm system myself so I want the disarm automation to stop the wait for action on the other automation that is currently waiting for the alarm to set so that I don’t get this true false notification that my alarm wasn’t set.
The automation should be redesigned to stop waiting when you disarm the alarm system.
Both wait_for_trigger
and wait_template
can indicate if their condition/trigger was fulfilled or if they timed out (the automation can use this information to determine what should be done next).
This is how I have it. Unsure how you suggest to change this. Only way to cancel would be that I make the wait for trigger to check for all state changes of the alarm panel then send me a notification of alarm not setting IFF the state is disarmed but that is only checking if the current state is disarmed not checking if the event received was to disarm which is what I’m after. This is why I use the wait.trigger condition as it gives me a leak at which trigger was used specifically. Not being dense just giving you more context.
action:
- choose:
- conditions:
- condition: trigger
id: "Apple Device"
sequence:
- service: alarm_control_panel.alarm_arm_away
target:
entity_id: alarm_control_panel.alarm
- service: notify.everyone
data:
message: "Home Assistant Alarm is being armed in Away Mode by {{ trigger.event.data.sourceDeviceName }}'s {{ trigger.event.data.triggerSource }}"
- conditions:
- condition: trigger
id: "Home unoccupied"
sequence:
- service: alarm_control_panel.alarm_arm_away
target:
entity_id: alarm_control_panel.alarm
- service: notify.everyone
data:
message: "Home Assistant Alarm is being armed in Away Mode by the house being empty"
- conditions:
- condition: trigger
id: "Homekit"
sequence:
- service: notify.everyone
data:
message: "Home Assistant Alarm is being armed in Away Mode Homekit"
- wait_for_trigger:
- platform: state
entity_id: alarm_control_panel.alarm
to: "armed_away"
timeout: 70
- choose:
- conditions: "{{ wait.trigger is none }}"
sequence:
- service: notify.everyone
data:
message: "⚠️ Home Assistant Alarm did not set"
data:
push:
sound:
name: "default"
critical: 1
volume: 1.0
default:
- service: notify.everyone
data:
message: "Home Assistant Alarm is Away and Armed"
EDIT
Updated with full actions
I understand, like having a automation with motion sensor and lights, then on a certain time of the day you just want to let the lights on? Over a switch or similar?
- wait_for_trigger:
- platform: state
entity_id: alarm_control_panel.alarm
to:
- "armed_away"
- "disarmed"
Enhance the conditions in choose
to check if the state-change was to armed_away
, disarmed
, or the wait_for_trigger
timed out. Let me know if you need my help to do that.