I am new to using Home Assistant . without meaning to I am a gifted bug hunter. No matter what I touch, I immediately find little bugs haha.
Let’s see if I was successful this time, or if I’m just stupid
I have been able to reproduce the problem to be solved with the Home Assistant OS as well as supervisor.
Both installations are not on the LAN.
To rule out it being a network issue, I have supervisor in the datacenter (Private IP with a NAT on the public server).
I have the Sonoff addon as well as Tuya integrated.
Sonoff I have many switches in different locations.
Tuya I have sensors (Co2 measurement)
All are working fine.
I have two scenes in the automation. Turn on a Sonoff switch and a scene that turns it off again. Both work.
When the Co2 value drops below the value of 800ppm and it is between 11:55am and 10:00pm, every day (Monday to Sunday), activate scene switch on.
Second automation: if the value rises above 1500ppm activate scene switch off (here no time limit / condition).
This works perfectly all day.
At this point a big compliment to the creators.
Now to the bug:
If the day for the automation is over (10:00 pm) it stops as desired. The next day when the period starts the Co2 value is far below the 800ppm. However, it is NOT start automatically. I have to turn it on manually. From that moment everything runs as desired until the next day.
One caveat is that you haven’t provided the actual code of the automation as pointed out above so I’m going to make some assumptions. With that caveat in place…
It’s the way automations work.
triggers are evaluated at an instant in time (in your case when the CO2 drops below 800ppm).
at that moment the automation checks the conditions (in your case the time is between 1155 and 2200).
If the conditions are met then the actions will run, if not then they won’t.
The automation then stops. Done. The automation won’t wait around until the conditions are met.
It then waits for the next trigger to occur (CO2 below 800ppm) but since the CO2 is already below 800ppm at 1155 then the trigger has already come and gone so the automation has no reason to check the conditions again. So the automation doesn’t run again until the CO2 goes from below 800ppm to above 800ppm then below 800 ppm again (triggers need to go from false to true to actually trigger the condition check).
what was alluded to above is that to get the automation to run at 1155 if the CO2 is already below 800ppm at that time is to add the time (1155) as another trigger. And then to add another condition to check that the CO2 is below 800ppm. that way both situations are accounted for.
Unfortunately it won’t work because of the exact reasons I pointed out above.
setting the mode to restart has no effect on the triggers or conditions at all. it only causes the automations actions to start back at the beginning if a trigger occurs while the actions are running.
And that is only really useful if the actions take a modestly long time to run such as when using some type of delay in the actions that is either explicit (delay: “00:01:00”) or implicit caused by an action that needs to complete before the next action runs (ex by calling a scrip in an action that needs to complete before it allows the actions to continue in the calling automation).
you just need to change the triggers and conditions as suggested by me and tom.