Window open, climate off

Please send us a screenshot of the HomematicIP thermostat. I want to know what state attribute it provides to Home Assistant.

Open your Home Assistant instance and show your state developer tools.

@wurzel12 also reported some strange behavior of his Fritz DECT TVR von AVM - please also send us the state attribute of your climate device.

Here is an example of the information needed:

Share your Trace information as well

In addition to that, please also share the trace so that we can analyze the problem professionally. Thanks!

Here are the ones you want, the state attribute and trace.
AVM Comet
Comet
AVM DECT301
DECT_301
Trace

Hope it helps…
If you need more info, just ask

Thanks for sharing the information! I have made some research for your thermostat and it confuses me a bit.

How long does it take for the thermostat to receive a new temperature, for example, if you adjust it via the Home Assistant UI? Is it instantly or t´does it take minutes (up to 10)?

Yes, that’s a bit strange, AVM uses DECT to control the thermostats.
HA sends the command to the FritzBox and the box at intervals of 15 minutes to the thermostat.
Depending on when HA issues the command, it can take up to 15 minutes for the thermostat to respond.
The Comet thermostat is instantly responsive, although it also uses DECT it is all a bit confuse.
I think what’s missing is reading out the current Preset_Mode, and then putting it back into HA.

I apologize but I got busy with some emergency work. I deleted another automation that was controlling the fan since new HP does what I needed to do automatically then I updated and restarted HA. Apparently traces get deleted during restarts but I haven’t been able to replicate the issue since.

With a delay like that I would not call it smart - excuse me wir haben 2022 !!! :sweat_smile: And that can cause strange behavior as reported.

I agree on the following but we cannot handle it with this blueprint.

Try to import this automation manually by creating a new automation and switch to edit in yaml. Then paste the following code and change the thermostat as well as the window sensor (you can also do it in editor mode if you preferrer). Please test it with all corner cases

  • opening and closing within the 15 min range
    • in comfort mode
    • in eco mode
  • opening and closing outside the 15 min range
    • in comfort mode
    • in eco mode

If all the results are positive, we can create a blueprint for this AVM Thermostat

alias: Ecobee as Fritz AVM Thermostat
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.door_window_sensor_x # Change here
    to: "on"
condition:
  - condition: not
    conditions:
      - condition: state
        entity_id: climate.ecobee # Change here
        state: "off"
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: climate.ecobee # Change here
            attribute: preset_mode
            state: comfort # not home
        sequence:
          - service: climate.turn_off
            data: {}
            target:
              entity_id: climate.ecobee # Change here
          - wait_for_trigger:
              - platform: state
                entity_id:
                  - binary_sensor.door_window_sensor_x # Change here
                to: "off"
            continue_on_timeout: false
          - service: climate.turn_on
            data: {}
            target:
              entity_id: climate.ecobee # Change here
          - service: climate.set_preset_mode
            data:
              preset_mode: comfort # not home
            target:
              entity_id: climate.ecobee # Change here
      - conditions:
          - condition: state
            entity_id: climate.ecobee # Change here
            attribute: preset_mode
            state: eco
        sequence:
          - service: climate.turn_off
            data: {}
            target:
              entity_id: climate.ecobee # Change here
          - wait_for_trigger:
              - platform: state
                entity_id:
                  - binary_sensor.door_window_sensor_x  # Change here
                to: "off"
            continue_on_timeout: false
          - service: climate.turn_on
            data: {}
            target:
              entity_id: climate.ecobee # Change here
          - service: climate.set_preset_mode
            data:
              preset_mode: eco
            target:
              entity_id: climate.ecobee # Change here
mode: single

I created the automation and will do some testing and then give feedback.
The 1st is: the two Preset_Mode are: “eco” and “comfort”
For a better understanding: The thermostats wake up every 15 minutes and ask for a change in the Fritzbox, e.g. 0:00; 0:15, 0:30
If Homme Assistant or an external thermostat reports a change, it can take between 1-15 minutes for the thermostat to adopt the new values.
We don’t need a 15 minute delay, should I e.g. open at min 05 and close again at min 11, the thermostat does not change its state, remains on off, heating (Eco or Comfort).
With your original, the thermostat always jumped to “Comfort” heating and ignored the Preset_Mode.
Since the temperature is very sluggish, one can argue how useful the whole thing is :wink: And why is AVM the “only one” that uses DECT ULE :wink:
What is also exciting is that there seems to be a “window open” function in the firmware for an ext. Sensor, there was a window sensor from Panasonic.

Oh Sorry - the automation was designed for home and eco
Bildschirmfoto 2022-10-18 um 10.50.45

You need to change that - I have also updated the post with the automation for your AVM!

No problem, I fixed it myself :wink:
It looks like it works exactly as it should, see screenshot.
I used 10 sec delay for testing, the status changes immediately in the Fritzbox and after a few minutes on the thermostat. Everything also jumps back into the correct starting position.

Eco-Modus:

Comfort Modus:

I think this can also be used for other thermostats, since I still have a ZigBee thermostat from Hama here, it even has 5 preset_modes, it just has to be adjusted manually.
In any case, thank you very much, I also learned something :slight_smile:

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