Constantly repeating trigger during time period

Good day alltogether

My first few weeks with HA up & running were awesome. All different devices under one roof & a strong community with a lot of advice for newbies like me. I am staying in South Africa, where load shedding schedules (“planned power outage”) are frequently occuring.
My first weeks with HA were also so happy because there where no load sheddings. My current UPS is not big enough to keep the server running for 2h, so everything is off when electricity is back again. Though I will get a bigger battery soon, for now it will has to do the job.
I am trying to create a automation to get things going after a power outage:

  • a simple timer will not do it: if no electricity is available during the time of firing on/off, the devices are out of the planned schedule.
  • second thought was creating a helper day timer which is toggling a binary sensor on/off according to a schedule. The automation is repeating firing the devices as long the condition of this binary sensor is given. I just learned this morning that when the set time to toggle is during downtime, after rebooting the binary sensor stays like it was before. So the devices carry on like they were before since the condition is not correct and the helper could not fire.
  • Poweronstate in Tasmota will not work since the needed state of the device can change during load shedding/downtime.

I need something that will fire an automation at a set intervall with the right state even after rebooting. For example: after loadshedding, rebooting, recognising the scheduled/needed state and firing the automation and keeping to fire during that set time period. When I was still using ewelink I just used different timers (more than 2h hours apart to make sure at least one is being used outside of loadshedding), but the number of timers was very limited. But I am sure there is a smarter solution in HA.
I searched the forum & I am sure the answer is somewhere there neatly explained. But since I do not even know the correct words to search for, I really would appreciate some help here.

Kind regards from South Africa

Elmbob

I don’t understand what you are actually trying to do.
You write a lot but nothing really about what needs to be done and why.

Getting back to normal after a power outage is always a problem - regular long blackouts must be a nightmare.

Not sure that it’s a good idea to have automations repeating every couple of hours - could get complicated very quickly. I have one that runs every night to reset various switches, but at 4am things are much the same every day.

You can use the Home Assistant trigger to run an automation on restart. You would then need reference points outside Home Assistant to decide what state the system should be in. Time, date and outside light levels are obvious ones, but the sun entity might also be useful.

You might consider experimenting with scenes to get everything into the right state quickly.

Get what going? If you mean setting all devices to a specific state, that responsibility should reside in the automation that normally controls each device (not in a single, centralized “power-failure recovery” automation).

All of my scheduled automations are designed to handle a startup event. In other words, after power is restored (or merely a restart) the automation determines if a device should be on or off (or whatever is the correct state for that moment in time).

Here’s an example of what I mean:

1 Like

Indeed. There are halfway house options, though. I have a number of input.boolean flags which are checked by a startup automation and reset according to time of day etc. Other automations check the flags to see what state devices should be in.

Two different philosophies:

  1. Each automation is responsible for managing all of its own resources on startup.
  2. A separate “power-failure recovery” automation manages all (or some) of the resources of other automations on startup.

The reason why I prefer the first one is because the mechanism for managing an automation’s startup behavior is built into the automation itself. I don’t need to look elsewhere to understand what happens on startup (or to ensure the “power-failure recovery” automation is enhanced to handle new automations I create).

Nevertheless, I appreciate the fact that one can choose to employ a hybrid of the two philosophies.

I did not know about the restart trigger, thank you for that idea. However, it can be that the server up while our farm is running on generator but the greenhouse on the other plot is not. So the devices are not receiving the states they should be in. I should have mentioned this minor detail before…
I set up an automation with a timed trigger: every 15min the group switch is triggered under the condition of a time frame. 4:30 till 19:30 the sulphur burners are switched off every 15min, 19:30 till 4:30 switched on every 15min.
I have the feeling that missed events will keep me busy…

In that case, if the devices in the unpowered greenhouse are configured correctly, their state should appear as unavailable. An automation can be triggered when a device’s state changes to or from unavailable.

In other words, actions can be performed when specific events occur (related to startup and device presence/absence) as opposed to employing an inefficient Time Pattern Trigger.

1 Like

Thank you Taras, I will tinker around with your suggestions. The time trigger works, but is inefficient.