I use HomematicIP to control my heating system with wall-mounted thermostats and thermostatic radiator valves (TRVs). Homematic supports linking these devices with window/door sensors, so that the set temperature is reduced when the window is opened. As I already had wired window alarm sensors connected to HA via MQTT, I was unwilling to go to the trouble and expense of adding about 30 additional sensors to all my windows.
I adapted this blueprint some time ago from another one that was posted here, but now I have forgotten who created it! So this is not all my own work, and if the original author contacts me, I will credit him/her here.
blueprint:
name: Window Open, Notify HomeMatic CCU
description:
An automation blueprint that reduces the set temperature of your climate
device or group if a window sensor is open for more than the preset wait time.
It uses the Homematic window sensor channel to set the temperature to the "Open-window
temperature" set in the device configuration. You should set the "Mode for temperature
fall detection" to Inactive to avoid conflicts. It waits until the window is closed
again in order to restore the climate entity temperature. It has an optional blocking
entity to prevent the automation running unnecessarily, for example during the
Summer season.
domain: automation
input:
window_entity:
name: Window Sensor
description: The window sensor that will control the climate entity.
selector:
entity:
domain: binary_sensor
device_class: window
open_delay:
name: Windows Open Wait Time
description: Time to delay after window opens before notifying HomeMatic.
default: 30
selector:
number:
min: 0.0
max: 600.0
unit_of_measurement: seconds
mode: slider
step: 1.0
blocking_entity:
name: (OPTIONAL) Blocking Entity
description: If this entity's state is on, it will prevent the automation from running. E.g. summer mode or away mode.
default:
selector:
entity:
domain: input_boolean
climate_entity:
name: Climate Device
description: The climate entity that is controlled by the window sensor.
selector:
entity:
domain: climate
source_url: https://gist.github.com/sotatech/500b53ee64ca5ad5299c22cde47407ed
variables:
blocking_entity: !input blocking_entity
climate_target: !input climate_entity
climate_id: '{{ state_attr( climate_target, "id") }}'
open_delay: !input open_delay
trigger:
- platform: state
entity_id: !input "window_entity"
to: "on"
for: !input "open_delay"
condition:
- condition: template
value_template: "{{ (blocking_entity == none) or (states[blocking_entity].state == 'off') }}"
action:
- service: homematic.set_device_value
data:
address: "{{ climate_id }}"
channel: 1
param: "WINDOW_STATE"
value: 1
- wait_for_trigger:
- platform: state
entity_id: !input "window_entity"
to: "off"
continue_on_timeout: false
- service: homematic.set_device_value
data:
address: "{{ climate_id }}"
channel: 1
param: "WINDOW_STATE"
value: 0
mode: restart
max_exceeded: silent
When I created this blueprint, I only needed it for windows, but later decided to use it for the doors as well. As my coding skills and my time are limited, I just created a separate blueprint for doors:
blueprint:
name: Door Open, Notify HomeMatic CCU
description: An automation blueprint that reduces the set temperature of your climate device or group if a window sensor is open for more than the preset wait time. It uses the Homematic window sensor channel to set the temperature to the "Open-window temperature" set in the device configuration. You should set the "Mode for temperature fall detection" to Inactive to avoid conflicts. It waits until the window is closed again in order to restore the climate entity temperature. It has an optional blocking entity to prevent the automation running unnecessarily, for example during the Summer season.
domain: automation
input:
door_entity:
name: Door Sensor
description: The door sensor that will control the climate entity.
selector:
entity:
domain: binary_sensor
device_class: door
open_delay:
name: Door Open Wait Time
description: Time to delay after door opens before notifying HomeMatic.
default: 30
selector:
number:
min: 0
max: 600
unit_of_measurement: seconds
blocking_entity:
name: (OPTIONAL) Blocking Entity
description: If this entity's state is on, it will prevent the automation from running. E.g. summer mode or away mode.
default:
selector:
entity:
domain: input_boolean
climate_entity:
name: Climate Device
description: The climate entity that is controlled by the door sensor.
selector:
entity:
domain: climate
variables:
blocking_entity: !input blocking_entity
climate_target: !input climate_entity
climate_id: '{{ state_attr( climate_target, "id") }}'
open_delay: !input open_delay
trigger:
- platform: state
entity_id: !input 'door_entity'
to: 'on'
for: !input 'open_delay'
condition:
- condition: template
value_template: "{{ (blocking_entity == none) or (states[blocking_entity].state == 'off') }}"
action:
- service: homematic.set_device_value
data:
address: "{{ climate_id }}"
channel: 1
param: 'WINDOW_STATE'
value: 1
- wait_for_trigger:
- platform: state
entity_id: !input 'door_entity'
to: 'off'
continue_on_timeout: false
- service: homematic.set_device_value
data:
address: "{{ climate_id }}"
channel: 1
param: 'WINDOW_STATE'
value: 0
source_url: https://gist.github.com/sotatech/500b53ee64ca5ad5299c22cde47407ed#file-door-open-notify-homematic-yaml
mode: restart
max_exceeded: silent
I did something simillar for my heating but as well as doors I also included room fans being on or no motion for 30 minutes. I use a template binary sensor to determine when an inhibit (blocking state) is active as follows:
z2_inhibit:
friendly_name: "Z2 Inhibit Active"
value_template: >-
{{ is_state('binary_sensor.balcony_door', 'on') or is_state('switch.sonoff04', 'on') or
is_state('input_boolean.z2_manual_operation', 'on') or is_state('binary_sensor.z2_occupied', 'off') }}
I then use the simple-thermostat card to show what states are inhibiting the heating from operating (in the example below maual operation and the fan are on but motion and open door are off):
At the moment the heating is in manual/standby (i.e. off) as it is quite warm, however if I flip manual off then it goes into “Eco” because the cooling fan is still on:
If the fan was turned off it would go into “Comfort” (the desired room “Comfort” temperature is set in each radiator using an IR remote).
That looks like a nice solution. The main challenge for me was figuring out the actual service call to HomeMatic to tell it that a window was open or closed, as the documentation is mostly in German. After that, the HomeMatic controller handles changing the temperature. This is the service call I use:
It works good (sadly it does not turn off the heating compleatly instead it turns it down to 12). Only thing I would have loved is a option for more heaters since my livingroom has 2 sadly and so it doesnt work there
The window open mode can be exposed to Home Assistant with read and write access with the new integration mentioned above. It is filtered by default because the attribute includes the string “STATE”, but you can make it visibile by adding “WINDOW_STATE” to an unignore file.