Aggregate window- and door switches for smart heating/ventilation

Hey everybody,

I have a flat and want to automate my heating depending on open windows and doors. I want to shut off the heating if
1.) the window in that room is open or
2.) it is conencted to a room with an open window via open doors.

Pretty simple I thought, as I have a corridor (“F”) that connects to every single room (living room “WZ”, bathroom “B” and sleeping room “SZ”) with one sensored door. There are no other co9nnections between the rooms. So my plan is as follows:

1.) put Aqara window/dor sensoprs to every window and door. The living room has 2 windows, so those are aggregated into a single entity that will become “open” as soon as one of the windows is “open”.
The bathroom has no window, so I will just activate the heating state via a logical and of the corridor ventilation state and the door opening state.
2.) for every room, create a template sensor that will control the “ventilating” status for that room in dependency of its windows, the door to the corridor and the corridor ventilation state:

{% set door = (states('binary_sensor.s_door_wz_contact')) == "on" %}
{% set window = (states('binary_sensor.g_window_wz') == "on") %}
{% set flur = (states('binary_sensor.t_ventilation_f')) == "on" %}
{{ (window) or (door and flur) }}

(this is for the living room with 2 windows; for the rest, the value is retrieved just as in the “door” variable with a single sensor)
3.) create a similar template for the corridor that sets the corridor’s ventilating status to a logical or of all the single rooms’ ventilation status:

{% set sz = (states('binary_sensor.t_ventilation_sz')) == "on" %}
{% set wz = (states('binary_sensor.t_ventilation_wz')) == "on" %}
{% set k = (states('binary_sensor.t_ventilation_k')) == "on" %}
{{ ((wz) or (sz)) or (k) }}

However, once I open up a room’s door to the corridor and that changes the value there, it won’t change back. Is that because of some type of safety mechanism preventing infinite loops or similar? Do you have a better idea of implementing that? Thank you very much in advance :slight_smile:

best wishes,
Nico

If I understood what you want to achieve correctly, the answer is pretty simple - create a group of binary sensors for each room.

By default (assuming you don’t mess around with the “All entities” option), the group will be on if at least one of those devices are on. You could then set up your automation based on the group state so that it turns on the heating when the relevant group(s) is off, and turn it on when the group is on.

Hey,

thank you very much for your reply!
Yes, that’s at least the part for a single room. The problem is: I want to shut off the heating in that room (even if the windows there are closed) when it is connected to an open window via doors.
Example:
Living room windows are closed. But the window in the bedroom is open, and also the door to the corridor - this makes the corridor’s ventilation status go to “ventilating”, and as soon as I open up the door to the living room, the living room’s ventilation status will also switch to “ventilating”, shutting off the heater there, even with the windows closed.

Anybody has ideas or experiences to share regarding that? :slight_smile: