Window open, climate off

It is a simple and useful automation. After a defined delay it turns off a running climate entity and waits for the window to be closed again (also with a delay) until it turns the device back to the previous set HAVC mode. If you need you can optionally also define custom actions for opening and closing e.g. for notifications, blind/ cover control, etc.

Reduce heating costs

It prevents the entity of excessive heating and/or cooling while a window is open and also helps to reduce CO2 and your carbon dioxid footprint. I primary use it to reduce costs and raise thermal efficiency as well as personal comfort.

HAVCmode

Additional picture here

Supported modes

It checks if a climate device is running in any mode (not “off”) - in other words it triggers if any of the following modes is active: automatic, auto heat, heat_cool, dry and fan_only. Therefore, it is not limited to heat devices and also works with Air Conditioner, Air Ventilation and other climate devices.

Delay

You can also set a minimum open time and a minimum close time before the automation triggers and moves on to the next step.

Optional: Custom actions

Some of you have the need to perform additional actions like notification, adjusting the light, setting timer etc. Thanks for the feedback - this feature is also availible now!

Custom action example: Blind control

In this post I have explained how you additionaly can control your blinds. The blinds are opened after the window has been opened and closes again to the previous position (but you need an additional helper) Window open, climate off - #154 by SmartLiving.Rocks
ezgif-4-960674f87d

More than one window sensor?

Use Group Helper!

Now you can use helpers in order to create a group sensor. Go to Helpers (you can use the link to navigate there). In the lower right corner you choose Create Helper, then you choose Group and then you click on Binary Sensor group and add all the needed window sensors. Click Submit and it will create a new window group sensor that can be used with this Blueprint :partying_face:

Open your Home Assistant instance and show your helper entities.

Use yaml!

If you want to use yaml see this post here how to create a group sensor: Window open, climate off - #88 by SmartLiving.Rocks

Important

:warning: This blueprint only works for Home Assistant 2022.4 and later. For users running an earlier version, you need to import it from GitHub.

IMPORTANT notice for HomematicIP users - HomematicIP Blueprint from @sota - click here!
HomematicIP uses a service call homematic.set_device_value to set the WINDOW_STATE parameter directly, so it emulates the operation of HomematicIP door/window sensor. Thanks to @sota

UPDATED Version: Now it supports different HAVC modes: automatic, auto heat, heat_cool, dry, fan_only and off - if you need more please let me know :+1:

Changelog and information for Homematic Users

IMPORTANT notice for HOMEMATIC and TADO users :partying_face: this modified version of the blueprint now works right away also for you. No need to import it from GitHub! Tado Blueprint on Github - click here!

Important notice: If you have to restart Home Assistant for any reasons it will probably kill the automation. “Delay” and “Wait for” triggers will not be recognized after a restart and it can result in a strange behavior as @NicoLeOca has experienced and described in his post!

UPDATE: Thanks to @Soccs we have added a condition that checks if the climate device is running before the automation triggers! It is not specific for MELCloud users as some other climate devices also have more active states!

UPDATE: Now you can also define a minimum time in seconds before the automation is triggered. Good idea from @ferryhel ! Thanks

Blueprint

Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Or import this Blueprint by using the forum topic URL:

blueprint:
  name: Window open, climate off after a defined time
  description: 'Climate device like heating and cooling devices (if active) are turned
    off and go back to the previous set stage after the windows is closed again. You can also define a time before the 
    climate device turns back to its previous state. Now it supports several heating modes and different vendors like Tado. The supported
    HAVC modes are: automatic, auto, heat, heat_cool and off. If you need more please
    let me know. Happy automating!'
  domain: automation
  input:
    window_entity:
      name: Window Sensor
      description: The window sensor that controls the climate entity. If you have
        more window sensors please make a group sensor.
      selector:
        entity:
          domain: binary_sensor
          device_class: window
          multiple: false
    minimum_open_time:
      name: Miniumum open time
      description: Time in seconds to wait until the automation is triggered
      default: 12
      selector:
        number:
          min: 0.0
          max: 120.0
          unit_of_measurement: seconds
          mode: slider
          step: 1.0
    minimum_close_time:
      name: Miniumum close time
      description: Time in seconds to wait until the climate entity is turned on again
      default: 12
      selector:
        number:
          min: 0.0
          max: 300.0
          unit_of_measurement: seconds
          mode: slider
          step: 1.0
    climate_target:
      name: Climate Device
      description: The climate entity that is controlled by the window sensor.
      selector:
        entity:
          domain: climate
          multiple: false
    open_action:
      name: Additional Open Action (Optional)
      description: Action to perform if the door/window sensor is opened (e.g. open
        blind, tts announcement)
      default: []
      selector:
        action: {}
    close_action:
      name: Additional Close Action (Optional)
      description: Action to perform if the door/window sensor is cloed again (e.g.
        close blind, tts announcement)
      default: []
      selector:
        action: {}

variables:
  open_action: !input open_action
  close_action: !input close_action
  
mode: single
trigger:
- platform: state
  entity_id: !input window_entity
  to: 'on'
  for: !input minimum_open_time
condition:
- condition: not
  conditions:
  - condition: state
    entity_id: !input climate_target
    state: 'off'
action:
- choose:
  - conditions:
    - condition: state
      entity_id: !input climate_target
      state: cool
    sequence:
    - service: climate.turn_off
      target:
        entity_id: !input climate_target
    - choose:
      - conditions: '{{ open_action is defined and open_action|length > 0 }}'
        sequence: !input open_action
    - wait_for_trigger:
      - platform: state
        entity_id: !input window_entity
        to: 'off'
      continue_on_timeout: false
    - delay: !input minimum_close_time
    - choose:
      - conditions: '{{ close_action is defined and close_action|length > 0 }}'
        sequence: !input close_action
    - service: climate.set_hvac_mode
      target:
        entity_id: !input climate_target
      data:
        hvac_mode: cool
  - conditions:
    - condition: state
      entity_id: !input climate_target
      state: heat_cool
    sequence:
    - service: climate.turn_off
      target:
        entity_id: !input climate_target
    - choose:
      - conditions: '{{ open_action is defined and open_action|length > 0 }}'
        sequence: !input open_action
    - wait_for_trigger:
      - platform: state
        entity_id: !input window_entity
        to: 'off'
      continue_on_timeout: false
    - delay: !input minimum_close_time
    - choose:
      - conditions: '{{ close_action is defined and close_action|length > 0 }}'
        sequence: !input close_action
    - service: climate.set_hvac_mode
      target:
        entity_id: !input climate_target
      data:
        hvac_mode: heat_cool
  - conditions:
    - condition: state
      entity_id: !input climate_target
      state: heat
    sequence:
    - service: climate.turn_off
      target:
        entity_id: !input climate_target
    - choose:
      - conditions: '{{ open_action is defined and open_action|length > 0 }}'
        sequence: !input open_action
    - wait_for_trigger:
      - platform: state
        entity_id: !input window_entity
        to: 'off'
      continue_on_timeout: false
    - delay: !input minimum_close_time
    - choose:
      - conditions: '{{ close_action is defined and close_action|length > 0 }}'
        sequence: !input close_action
    - service: climate.set_hvac_mode
      data:
        hvac_mode: heat
      target:
        entity_id: !input climate_target
  - conditions:
    - condition: state
      entity_id: !input climate_target
      state: automatic
    sequence:
    - service: climate.turn_off
      target:
        entity_id: !input climate_target
    - choose:
      - conditions: '{{ open_action is defined and open_action|length > 0 }}'
        sequence: !input open_action
    - wait_for_trigger:
      - platform: state
        entity_id: !input window_entity
        to: 'off'
      continue_on_timeout: false
    - delay: !input minimum_close_time
    - choose:
      - conditions: '{{ close_action is defined and close_action|length > 0 }}'
        sequence: !input close_action
    - service: climate.set_hvac_mode
      data:
        hvac_mode: automatic
      target:
        entity_id: !input climate_target
  - conditions:
    - condition: state
      entity_id: !input climate_target
      state: auto
    sequence:
    - service: climate.turn_off
      target:
        entity_id: !input climate_target
    - choose:
      - conditions: '{{ open_action is defined and open_action|length > 0 }}'
        sequence: !input open_action
    - wait_for_trigger:
      - platform: state
        entity_id: !input window_entity
        to: 'off'
      continue_on_timeout: false
    - delay: !input minimum_close_time
    - choose:
      - conditions: '{{ close_action is defined and close_action|length > 0 }}'
        sequence: !input close_action
    - service: climate.set_hvac_mode
      data:
        hvac_mode: auto
      target:
        entity_id: !input climate_target
  - conditions:
    - condition: state
      entity_id: !input climate_target
      state: dry
    sequence:
    - service: climate.turn_off
      target:
        entity_id: !input climate_target
    - choose:
      - conditions: '{{ open_action is defined and open_action|length > 0 }}'
        sequence: !input open_action
    - wait_for_trigger:
      - platform: state
        entity_id: !input window_entity
        to: 'off'
      continue_on_timeout: false
    - delay: !input minimum_close_time
    - choose:
      - conditions: '{{ close_action is defined and close_action|length > 0 }}'
        sequence: !input close_action
    - service: climate.set_hvac_mode
      data:
        hvac_mode: dry
      target:
        entity_id: !input climate_target
  - conditions:
    - condition: state
      entity_id: !input climate_target
      state: fan_only
    sequence:
    - service: climate.turn_off
      target:
        entity_id: !input climate_target
    - choose:
      - conditions: '{{ open_action is defined and open_action|length > 0 }}'
        sequence: !input open_action
    - wait_for_trigger:
      - platform: state
        entity_id: !input window_entity
        to: 'off'
      continue_on_timeout: false
    - delay: !input minimum_close_time
    - choose:
      - conditions: '{{ close_action is defined and close_action|length > 0 }}'
        sequence: !input close_action
    - service: climate.set_hvac_mode
      data:
        hvac_mode: fan_only
      target:
        entity_id: !input climate_target

15 Likes

Hi,

Nice work. May I ask what kind of window sensor you are using? Looking for something usable for quite some time now but couldn’t find anything good. Wireless, small and battery powered would be awesome. RF or wifi would be great. Any advice? Thanks in advance and br

Hi, thanks!
Difficult question - they all have their pros and cons!

I am using several Z-Wave and Zigbee based window Sensors for testing purposes.

The Z-Wave are cost intensive but in a lot of form factors. The Zigbee are cheep and effective but not as nice looking as some Z-Wave. Furthermore there are some that have some more features like motion detection, illuminance, temperature, vibration detection. One also can detect if the window is tilt. Price range: 30-60 € (Controlled by Open Z-Wave integration).

The Zigbee ones are cheep and do their job. The manufacturing often feels more solid compared to some Z-Wave manufacturers. I have the Aquara Door Sensor (I got mine directly from a China Mi Store) for about 8$. (Controlled by deconz integration).

Thanks for the blueprint. I think it would be usefull to support multiple windows and/or a group to disable the climate entity.

4 Likes

Hi - thanks. I am not sure if this is supported at the moment. An blueprint example eg. several motion detectors trigger a light would be helpful. I will put it on the list of further improvements.

I haven’t tried it, but I think you just need to add target: like this;

  input:
    window_entity:
      name: Window Sensor
      description: The window sensor that controls the climate entity.
      selector:
        target:
          entity:
            domain: binary_sensor
            device_class: window

No. I have tried it before answering you. :nerd_face: You are able to select different window sensors but they do not create a working automation. It has to do with the “or” in the trigger area. I had a look at the several motion based light blueprints but all of them only work with only one sensor (at the moment).

Since the pir motion sensors I have are somewhat unreliable I ended up using two of them per device and build a template binary sensor around so that they only trigger as soon as both per device detected motion. I did that in esphome instead of HA but this would solve the issue for you if You use OR instead of AND. so any detected motion from any sensor would switch the binary sensor to ON. Not sure if that works in blueprints…

Thanks for the small overview of the sensors you’re using ^^

Br

Cool blueprint! :slight_smile:

For my case i have to change the line and remove the device class:

selector:
entity:
domain: binary_sensor
device_class: window

My sensors are not registered as window sensors. Is there any possibility to do the “wait for trigger” for two sensors? I have a room where are two windows and one heater.

Thanks! The sensors device class has to be specified correctly otherwise the blueprint does not find matching entitys. Your workaround shows all sensors - what in a lot of cases can become overwhelming.

As @Blade1337 reccomended you can use a “Template Binary Sensor” in order to make a (window) sensor group. Here you can also define a “device_class” so that my blueprint will recognize it as a window sensor.
You can put as many sensors as you want - the following example consists of two sensors.

binary_sensor:
  - platform: template
    sensors:
      window_group:
        friendly_name: Window Sensor with several Sensors
        value_template: >-
          {{ is_state('binary_sensor.training_fenster_936', 'on')
             or is_state('binary_sensor.training_philio_4_1_window_940', 'on')
            }}
        device_class: window 

Unfortunately it is not yet possible to do it directly in the Blueprint.

1 Like

Nice topic! I am looking for a blueprint using a temperature drop for detection of an open window. Then a window sensor is not needed. A rapid measured temperature drop of the thermostat or valve (Adam Plugwise) could be used to switch off the heating for 15-20 minutes.
Who can write such a blueprint? Thanks, Dirk.

Hi,
please define “A rapid measured temperature drop” in time and delta temperature. Please take in consideration that there are different environmental conditions during summer, winter as well as spring and autumn that will have an effect on the delta temperature.
Furthermore, I would like to know what happens after the 15-20 min countdown if the blueprint has been triggered and the window/door is still open?

This is great! It would be great if we could define the time it should be open before the heating is killed. For example, if I open my window for just a second, it shouldn’t kill the heating.

Yes, that is a good idea! I’ve just updated the blueprint. Is the time range of 120 seconds enough?

Just perfect! Thanks!

1 Like

Fritz Dect open window detection is a nice source for inspiration: open window based on temperature drop.
Fritz!dect open window
There are also suggestions of settings.

@SmartLiving.Rocks perhaps one final request: It would be really cool if we could send a message to a phone running the home assistant app:

{room} (or {climate} window was open. Killing heating
and on close:
{room} (or {climate} window closed. Restoring heating

Sorry, I am not convinced, and I highly doubt the efficiency as well as the stability of the automation. The failure rate is way too high (see also diverse AVM User/Experience groups/forums). Sorry, I am not the right guy for your requirement. Maybe you can develop a blueprint with these guys: Use rapid temperature delta to trigger automation? Thanks!

Notifications, alerts and other information is a complete different chapter in the Book of Home Automation! I see the need as I have TTS saying over my media player entity during daytime: “I have switched off the heater. The temperature is yx and the humidity is zx.” You have to set an input boolean helper to set notification ON/OFF as well as input sliders to define a time range. Then you use it also for other things like the “Garage/Entrance/ door is still open!”, “Person xy at the Entrance”, “Unknown car detected at the driveway!” etc. The notification is also able to select a device to send the Notification to (Media Player, Smartphone, TV, Telegram, E-Mail, LeMetric) based on different conditions (time, location, TV-on, sleepmode-on etc.)
For this basic automation it is too much.

Hello,
I grab your Creation and implemented a Condition. the condition is that if the Climate unit is actually turned off, this automation will not start the climate.
In this particular case for MELCLOUD systems. This is important because each climate unit has its own state names. if you want to find out about yours just go to DEveloper Tools and write the name of the entity. this will show you the state atributes.

blueprint:
  name: Window open, climate off after a defined time4
  description: An automation that turns off your climate device for exmple a heater
    or an air conditioning if a window sensor is open for a specific time. It waits
    until the window is closed again in order to turn the climate entity on again.
  domain: automation
  input:
    window_entity:
      name: Window Sensor
      description: The window sensor that controls the climate entity.
      selector:
        entity:
          domain: binary_sensor
          device_class: door
    minimum_open_time:
      name: Miniumum time the window is open
      description: Time in seconds to wait until the automation is triggered
      default: 12
      selector:
        number:
          min: 0.0
          max: 120.0
          unit_of_measurement: seconds
          step: 1.0
          mode: slider
    climate_target:
      name: Climate Device
      description: The climate entity that is controlled by the window sensor.
      selector:
        entity:
          domain: climate
    condition_target:
      name: Climate Device
      description: I Unit has a State by melcloud operate.
      selector:
        entity:
          domain: climate
  source_url: https://community.home-assistant.io/t/window-open-climate-off/257293
trigger:
- platform: state
  entity_id: !input 'window_entity'
  to: 'on'
  for: !input 'minimum_open_time'
condition:
- condition: state
  entity_id: !input 'condition_target'
  state:
  - 'heat'
  - 'dry'
  - 'cool'
  - 'fan_only'
  - 'heat_cool'
action:
- service: climate.turn_off
  entity_id: !input 'climate_target'
- wait_for_trigger:
  - platform: state
    entity_id: !input 'window_entity'
    to: 'off'
  continue_on_timeout: false
- service: climate.turn_on
  entity_id: !input 'climate_target'
1 Like