Hey, I’m setting up my first automations to turn my HVAC fan on for 4 hours if CO2 is above 1000 for a bit. Since 4 hours is a while, to avoid my fans stuck to “on” I assume I need to do this statefully, is below a pretty “standard” solution to this or is there any more idiomatic suggestions? Basically I set a helper timer that’s set to restore state on restarts and then have a separate automation that sets it back to auto when the timer finishes? Should I be restarting the timer instead?
#First automations
1 messages · Page 1 of 1 (latest)
I don’t think storing state on the above 1000 for 30 min is as crucial
lol it does not like me changing the name of the timer
Re: restarting the timer I guess my question depends on how often this triggers. Every 30 minutes while above 1000 or only once?
Or every tick while above 1000 and 30 minute has passed?
Trying to find the docs that clarify that for the ‘for’ trigger
Looks like I found the answer in the forum, only once so long as it stays above 1000
I guess it really doesn’t like editing timers at all, just need to make new ones
Keep this note in mind:
However, automations using the timer.finished event will not trigger on startup if the timer expires when Home Assistant is not running.
Docs on for: are here: https://www.home-assistant.io/docs/automation/trigger/#holding-a-state-or-attribute
I can edit everything about a timer:
Hmmm, what’s the idiomatic workaround?
Do you create a third automation that checks for idle on startup?
Hmmmm, maybe it’s because it’s used in an automation? I’ll try to recreate it
I guess that works here (a simple third automation checking idle) but the more robust solution in general would be to track a stateful Boolean at the same time as the timer and check that?
A separate automation or just another trigger for the homeassistant.started event to check for idle, yes
You can do that, too.
or just check the C02 at HA start and either turn the HVAC fans on or off, regardless of what was going on when you restarted HA
in fact, you could just use a numeric_state trigger to turn the fans off when it goes below your threshold, or a certain amount below that threshold
stateless is generally a good strategy - focus on your actual goal
amount of time isn't the goal - CO2 level is
Mmmm I see, yeah, just check below 1000 for 4 hours to trigger setting auto
And I guess that would survive restarts too. The 4 hour timer resets but that’s not a big deal at all
A "for" block will not survive a restart. It may never trigger because there may not be a stage change to start the for:
Oh