Hi, I'm currently trying (and failing) to create an automation to help me with starting up my mobile airconditioner when my power usage goes below -1200 Watt. The reasoning is, I get almost nothing for putting power back on the net, might as well just use it to cool the bedroom.
Since I don't want to wear out the airconditioner, I try to build some safeguards against constant switching on and off again. I had the idea to check if the power usage over time. If it consistently stays under -1200 watt, it should start the airconditioner, else, the automation ends without changes.
This proves to be difficult. I know I can set a time range in the for block in the trigger. However, when the automation execution gets abandoned because of a condition further down the line, the automation doesn't get triggered again, since it only fires on exactly 10 minutes, not on 15 minutes for example.
Next I thought to put it in a condition, but noticed that there is no support for a for block in conditions. A session with Gemini trying to get something going with helpers and whatnot also resulted in nothing.
Has anyone made an automation that evaluates a state for a longer time before firing? If so, how do you do it, cause this has me stumped.
One way to handle this type of situation is to create a Template binary sensor to track if the usage is below the desired value. That allows you to use a State condition targeted at the binary sensor, which does support for, unlike a Numeric State condition.
In regards to the automation more broadly, what I usually do is to have all the Conditions and Triggers mirrored. So, whatever other conditions you currently have would also have corresponding triggers. That way any of them can initiate the automation, but they all have to be met for the actions to be executed.
Another approach that some users prefer is to combine all the logic of the triggers and conditions using a template binary sensor, then trigger their automation off that.
That seems to work! Thank you for the tips on mirroring triggers and conditions. I'll keep that in mind.
I try to avoid creating helpers where I can, because I noticed that it becomes a cluttered mess on my environment quickly, but I will remember to keep it in mind for scenario's where I can't get around it without.