Hi everybody,
below is my automation for automatically switching thermostats depending on window open/closed state. They used to work just fine until recently (there was no update in Home Assistant
, but I did upgrade zigbee2mqtt
in between - not sure if this is related), but now they don’t do what they used to.
Home Assistant 0.103.4
Zigbee2mqtt Version 1.9.0
-
coordinator {'type': 'zStack3x0', 'meta': {'transportrev': 2, 'product': 1, 'majorrel': 2, 'minorrel': 7, 'maintrel': 1, 'revision': 20191106}}
(HardwareTexas Instruments CC1352P-2
) - Thermostat
Eurotronic SPZB0001
Originally, they would trigger whenever either a thermostat was set to a different temperature or when I window state toggled. When a window opened, it would set hvac_mode: off
, otherwise (= window shut again) it would set hvac_mode: heat
. Example:
- window closed
- thermostat on 17.5°C
- window then opened
- thermostat set to off (= 5°C)
- window closed again
- thermostat set to heat (= back to whatever degrees it had been before, in this case 17.5)
Now this automation causes my thermostats to constantly be at 30°C, which seems to be “on” mode. I can not manually turn them down, as they are triggered by any change in temperature, which will cause them to revert to 30°C.
This automation is currently deactivated; however, this also means the thermostats will not change when windows change their status.
Another problem that has existed previously as well, but also needs to be fixed, is this: when an automation (below as well) changes the temperature, the automation above will not trigger. So let’s say I open a window at night. This would set hvac_mode: off
; however, if the automation turns up the heat at 6am (while the window is still open, the automation responsible for this will not turn it right back to hvac_mode: off
, but rather just set it to whatever the automation set it at 6am (even though the window is still open!)
automation for controlling thermostats depending on window state
automation:
- alias: "[Heizungen] Auto On/Off"
trigger:
- platform: state
entity_id:
- binary_sensor.arbeitszimmer_fenster_contact
- binary_sensor.kueche_fenster_contact
action:
- service: climate.set_hvac_mode
data_template:
entity_id: >
{% set zimmer = trigger.to_state.object_id.split('_')[0] %}
climate.{{zimmer}}_heizung_climate
hvac_mode: >
{% if trigger.to_state.state == "on" %}
off
{%elif trigger.to_state.state == "off" %}
heat
{% endif %}
- alias: "[Heizungen Fenstercheck]"
trigger:
- platform: state
entity_id:
- climate.arbeitszimmer_heizung_climate
- climate.jonna_heizung_climate
action:
- service: climate.set_hvac_mode
data_template:
entity_id: >
{% set raum = trigger.to_state.object_id.split('_')[0] %}
climate.{{raum}}_heizung_climate
hvac_mode: >
{% set fenster = 'binary_sensor.' ~ trigger.to_state.object_id.split('_')[0] ~ '_fenster_contact' %}
{% if states(fenster) == "on" %}
off
{% elif states(fenster) == "off" %}
heat
{% endif %}
# {{ 'off' if is_state(fenster, 'on') else 'heat' }}
automation for changing thermostats at certain times
input_number:
az_morgens:
name: "AZ 08:30"
initial: 18
<<: &input_template
min: 5
max: 30
step: 0.5
icon: mdi:radiator
unit_of_measurement: "°C"
az_abends:
name: "AZ 19:25"
initial: 15
<<: *input_template
automation:
# Arbeitszimmer {{{
- id: "heizung_az_morgens"
alias: "[Heizung] AZ 08:30"
trigger:
- platform: time
at: "08:30:00"
action:
- service: climate.set_temperature
data_template:
entity_id: climate.arbeitszimmer_heizung_climate
temperature: "{{ states('input_number.az_morgens') | float }}"
- id: "heizung_az_abends"
alias: "[Heizung] AZ 19:25"
trigger:
- platform: time
at: "19:25:00"
action:
- service: climate.set_temperature
data_template:
entity_id: climate.arbeitszimmer_heizung_climate
temperature: "{{ states('input_number.az_abends') | float }}"
# }}}
Would anybody please help me fix this? Currently it is as if I had regular (“non-smart”) thermostats. If a window gets opened, the corresponding thermostat has to be turned off manually. And because the second automation will set thermostats to other values even if their corresponding window(s) are open, I cannot reliably set temperatures at specific times.
Thank you for your input