I am confused by the initial_state that can be set for automations. I noticed some behaviour changes after upgrading to 0.42 (issues #6911 and possibly #6936 were related to this) and have been trying to figure out what “on” and “off” mean with regard to automations.
Does ON mean, the automation can be triggered if the right conditions are met, and OFF means it will never be triggered even if the specified conditions are met?
Or does it turn ON when it is triggered and turn off again when it is ready executing?
I am asking because I cannot figure out how to set the initial state for several automations. I have multiple involving switching/dimming the same light. and it seems one keeps overrulling the other or something, but I can’t find the pattern of what is doing what when setting different initial_states.
Yes, this. An automation in the “off” state is inactive no matter the conditions. They are all on by default. If you have initial_state: 'off' in the automation you need to turn it on before it will work.
You can also control this state with the services automation.turn_on/turn_off/toggle or by simply adding the automation to a group and controlling it like any other switch.
Ah thanks for the replies! @chrio 's explanation made me realize that I can use those states for activating different automations. not sure how to use that, but thanks for explaining!
Is there a way to setup initial_status to be the last state? So if the automation was turned off it will remain off after a restart and if it was on remain on? Thank you!
UPDATE: confirmed it is working properly and remember last state if no initial_state in the config and recorder is configured.
Totally my bad!!! I am sorry, I commented out the initial_state from a different automation. Ashamed… Thank you Guys and confirmed it is working properly and remember last state if no initial_state in the config and recorder is configured.