hello, maybe it will be a trivial question … but I wonder why if for example I have an automation of a light that is switched from 6:00 pm to 11:00 pm and during that restart the system for maintenance automation no longer works ? or better if I restart and the lights were on at restart, they will be turned on again but they will not go off at 11.00pm! there is a way that the system at the time of restarting recheck the automations making them effective, not only the last state if on or off but also read the rule within the automation.
If you’re using a delay in your automation between on and off I think that’s why… use specific on and off triggers.
Can you provide the automation.
How did you “automate” it?
-
alias: ‘Luci Faretti’
trigger:- platform: sun
event: sunset
offset: “00:30:00”
action: - service: homeassistant.turn_on
entity_id: switch.ingresso_faretti - delay: ‘00:{{ states.input_number.auto_light_minutes_faretti.state | int }}’
- service: homeassistant.turn_off
entity_id: switch.ingresso_faretti
- platform: sun
-
alias: ‘Luci cubi’
trigger:- platform: sun
event: sunset
offset: “00:30:00”
action: - service: homeassistant.turn_on
entity_id: switch.ingresso_cubi - delay: ‘00:{{ states.input_number.auto_light_minutes_cubi.state | int }}’
- service: homeassistant.turn_off
entity_id: switch.ingresso_cubi
- platform: sun
-
alias: ‘Luci palme’
trigger:- platform: sun
event: sunset
offset: “00:30:00”
action: - service: homeassistant.turn_on
entity_id: switch.ingresso_palme - delay: ‘00:{{ states.input_number.auto_light_minutes_palme.state | int }}’
- service: homeassistant.turn_off
entity_id: switch.ingresso_palme
- platform: sun
this at the top is one of the automations, I must say that it works only as I said that if by pure chance the system restarts within the time slot of the automation does not complete it correctly …
Format your code properly please, see top of page.
if i see that right (as your automation is not properly formated), you have the on and off switch in one automation.
Thats why the switching off ist not triggered when you restart your homeassistant.
In your case, your automation has a delay. If homeassistant is restarted when the script is running (within the delay time) the whole automation is stopped.
Therefore you have to seperate your automations.
How could you do that:
You could add a binary sensor, which is on when the light is turned on and the binary sensor is off after x minutes passed after switched on.
Then you implement a second automation, which is triggered when the binary sensor is switch off. This one will switch off the entity then.
thanks for the interest I could not properly format because I’m often away from home and with the smartphone I can not well, however, sin as I said everything works very well for several months, as suggested by you I have to review everything and rewrite the automation I have to put of commitment and do it, thanks again.
You are aware that automations are now off by default when HA starts?
no, but I had noticed lately I thought they were reset because of the multiple reboots that in this period I’m doing to add news to my HA. why was this thought to raise the security level for accidental start of automations after an unexpected restart?
I don’t know why it was done, but no doubt you can look at the discussion that would have taken place on github.
See These two Posts
I’m actually not sure if that is completely correct…
The documentation is kind of vague but my understanding is that if you always want the automation to be on or off when you restart HA or reload automations then you need to put in the “initial_state:” and set it to true or false.
If you always want the state of the automation to be the same as the state that it was in before the restart/reload then you don’t want to have the “initial_state:” included.
For example if I have an automation that I sometimes want on or off depending on some other condition or if I turned it on or off manually and I restart HA I would normally not want HA switching it to the other state. I would normally want it to maintain the same state that it was in prior to restarting.
If you look at the blog post for v84 it seemed to imply that unless you have an initial_state set then all automations would be defaulted to off because the storage mechanism to save the state between restarts was being changed and that the state information would have been lost until you go thru and manually turn the ones on that you want on. From then on the state of the automations (on or off) would be retained. Unless you don’t allow HA to completely start back up before restarting it again. Then the status would again be lost until the next complete restart occurred.
Otherwise that would be a real pain in the @$$ to have to go thru all of you automations that might be variably on or off and reset them to the desired state every time you restart HA.
It’s confusing but I think I’m right…I think…