Is there a way to specify the initial state of an automation? I want it to be off when home-assistant starts.
Also, I noted that if I turn off an automation and reboot home-assistant, it turns back on – the state of automation is not persistent.
I think that kinda goes against the concept of automations though, doesn’t it? An automation that doesn’t load automatically is a… script.
I’m curious what your use case is though.
Except that a script is supposed to do its thing and terminate immediately, while an automation can keep reacting to events.
Besides, having an “initial state” option will only make the automation component more general.
Use case:
I have a mobile temperature sensor. I want an automation that gets fired whenever a fresh reading from the mobile temperature is received, and sets this value as the “remote temperature” in my thermostat, so that my thermostat makes decisions based on the mobile temperature sensor and not the sensor it has inside. But I want this automation to fire only during some times, e.g. while sleeping – and I want this decision to be manual.
I can use the “input_boolean” component and add this as an additional condition in the automation.
But I noticed that the frontend already has a switch to turn automations on/off.
I can certainly see the reasoning behind wanting this. If something causes the server to reboot, it’s reasonable to expect it to resume operation the way it was before the interruption.
Use case where I see for this: If due to unseasonal temperatures, or I’m cleaning the filter I don’t want my pool filter to run on its normal schedule today, I’d turn off those automations. If my HA server reboots mid filter clean and fires up the pump, I might not be so happy. Cleaning is not the best example, as I should lock out the pump from automatic control during maintenance with an HOA switch, but even if I just wanted it to not follow the automation and be controlled manually for a day or two, it would be nice not to notice that the server had rebooted, and go back to change status of automations.
I was a little surprised as well that a reboot clears the off state of an automation.
I can see one more reason for automation to be persist-able.
When I am on vacation, I want an automation that automates some light behavior.
That automation will be off most the time.
Very much like IFTTT recipes. You can switch these off as needed. I will in fact work around with an IFTTT recipe…
I want this too. I have an automation that automate another automation. I wish to set the initial state of the automation whenever I reboot the HA.