Bit of a bizarre question, but: if you have an Automation with a Delay and run it twice, do you get two instances of the automation running, or is there something preventing multiple-instances of the same automation running at the same time?
Why am I asking? See in-line comments for details, but in essence, I’m trying to over-load (in a programming sense) the function of a Wemo light-switch. Single press / click toggles the fan, Double click activates a script. I manage this assuming two instances of the Automation script running at the same time (but updating the same input_boolean). Currently not working… I see the flag toggle via mobile app, but my test light doesn’t turn_on.
My guess is that HA is overriding/stopping the First Click as soon as I initiate the Second Click, so that I’m never getting the right toggle value.
alias: Fan X2 Puppy Potty Track
initial_state: true
trigger:
# when fan is toggled
- platform: state
entity_id: switch.master_bedroom_fan
action:
# Here is the full logic flow, since this is a bit confusing...
# GOAL: Double-clicking a Wemo wall-switch for ceiling fan will
# activate a script. Single-clicking will simply toggle
# the fan, not run the script. This is a toggle, not on/off,
# i.e., I want a double-toggle to leave fan in original state.
# For testing purposes, below turns on a nearby light.
# Currently, I see the flag toggle, but the light doesn't come on.
# Perhaps HA is killing the First Click when the Second fires
# WITH ONLY 1 PRESS WITHIN DELAY TIME:
# -- Default state: boolswitchstate = OFF
# -- First Click: Initiated by switch.master_bedroom_fan
# -- First Click: Toggle#1: boolswitchstate = ON
# -- First Click: Delay starts, automation on-hold
# -- time...
# -- First Click: Delay ends, automation continues
# -- First Click: Toggle#2: boolswitchstate = OFF
# -- First Click: Condition: does boolswitchstate == ON? False
# -- First Click: Automation Aborts
# -- default state restored: boolswitchstate = OFF
# WITH 2 PRESSES WITHIN DELAY TIME:
# -- Default state: boolswitchstate = OFF
# -- First Click: Initiated by switch.master_bedroom_fan
# -- First Click: Toggle#1: boolswitchstate = ON
# -- First Click: Delay starts, automation on-hold
# -- time...
# -- Second Click: Initiated by switch.master_bedroom_fan
# -- Second Click: Toggle#1: boolswitchstate = OFF
# -- Second Click: Delay starts, automation on-hold
# -- time...
# -- First Click: Delay ends, automation continues
# -- First Click: Toggle#2: boolswitchstate = ON
# -- First Click: Condition: does boolswitchstate == ON? True
# -- First Click: Target switch turned on
# -- First Click: Turn_off boolswitchstate = OFF
# -- First Click: Automation Complete!
# -- time...
# -- Second Click: Delay ends, automation continues
# -- Second Click: Toggle#2: boolswitchstate = ON
# -- Second Click: Condition: does boolswitchstate == ON? True
# -- Second Click: Target switch turned on (again, but OK)
# -- Second Click: Turn_off boolswitchstate = OFF (again, but OK)
# -- Second Click: Automation Complete!
# -- default state restored: boolswitchstate = OFF
# Toggle#1:
- service: input_boolean.toggle
data:
entity_id: input_boolean.boolswitchstate
# this will eventually be 1s, but set to 5 for debugging
- delay: '00:00:05'
# Toggle#2:
- service: input_boolean.toggle
data:
entity_id: input_boolean.boolswitchstate
- condition: state
entity_id: input_boolean.boolswitchstate
state: 'on'
# turn on other target light:
- service: switch.turn_on
entity_id: switch.master_bedroom_light
# assign boolswitchstate to OFF, to restore default state
- service: input_boolean.turn_off
data:
entity_id: input_boolean.boolswitchstate
I’m sure I can find another way to do this… but it raised the question: does HA kill duplicate Automations?