Hi, I can’t figure out the right automation logic.
I have two automations for AC pausing:
- the first pauses the AC when window (with a window sensor) opens for longer than X minutes
- the second starts the AC when the window closes (for more than X minutes) .
Trouble is, this obviously starts the AC regardless if it was on or off before the window closes.
How do I set this up ONLY when AC was previously ON? And keep the previous mode (cool/auto/dry/fan). I guess there should be a time window of a couple of hours so it doesn’t restart after, say, a cold night with AC off.
Thanks for any help.
EDIT: solution is to store the current AC state into a new scene in the first automation, and then recalling that with the second. I didn’t know this was a thing. Problem solved, thanks!
Why not concentrate on whether the ac should be on rather then whether it was peviously on.
I’m sorry how is this helpful?
I don’t get the logic.
You want to put the AC ON only if it was already ON without changing the mode? I understand that as “do nothing”
@koying I think the idea is that the ac was turned off when the window opened. Wjen the window is closed the ac should only turn on if it was on before the window was opened.
I worded the OP really badly. Edited now. Thanks.
My point earlier was that maybe when the window closes, turn on the ac depending on the current conditions, ie temperature, humidity and perhaps time of day.
Right, that could be the next step but I’d probably start with the basic logic. Thanks!
In the “Open Window” automation, you could save the state of the AC to an
That would give you both the “old” state and the timestamp (
Than, in your “Close Window” one, take the proper decision based on these information.
There is probably a better way, but my take would be.
In the automation that turns off the ac on window open: save current state of ac via a scene and time in a time helper.
On window close: if now - the time helper is less then X hours set the ac to that scene.
I will look into that, I didn’t know you can save a current state of something to a scene. Thanks!
Working perfectly! Scene snapshot was the missing ingredient for me. Thank you guys!
Really depends if it is a simple on/off, in which case @koying 's suggestion is great, or if it is a climate entity a scene should work better as there is more to a climate than just on/off.
@koying 's point about last_updated makes saving the time redundant.
yep it’s a climate entity (A Daikin minisplit running via the official Daikin integration). It does save/recall the mode correctly. It doesn’t recall the Boost mode but AFAIK that’s a temporary toggle anyway. The automation works as I intended.
Looks like the automation doesn’t always store the current state of the AC. For example, I have the AC on “Dry”, then open the windows, it pauses correctly but upon closing the window again, the AC restarts in “Cool” mode or otherwise.
Is there a way to check the state of the scene.hvac_pause that gets created (the scene I use to store the current state of the AC in)? I looked in “States” but that only shows “Scening”.