Window open, climate off

Thank you very much! That is the most important thing!

I’m wondering if the automation still works as expected?

hey there.
although this is really great work @SmartLiving.Rocks

since this still involves specifying every room, every window and every thermostat - all in single automations, i think this whole window/climate problem needs a more out-of-the-box approach using wildcards.

in this threat, a nice fellow came up with a real short and great solution

this works out of the box for every window and room. no matter what manufacturer.
but like kermit said
“This is assuming you have an area set for each device/entity and the all the windows sensors have their device_class set to window.”
image

[{"id":"59c7f851f774ae47","type":"tab","label":"Global Window Open","disabled":false,"info":"","env":[]},{"id":"744b9f1935875b62","type":"server-events","z":"59c7f851f774ae47","name":"Window Opened","server":"bae62b83.87c628","version":2,"eventType":"state_changed","exposeToHomeAssistant":false,"eventData":"{\"new_state\":  {\"state\": \"on\", \"attributes\": { \"device_class\": \"window\"}}}","haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"$outputData(\"eventData\").event.new_state","valueType":"jsonata"},{"property":"template","propertyType":"msg","value":"\"{{ area_id('\" & $outputData(\"eventData\").entity_id & \"')}}\"","valueType":"jsonata"}],"event_type":"","x":245,"y":220,"wires":[["ca4b9b28e27c1efd"]]},{"id":"ca4b9b28e27c1efd","type":"api-render-template","z":"59c7f851f774ae47","name":"get entities for area","server":"bae62b83.87c628","version":0,"template":"","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":475,"y":220,"wires":[["39633f7c67c42b88","92dc067bd4f2369b"]]},{"id":"39633f7c67c42b88","type":"api-call-service","z":"59c7f851f774ae47","name":"turn off climate","server":"bae62b83.87c628","version":5,"debugenabled":false,"domain":"climate","service":"turn_off","areaId":["{{payload}}"],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":693,"y":220,"wires":[[]]},{"id":"8bb71ad5d4996322","type":"server-events","z":"59c7f851f774ae47","name":"Window Closed","server":"bae62b83.87c628","version":2,"eventType":"state_changed","exposeToHomeAssistant":false,"eventData":"{\"new_state\":  {\"state\": \"off\", \"attributes\": { \"device_class\": \"window\"}}}","haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"$outputData(\"eventData\").event.new_state","valueType":"jsonata"},{"property":"template","propertyType":"msg","value":"\"{{ area_id('\" & $outputData(\"eventData\").entity_id & \"')}}\"","valueType":"jsonata"}],"event_type":"","x":250,"y":485,"wires":[["684756f832d6aa4f"]]},{"id":"684756f832d6aa4f","type":"api-render-template","z":"59c7f851f774ae47","name":"get entities for area","server":"bae62b83.87c628","version":0,"template":"","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":470,"y":485,"wires":[["4540aff8a2bb80e3","a9612e0bfd6c82b5"]]},{"id":"4540aff8a2bb80e3","type":"api-call-service","z":"59c7f851f774ae47","name":"turn off climate","server":"bae62b83.87c628","version":5,"debugenabled":false,"domain":"climate","service":"turn_on","areaId":["{{payload}}"],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":708,"y":485,"wires":[[]]},{"id":"78dd80c123f6f2c9","type":"api-call-service","z":"59c7f851f774ae47","name":"open covers","server":"bae62b83.87c628","version":5,"debugenabled":false,"domain":"cover","service":"close_cover","areaId":["{{payload}}"],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":880,"y":560,"wires":[[]]},{"id":"a2a04479af5713ba","type":"api-call-service","z":"59c7f851f774ae47","name":"open covers","server":"bae62b83.87c628","version":5,"debugenabled":false,"domain":"cover","service":"set_cover_position","areaId":["{{payload}}"],"deviceId":[],"entityId":[],"data":"{\"position\": 10}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":870,"y":285,"wires":[[]]},{"id":"92dc067bd4f2369b","type":"api-current-state","z":"59c7f851f774ae47","name":"is night?","server":"bae62b83.87c628","version":3,"outputs":2,"halt_if":"below_horizon","halt_if_type":"str","halt_if_compare":"is","entity_id":"sun.sun","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":635,"y":325,"wires":[["a2a04479af5713ba"],[]]},{"id":"a9612e0bfd6c82b5","type":"api-current-state","z":"59c7f851f774ae47","name":"is night?","server":"bae62b83.87c628","version":3,"outputs":2,"halt_if":"below_horizon","halt_if_type":"str","halt_if_compare":"is","entity_id":"sun.sun","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":685,"y":560,"wires":[["78dd80c123f6f2c9"],[]]},{"id":"bae62b83.87c628","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

this shows how easy it can be, and i think is more the way smart-home should be today.

a blueprint without node-red using this approach would be of course awesome, but i am more comfortable with node-red

This looks really cool! However, I noticed that it won’t let me select contact sensors that are shown as “doors” in Home Assistant. Only the contact sensors that are shown as “windows” show up.

Wouldn’t it be useful to be able to select door sensors as well?

Thanks for that great blueprint!

I adpted it to my purposes. I substituted the complete action: paragraph. It’s now much shorter, no need for target_temperature and the conditions for state any more. :slight_smile: I replaced by creating scenes on the fly and reloading them. They fit ALL climate devices, doesn’t matter which modes they have. Creating and reloading scenes on the fly

action:
  - service: scene.create
    data:
      scene_id: before
      snapshot_entities: !input climate_target
  - service: climate.turn_off
    target:
      entity_id: !input climate_target
  - wait_for_trigger:
      - platform: state
        entity_id: !input window_entity
        to: "off"
    continue_on_timeout: false
  - delay: !input minimum_close_time
  - service: scene.turn_on
    target:
      entity_id: scene.before

Much shorter and not as complicated. :slight_smile:

1 Like

What? Wait, no way :heart_eyes:! You are absloutely right :partying_face: I was not aware that scenes also can be used for every entity - I thought it is only for lights! Thanks for educating me - that is a powerful feature!

Do you have an idea how we can dynamically define a name for scene_id: before so that every bp automation gets its own scene name for every climate area?

If it is a window, then define its device class to window!

change binary sensors device class from door to window in home assistant

There is also a version for any binary sensor on GitHub you can import manually:

Dynamic scene_id, very good hint. It doesn’t seem to be possibel (until now) templating this parameter. What I found here might be a possible solution. I will investigate it.

I made a little success. I got an entity list with
{{ expand(state_attr('climate.trv_wohnzimmer', 'entity_id')) |map(attribute='entity_id')|list }}

I did define this device group in configuration.yaml like this:

climate:
  - platform: climate_group
    name: TRV-Wohnzimmer
    temperature_unit: C
    entities:
      - climate.trv_wohnen_01
      - climate.trv_wohnen_02
      - climate.trv_wohnen_03

To group climate devices you’ll need Home Assistant Climate Group

Now i will do some tests how it behaves when you open and close several windows.

This doesn’t work also. becaus it restores always the last situation. I will try using two scripts as described here https://community.home-assistant.io/t/turning-on-a-scene-with-a-dynamic-entity-id-in-a-script/283941

Indeed, that tricky. Interesting links you have shared! Especially the climate group.

Here is also a guy who wants to improve the climate automation using node red. Maybe that is helpful for you: Window open, climate off - #191 by snikay

As far as I understand, you want to have a shorter code, but now you are creating two more scripts for each heating area to get it working?

Generally, Blueprints are designed to make complicated code easy to use for non-coders. You can have a look at how this Blueprint started (very easy, simple and straight forward) and how it has developed over the time. The community gave great feedback and we discovered a lot of corner cases from all over the world. Covering more than 90% of all climate devices from different vendors worldwide including air conditioning. To make it working and over all the corner cases the code became more complex/ complicated but at the same time it got better and better and now it is rock solid :partying_face: with more than 3,500 installations and even a fork for Homematic users as well as a working solution for AVM Fritz Dect Thermostats.

Regarding Homematic: thanks for pointing out the option to control the window state via setDevice-Dingenskirchen.

There is also an even better approach (in my opinion). When using the superceding in development integration for Homematic: GitHub - danielperna84/custom_homematic: Custom Home Assistant Component for HomeMatic one can expose the window state as a switch entity. The main benefit is that this adds read access to the state.

By default the window state is not exposed. You have to add the line “WINDOW_STATE” to an unignore file. See Fensterzustand TRV · Discussion #725 · danielperna84/hahomematic · GitHub

Thanks for sharing. I am already following the topic on github - somebody on the German Home Assistant matrix channel recommended it to me.
Unfortunately, I have not fully understood the homematic cosmos with it ip/wired/ “normal” and its reasperymatic in order to make it fully local accessible. Too complicated for a Z-Wave guy :wink:
As far as I have seen, you already have reached out to @sota who is the Homematic expert and also made a blueprint version.

I’m facing an issue, the thread is too long to follow and can’t find similar that I’m facing. I have four automation that happens when open some window or door sensor and stops heating just as this blueprint promises, all automations was launched because I’m using mode: parallel, but when the first paralleled automation finish, all are finished also, is this behaviour correct? Or exist a way to each paralleled automation ends when the door window match conditions?

alias: Clima) Apagar calefacción Matrimonio si se abren puertas o ventanas
description: ""
mode: parallel
max: 4
use_blueprint:
  path: SmartLiving.Rocks/window-open-climate-off.yaml
  input:
    window_entity: binary_sensor.sensores_de_ventanas_y_puertas_en_matrimonio
    minimum_open_time: 60
    minimum_close_time: 30
    climate_target: climate.dormitorio_matrimonio

Why?

My original code is single

Then, it’s not possible to handle the automation for each room in parallel way? When I run the automation in more than one room, only one of the automation works

Was my mistake, I’m trying again, I revert the code without parallel and works as expected, thank a lot, something mysterious happened today at morning

Due to some limitation, a Shelly TRV doesn’t come back to the initial setting (temperature). Is it possible to toggle the preset instead of the HVAC (“operation” in UI)? Or do you think of a workaround? Thanks in advance.

Interesting! Thanks for Testing my blueprint with Shelly TVR.
I think here is the problem as the thermostat does not have an ‘off’ state.


I need to think how we can handle it.

  1. Storing the temperature needs an additional helper that needs to be created manually.
  2. Setting the temperature to its minimum is a solution but it would be exclusive for Shelly.
  3. Ask shelly to upgrade their firmware.

I have the same behaviour with a Zwave thermostat that is 8 years old. Turning off should be supported and I think more users will claim it

Hi. I’m using your blueprint and you’ve done a wonderful work!
I wonder if there was a way to detect when the door/window is open for a given time (e.g. 2 minutes) and then stop the cycle of the automation.
Better explained, I want it to work as it is intended to be, so I open the door and the climate stops, I close it and it restores the previous HVAC mode but I wanted to stop the automation if the door was open for more than X time and keep the climate device off.

Regards,
Handryck

You can use the optional action part for that. Choose a delay e.g. 5 min and then a call service ‘automation turn off’ and choose the automation (you need to create the automation first)!

How are you going to turn on the automation again?