There are many topics concerning thermostate controls here, which are at least overpowering, what I need. So, sorry, if the solution is hidden somewhere in any of these topics, I did not get it. Because it is far beyond of my skills.
What I have:
One thermostat (FritzDect) and one window sensor (IKEA) in the toilet room.
What works now in HA:
Automation 1: When the window is opened, the thermostat is closed.
Automation 2: When the window is closed, the thermostat is set to „Eco“ state.
Concerning the states of the thermostate, provided by the Fritz DECT basis:
Eco: temperature set, currently 16 °C, currently used 24h.
Comfort: temperature set, currently 21 °C, currently not used.
Summer: Date spanning summer time, currently 15. June to 15. September, temperature is scheduled to „off“ then.
Holidays: Date spanning holidays, currently not used.
What I need:
As it is getting colder outside, I want to schedule time spans for „Comfort“ and „Eco“ heating with HA. These should not conflict with window open triggers.
I could set separate automations for changing to „Comfort“ at 06:00 and back to „Eco“ at 07:00. But, if the window is opened within this time, the temperature would set to „off“. As soon as the second automation sets the temperature to „Eco“, it would start to heat, although the window is still open.
I would like to keep this automation simple. That is: I do not need (and definitely not understand) an all purpuse solution for a complete home automation for all climate devices. It is just one small room, with one thermostate and one window open sensor.
As a starter this is my automation for switching off:
alias: WC_Temperatur-Aus
description: WC-Heizung aus, aber nicht im Sommer
triggers:
- trigger: state
entity_id:
- binary_sensor.wc_fenstersensor
to: "on"
for:
hours: 0
minutes: 1
seconds: 0
conditions:
- condition: not
conditions:
- condition: state
entity_id: climate.fritz_smart_thermo_wc
attribute: preset_mode
state: summer
- type: is_temperature
condition: device
device_id: b96d87f4f132be554ba187cf1e2ba7d6
entity_id: 3b3f30243cd53d791191c6612ce3dc12
domain: sensor
below: 16
actions:
- device_id: 13d54ad72f75179a8678aca7a5d03b3f
domain: climate
entity_id: 17295126fc3b5c71681221eb0b09422d
type: set_hvac_mode
hvac_mode: "off"
mode: single
It would be helpful if you posted your automation for turning the thermostat on, rather than off, since that’s where you need to pick the thermostat mode.
Are you just looking to set portions of the day based on the time of day to control whether you’re going into Comfort or Eco when the window closes? What time spans for each?
Ok, that is right, silly me!
Here is the automation, when the window is closed:
alias: WC_Temperatur-Ein
description: Wenn das Fenster zu ist, WC-Thermostat einschalten
triggers:
- entity_id:
- binary_sensor.sensor_2_contact
from: "on"
to: "off"
for:
hours: 0
minutes: 1
seconds: 0
trigger: state
conditions:
- condition: not
conditions:
- condition: state
entity_id: climate.fritz_smart_thermo_wc
attribute: preset_mode
state: summer
- condition: device
device_id: 13d54ad72f75179a8678aca7a5d03b3f
domain: climate
entity_id: 17295126fc3b5c71681221eb0b09422d
type: is_hvac_mode
hvac_mode: "off"
actions:
- device_id: 13d54ad72f75179a8678aca7a5d03b3f
domain: climate
entity_id: 17295126fc3b5c71681221eb0b09422d
type: set_preset_mode
preset_mode: eco
mode: single
My simple plan is to heat with „Comfort“ at 06:00 until 07:00 in the morning. Usually, the window will need to be opened after breakfast at 07:30. So, my actual automation works well under that condition. However, occasionally there „is an urgent need“ to open the window at 06:30 or so. In my first automation, you could see, that it does not run when the outdoor temperature is above 16 °C. This was the case since I established the automation already at times around 07:00. Now, it is colder, and I realized, that the heating started at 07:00, when going into eco state. Therefore, I want to ignore the automation, when the temperature is changed at 07:00, as long as the window remains open. Occasionally, it remains open all day long, until someone complains about the „cold situation“ in there. But, maybe, there is a learning effect in the coming season. Currently, it saves a lot of energy, as long as it works as expected.
Hope, I understand your question right?
In my first automation, you could see, that it does not run when the outdoor temperature is above 16 °C.
That seems like the opposite of what you’ve got. Currently,
When you open the window, the HVAC is turned off, so long as (1) it’s not summertime AND (2) the temperature is below 16.
When you close the window, the HVAC goes into Eco, so long as (1) it’s not summertime AND (2) the HVAC was off when the window was opened.
I understood your original request to be: “depending on the time of day, when the HVAC is turning on, I want it to be either Eco or Comfort.” To accomplish that, you can use the code below… but I feel like I’m not fully understanding what you actually want to do.
alias: WC_Temperatur-Ein
description: Wenn das Fenster zu ist, WC-Thermostat einschalten
triggers:
- entity_id:
- binary_sensor.sensor_2_contact
from: "on"
to: "off"
for:
hours: 0
minutes: 1
seconds: 0
trigger: state
conditions:
- condition: not
conditions:
- condition: state
entity_id: climate.fritz_smart_thermo_wc
attribute: preset_mode
state: summer
- condition: device
device_id: 13d54ad72f75179a8678aca7a5d03b3f
domain: climate
entity_id: 17295126fc3b5c71681221eb0b09422d
type: is_hvac_mode
hvac_mode: "off"
actions:
- variables:
desired_mode: >
{% if now().hour >= 6 and now().hour < 7 %}
comfort
{% else %}
eco
{% endif %}
- device_id: 13d54ad72f75179a8678aca7a5d03b3f
domain: climate
entity_id: 17295126fc3b5c71681221eb0b09422d
type: set_preset_mode
preset_mode: "{{ desired_mode }}"
mode: single
Maybe, I was telling too much from the side of the daily practice, not looking at the strategy. Sorry.
It is not depending on the time of day, when the HVAC is turning on. My current combination of two automations is colliding.
First automation step turns HVAC off, triggered by window open
Second step turns HVAC to Eco mode, triggered by window closed
Now I would like to add tow additional automations
Third automation step turns HVAC to Comfort mode an 06:00
Fourth step turns HVAC to Eco mode at 07:00
As far as I can understand your solution, you combine third and fourth step into one and integrate it into the second automation step.
I am not sure (because my skills are low), if the problem is solved. E.g. when first automation happens between 06:00 and 07:00, that is, after third, but before fourth automation steps, the actual mode is Comfort and will switch to off. At 07:00 the mode will then switch to Eco, although the window is still open and should stay off. This will not happen with your construct?
BTW, the exclusion of „summer“ is just for avoiding an error, because as long as the state „summer“ is present, neither Comfort nor Eco states exists and thus could not be activated,
.
So, how do you want to handle the situation where 6:00a comes around and the window is open? Do you still want to turn Comfort on? Even if this is unlikely to happen, it’s important for me to understand in order to help you.
Seriously, I had not yet looked at that situation. But you are right, it might happen, all over the night, that the window „needs to be opened“. I think, that whenever the window is open, the HVAC should stay off, even before the warming up would happen.
This automation has three triggers: the window closes, the clock hits 6:00, and the clock hits 7:00. No matter which trigger fires it, it will only run if the window is closed (which is obviously guaranteed if the trigger is that the window closes), and only if it’s not summer.
When the automation triggers and all of those conditions are met, it will set the HVAC to Comfort if it’s between 6:00 and 6:59; otherwise it will set the HVAC to Eco.
Note that I took out your original condition that the HVAC be off. If you think you need that, let me know why. As you had it, it won’t work with this automation, since at 7:00am, the HVAC could be in Comfort. I’d need to know what it was accomplishing to help you put it back into this revised automation.
alias: WC_Temperatur-Ein
description: Wenn das Fenster zu ist, WC-Thermostat einschalten
triggers:
- entity_id:
- binary_sensor.sensor_2_contact
from: "on"
to: "off"
for:
hours: 0
minutes: 1
seconds: 0
trigger: state
- trigger: time
at: "6:00:00"
- trigger: time
at: "7:00:00"
conditions:
- condition: state
entity_id: binary_sensor.sensor_2_contact
state: "off"
- condition: not
conditions:
- condition: state
entity_id: climate.fritz_smart_thermo_wc
attribute: preset_mode
state: summer
actions:
- variables:
desired_mode: >
{% if now().hour >= 6 and now().hour < 7 %}
comfort
{% else %}
eco
{% endif %}
- device_id: 13d54ad72f75179a8678aca7a5d03b3f
domain: climate
entity_id: 17295126fc3b5c71681221eb0b09422d
type: set_preset_mode
preset_mode: "{{ desired_mode }}"
mode: single
I had the HVAC checked to be off, as there was the first condition to wait for one minute after the window being open to turn the HVAC off. In case, the window was closed whithin that minute, the second automation should not set the state to Eco.The other exclusion concerns the condition, that the outside temperature is below 16 °C. Then the there was no need to change the temperature. That was the idea behind. I have to get through your solution to see, if this condition is obsolete. This will take some brain time. At least for me…
Thanks
Things get complicated pretty fast even when you start with something simple
The code I posted above doesn’t have that safeguard to avoid running the “on” automation if the window was open for less than a minute. Does it matter–i.e., if the HVAC is already in Eco and you set it to Eco again, is there some adverse effect? If it doesn’t matter, then there is no point in worrying about it.
As a bonus, consider what happens if the window is opened at 6:59:50 and closed at 7:00:05. You would presumably still want to send the HVAC command, since your HVAC is probably in Comfort and now you’d like it to be in Eco. The automation WILL run at 7:00:00, but it will see that the window is open and do nothing; so you’ll need it to do something when it runs at 7:00:05 triggered by the window close.
Life can easily be more complex than expected, I know.
I had the situation, that the window was not locked and swinging in the wind, signalling on and off. So I inserted the one minute delay. Then I had a warming up period of 2h, where accidentially the window was opened for a few seconds, which resulted in a change from Comfort to Eco. Instead of inserting a delay at that point, i decided to check, if the first automation was completed, thus the HVAC is off. Now we have the resulting complications. Sorry.
There is still a way to manually operate the termostat. But it is not a good idea after months of nice automagics, especially on a cold morning at 06:50.
So, right now the automation will never set it to Eco between 6 and 7.
If you want to be able to manually set the HVAC to Comfort or other modes at other times and not have a momentary window blip throw it back into Eco—that’s doable but much harder.
At least, there are no errors in the traces log. Although after saving the file and opening it again, it asked to be saved again. So, I assume, that there is a check in the background, which did some syntax tuning, that needed to be saved again. Now, I will wait until tomorrow.