Question
How can I prevent an automation from restarting if I want the state to be temporarily locked?
I have an automation for motion triggered Christmas lights, but I have a switch condition to prevent it from turning on if I manually turned off the lights. Thank you @CentralCommand for your explanation here Manual override of automation - #2 by CentralCommand
Goal
I’m trying to have a motion light that I can prevent from turning itself on if I turn them off via the UI or Alexa.
The Automation
alias: "Christmas: Lights on while home"
description: >-
Goal is to have it not turn lights on if i manually turn off. Haven't figured
out how to prevent restart triggered by motion during the manual off holding
window.
trigger:
- platform: state
entity_id: alarm_control_panel.ha_alarm
- platform: state
entity_id:
- group.upstairs_motion_sensors
to: "on"
- platform: state
entity_id:
- switch.mobile_plug
to: "off"
condition: []
action:
- choose:
- conditions:
- condition: or
conditions:
- condition: state
entity_id: alarm_control_panel.ha_alarm
state: armed_away
- condition: state
entity_id: alarm_control_panel.ha_alarm
state: armed_night
sequence:
- service: switch.turn_off
target:
entity_id: switch.mobile_plug
data: {}
- conditions:
- condition: template
value_template: >-
{{ trigger.to_state.context.parent_id == none and
trigger.to_state.state == 'off' }}
sequence:
- wait_for_trigger:
- platform: state
entity_id:
- switch.mobile_plug
to: "on"
timeout:
hours: 3
minutes: 0
seconds: 0
milliseconds: 0
default:
- service: switch.turn_on
data: {}
target:
area_id: switch.mobile_plug
enabled: true
- delay:
hours: 0
minutes: 30
seconds: 0
milliseconds: 0
- service: switch.turn_off
data: {}
target:
area_id: switch.mobile_plug
mode: restart
So the section has the goal of preventing the automation from restarting (for 3 hours or if I manually turn it on again) if I just manually turned it off.
- conditions:
- condition: template
value_template: >-
{{ trigger.to_state.context.parent_id == none and
trigger.to_state.state == 'off' }}
sequence:
- wait_for_trigger:
- platform: state
entity_id:
- switch.mobile_plug
to: "on"
timeout:
hours: 3
minutes: 0
seconds: 0
milliseconds: 0
The problem
Right now the automation is in restart
mode. I don’t think it should be in single
mode because that would prevent the motion timer from restarting and would prevent the manual off from happening. I don’t think it should be in queue
mode because it would not always have the latest action next.
Any thoughts?