What is the right way to implement Heat/Cool settings for thermostats during the year

I’m a HA newbie, so I’m struggling a little to understand the correct way to go about implementing my thermostats and door sensors.

I have 11 Honeywell thermostats, all connected via the Honeywell cloud. Each of these thermostats are in an individual room, with 2 doors. I’ve ordered some Aqara door sensors to try, and the Sonoff 3.0 USB zigbee adapter.

My goal is to have HA toggle the thermostat on and off based on the door sensor. IE: If the door has been in the open state for 300 seconds, turn the corresponding thermostat off. When the door has been closed for 300 second, return the thermostat to its previous state.

I poked around a little, and it doesn’t seem like I have an option of “previous state”. So the question is how to I turn the thermostat on to its previous state.

I thought perhaps I could toggle a scene throughout the year. IE: Winter vs Summer. Based on that scene, the thermostat would toggle back to heat or AC, however I can’t seem to save a scene when adding any of my thermostat devices. I suspect HA is not letting me save any scenes because I am improperly uses it.

Anyone care to give me pointers on the right way to go about toggling the thermostat back to its previous state?

You should look into scenes. I haven’t personally used scenes with thermostats, but in theory it should work. Search the forum to see if others have used it for this purpose.

Ok so I was on the right track with using Scenes. But for whatever reason I cannot get the Scene to save. The logs also show no clues.

I’ll search around and see if I can find anything.

Thanks for confirming my initial hunch.

So I’ve figured out the issue with the Scenes not saving.

I’ve modified the configuration.yaml file to enable automations and scenes.

I’ve programmed the scenes and created automation change all the thermostats to heat/cool/off based on which scene is selected. We have 13 thermostats, so I added some delays between each thermostat preset change so that Honeywell wouldn’t ignore anything of the changes.

I have a new question though.

Currently, automation script is set for “When HVAC_Heat changes state or any attribues”, to set all thermostats to the preset Heat; where HVAC_Heat is a scene. Admittedly, I’m not entirely sure what state change is occurring when I click the HVAC_Heat “Activate” button under the Scenes widget on my dashboard.

Some quick searching shows that scenes don’t retain a state value, instead they run like scripts. Need To Confirm Scene As Automation Condition

Would it be possible to assign a value to a variable every time a scene is activated, so that the door automation script can check which scene was last activated?

For the following scenes assign a global variable the following value every time the scene is activated.
HVAC_Heat = 1
HVAC_Cool = 2
HVAC_Off = 0
Then during the automation script, check the variable to determine what preset to return a thermostat to.

What does your scene look like (config, correctly formatted)?

Scenes don’t have states, yes. You either need to check the specific entities’ states or save it, hence the below:

There are a number of helpers available in HA. It sounds like an input select, input number or even an input text could do the trick.

Thanks for taking the time to reply.

I’ve made some progress, thanks to your helpful hint about helpers. It took me awhile to figure out how to create a helper, but I’ve done the following.

I eliminated scenes completely. Instead, I have 3 automation scripts, Thermostat Off, Thermostat Cool, and Thermostat Heat. At the end of each automation run, a helper value called HVAC_Preset is set to 0,1 or 2.
0 = off
1 = heat
2 = cool

** It should be noted that all the thermostats will always be in the same HVAC preset. I have the scripts setup as a dashboard card and trigger the preset change from there.

This way, I can simply look back at HVAC_Preset and see what mode the thermostat was previously in.

Now onto handling the door opening situation. Each thermostat controls an HVAC unit dedicated to a single room. Each room has two doors. With the newly discovered functionality of helpers, I created an script for each room. When a door device switches from a closed state to an open state, a helper input number for that room is incremented by 1. The input number has a minimum value of 0 and a max of 2. Now I can track if there are any open doors for each room.

The next challenge. I need to have some type of delay on the door. I imagine the thermostat nor Honeywell will appreciate getting sent off/on commands hundreds of times a day. I’d like to implement some type of delay timer. I created another helper, a timer, and set the duration to 5 mins or 300 seconds.

As I am still learning Home Assistant, I think timers only work in a countdown manner. I gather what should happen is that I have one automation script that when the door sensor is trigger open, it begins the countdown timer for that room. Then another automation script that when the countdown timer reaches below value 1, set the corresponding HVAC preset to Off.

** It’s worth noting that I’m trying to only turn off the HVAC if the any of the doors are left open longer than X amount of time.

I have a few questions about the timer:

  1. There are two doors, but I imagine there is no reason to reset the timer if a second door opens after the first one. That makes the logic pretty straight forward. But I assume that if a timer counts down from 300 seconds, my condition to set the HVAC to off should be when the timer is BELOW 1 second correct?

  2. I assume timers need to be reset. So assuming I have the HVAC_OFF and both doors have just closed. I should have another automatic script that checks my door count helper, making sure it sees a value of 0, then it should reset my door timer, and then finally checks my HVAC_Preset helper to return the thermostat to its original preset.

Am I think about timers correctly?

I’ll probably need to add a timer in for the door close, as well.

Finally, I’m getting a lot of automation scripts for each room. Which I guess is fine, but is this a best practice? Or should I be trying to merge things together?

A quick update here.

I think I got most of it working.

I have timers set at 10 seconds, so I can quickly test things. My automation is set to look for a state change on a helper time for 10 seconds. I’m not entirely sure if this is the correct way to do this, but it is working.

I only have two things left to do, which is to finally hook in the door sensors. Thus far I’ve manually executed the automations and watched everything via dashboard cards.

Secondly, and the most important issue is making sure I don’t send to many commands to each thermostat simultaneously. Honeywell doesn’t seem to like this, and occasionally it will just kick the session for the integration resulting in none of my commands registering. This is what I get for using a cloud based thermostat vs something on zwave or zigbee.

In any case, my door open automation timer automatically gets cancelled if the door closes and the door count reaches 0. Therefore as long a the door open timer doesn’t reach 10 seconds before all the doors are closed, the thermostat preset ‘off’ command is not sent to Honeywell. Great.

However, this leads to a redundant ‘on’ command being sent when the door closed timer reaches 0. IE: If the thermostat is already on heat, and someone opens then closes a door within the door open timer window, the thermostat is never turned off because the door count reaches zero and the door open timer is cancelled. However, a door closed timer proceeds to countdown, and when it reaches zero checks the HVAC_Preset value to determine if the thermostat needs to be returned to cool or heat. Being that the thermostat was never turned off, it just tells the thermostat to enter heat, even though it is already on heat.

I don’t think this would break anything, but can anyone think of a clever way around this issue?

This is quite simple to do: just set a for requirement on the state trigger for the HVAC entity.

Or, as you’ve mentioned: timers. Timers are restored after a restart, which make them better than the above, especially for longer delays. You just trigger on the timer finished event.

See above.

Use a state trigger and check for 0. Then call timer cancel service to stop it.

Two options: using naming conventions you can make heavy use of templating to infer related entities, e.g. climate.hvac_1 relates to timer.hvac_1. This is my personal approach where I want a single automation. Another option to avoid duplication is to use blueprints. Generally speaking, I prefer smaller, separate automations for the sake of maintainability (but I do have some nasty big ones too).

If I follow, I think you can put a condition in the automation’s action section to test whether the entity you’re about to call a service for is in the expected state. If the check fails, the execution stops.

I have something similar with a gate: open the gate when I get home, but since the automation might take a little bit too long to fire due to a delay in the presence check, I might have pressed the remote’s button. In that case, I need to guard against that, so when the automation is about to open the gate, it just does a quick check to see that the gate is still closed.

Thanks for all the help Paul.

This is pretty up much and running. I just check it for problems every now and again.