Window open, climate off

We have discussed it here. You need to make a Binary Template Sensor. Example in the following post:

1 Like

Thank you for this blueprint.
I do have one question though. i do not want to use the open state from my radiator valve, but from a aqara window sensor as this seems to be more accurate. I cannot select these in the blueprint. Any easy way to fix this?

I assume the device class of your sensor is not “window”. We have discussed it here:

You are correct. I did change this and all is working fine now.
Thank you !

1 Like

@SmartLiving.Rocks

The HA description states that this should no longer be used. What would be the more modern variant?

template:
  - binary_sensor:
    sensors:
      window_group:
        friendly_name: Windows_Heating_Julia
        value_template: >-
          {{ is_state('binary_sensor.openclose_28', 'on')
             or is_state('binary_sensor.openclose_29', 'on')
            }}
        device_class: window 

Thought would be this, but this does not work so :roll_eyes:

Hi, thanks for the hint! That’s also a very important information for @WhimsySpoon @Plouf34 as I know they are also using several sensors for one climate entity.

NOT RECOMMENDED (but working) Template - Home Assistant

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 

RECOMMENDED Version Template - Home Assistant

template:
  - binary_sensor:
      - name: NEW Window Group Sensor
        state: >
          {{ is_state('binary_sensor.training_fenster_936', 'on')
             or is_state('binary_sensor.training_philio_4_1_window_940', 'on')
            }}
        device_class: window
1 Like

Thks.
Where do you create the recommended version? In the binary_sensor.yaml? if yes, I must write all the code above?

@SmartLiving.Rocks

I have 3 rooms with 2 window contacts and it won’t work on one. Looked through several times now, can not find the error. Ask for some advice.

config:

template:
  - binary_sensor:
      - name: Julia Heizung Gruppe
        state: >
          {{ is_state('binary_sensor.openclose_28', 'on')
             or is_state('binary_sensor.openclose_29', 'on')
            }}
        device_class: window
        
  - binary_sensor:
      - name: Schlafzimmer Heizung Gruppe
        state: >
          {{ is_state('binary_sensor.openclose_23', 'on')
             or is_state('binary_sensor.openclose_24', 'on')
            }}
        device_class: window
        .
.
.
.

 Logger: homeassistant.components.automation
Source: components/automation/__init__.py:646
Integration: Automatisierung (documentation, issues)
First occurred: 12:00:11 (3 occurrences)
Last logged: 12:01:49
Blueprint Window open, climate off after a defined time generated invalid automation with inputs OrderedDict([('climate_target', 'climate.julia_zimmer'), ('minimum_open_time', 30), ('window_entity', 'Julia.Zimmer.Fenster')]): Entity ID Julia.Zimmer.Fenster is an invalid entity ID for dictionary value @ data['entity_id']. Got None

In configuration.yaml (please refer to the official documentation!). Of course, if you have manually set a binary_sensor.yaml you could do it here, too.

First, I wanna thank you for your automation. This is exactly what I needed. There is just one problem. The automation turns off the heating without a problem but in one of two instances it won’t turn the heating back on. There is no apparent system. sometimes it works, sometimes not. Do you have an idea that I can try?

Hi, Check the trace timeline and share the result.

Hi,

Thanks for the quick response. I attached the trace but I am not sure if it was a failed attempt or a successful.

{
  "trace": {
    "last_step": "action/1",
    "run_id": "7d4594d1801111d16f517a89eb1855e8",
    "state": "stopped",
    "script_execution": "cancelled",
    "timestamp": {
      "start": "2021-11-21T16:28:39.714628+00:00",
      "finish": "2021-11-21T16:30:20.974297+00:00"
    },
    "domain": "automation",
    "item_id": "1635175869643",
    "trigger": "state of binary_sensor.combined_windows_livingroom",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2021-11-21T16:28:39.715219+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.turn_heating_wohnzimmer_off_if_fenster_open",
              "state": "on",
              "attributes": {
                "last_triggered": "2021-11-21T15:06:13.979193+00:00",
                "mode": "single",
                "current": 0,
                "id": "1635175869643",
                "friendly_name": "Turn heating wohnzimmer off if fenster open"
              },
              "last_changed": "2021-11-21T16:27:12.313863+00:00",
              "last_updated": "2021-11-21T16:27:12.313863+00:00",
              "context": {
                "id": "5e41aaecb387aced8e8590b52fb30762",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "platform": "state",
              "entity_id": "binary_sensor.combined_windows_livingroom",
              "from_state": {
                "entity_id": "binary_sensor.combined_windows_livingroom",
                "state": "off",
                "attributes": {
                  "friendly_name": "combined_windows_livingroom"
                },
                "last_changed": "2021-11-21T16:15:37.464056+00:00",
                "last_updated": "2021-11-21T16:15:37.464056+00:00",
                "context": {
                  "id": "7b7a54d42b4c088bd6267cbb6e7871d1",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "binary_sensor.combined_windows_livingroom",
                "state": "on",
                "attributes": {
                  "friendly_name": "combined_windows_livingroom"
                },
                "last_changed": "2021-11-21T16:28:31.711537+00:00",
                "last_updated": "2021-11-21T16:28:31.711537+00:00",
                "context": {
                  "id": "e488ae5ee291834be5c514c6ab01d67b",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": {
                "__type": "<class 'datetime.timedelta'>",
                "total_seconds": 8
              },
              "attribute": null,
              "description": "state of binary_sensor.combined_windows_livingroom"
            }
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2021-11-21T16:28:39.715485+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "condition/0/conditions/0": [
        {
          "path": "condition/0/conditions/0",
          "timestamp": "2021-11-21T16:28:39.715615+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "condition/0/conditions/0/entity_id/0": [
        {
          "path": "condition/0/conditions/0/entity_id/0",
          "timestamp": "2021-11-21T16:28:39.715742+00:00",
          "result": {
            "result": false,
            "state": "heat",
            "wanted_state": "off"
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2021-11-21T16:28:39.718208+00:00",
          "changed_variables": {
            "context": {
              "id": "3ac2c6ad407eab5ca801265cbba7932f",
              "parent_id": "e488ae5ee291834be5c514c6ab01d67b",
              "user_id": null
            }
          },
          "result": {
            "params": {
              "domain": "climate",
              "service": "turn_off",
              "service_data": {},
              "target": {
                "entity_id": [
                  "climate.thermostat_wohnzimmer"
                ]
              }
            },
            "running_script": false,
            "limit": 10
          }
        }
      ],
      "action/1": [
        {
          "path": "action/1",
          "timestamp": "2021-11-21T16:28:39.729057+00:00",
          "result": {
            "wait": {
              "remaining": null,
              "trigger": null
            }
          }
        }
      ]
    },
    "config": {
      "trigger": [
        {
          "platform": "state",
          "entity_id": "binary_sensor.combined_windows_livingroom",
          "to": "on",
          "for": 8
        }
      ],
      "condition": [
        {
          "condition": "not",
          "conditions": [
            {
              "condition": "state",
              "entity_id": "climate.thermostat_wohnzimmer",
              "state": "off"
            }
          ]
        }
      ],
      "action": [
        {
          "service": "climate.turn_off",
          "entity_id": "climate.thermostat_wohnzimmer"
        },
        {
          "wait_for_trigger": [
            {
              "platform": "state",
              "entity_id": "binary_sensor.combined_windows_livingroom",
              "to": "off"
            }
          ],
          "continue_on_timeout": false
        },
        {
          "service": "climate.turn_on",
          "entity_id": "climate.thermostat_wohnzimmer"
        }
      ],
      "id": "1635175869643",
      "alias": "Turn heating wohnzimmer off if fenster open",
      "description": ""
    },
    "blueprint_inputs": {
      "id": "1635175869643",
      "alias": "Turn heating wohnzimmer off if fenster open",
      "description": "",
      "use_blueprint": {
        "path": "SmartLiving.Rocks/window-open-climate-off.yaml",
        "input": {
          "window_entity": "binary_sensor.combined_windows_livingroom",
          "climate_target": "climate.thermostat_wohnzimmer",
          "minimum_open_time": 8
        }
      }
    },
    "context": {
      "id": "3ac2c6ad407eab5ca801265cbba7932f",
      "parent_id": "e488ae5ee291834be5c514c6ab01d67b",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "when": "2021-11-21T16:28:39.730541+00:00",
      "name": "Wohnzimmer Heizung",
      "state": "off",
      "entity_id": "climate.thermostat_wohnzimmer",
      "context_domain": "climate",
      "context_service": "turn_off",
      "context_event_type": "call_service",
      "message": "turned off"
    }
  ]
}

I am talking about the trace timeline! Here you can see what the automation does and you can easily find the mistake. I asked you to share with us the results of the 1.) working 2.) not working blueprint. Please make sure to document “if it was a failed attempt or a successful.” That is essential for helping you!

What do you mean - you are have two Home Assistant instances using the same climate entity?

I highly doubt that there is an issue with this blueprint. Please make sure that you have read all the corner cases we already have been trough in this documentation, such as:

Hi,

Thank you for your time and help. I opened the trace timeline and clicked “download trace”. Thats why I thought this is the text format of the trace time line and better suited for the forum.
I meant it fails in one out of two attempts and I read the section about restarting HA in between.
But after playing a little bit with the automations and the actions it triggers it seems to be a problem with my thermostats. They sometimes ignore the turn_on service call. And I have no idea why. But it has nothing to do with your blueprint. So thanks again.

Ah ok. What thermostats are you using? The integration would also be interesting to know.

I am using multiple Moes BHT-002 connected with a conbee2 over deconz updated to the current version. All other automations (like changing the temperature) are working but turning them on (when they are off) often doesn’t work. But I didn’t find time to investigate further where the problem is. I am probably going to send the “on” signal a few times until they are back on.

I have a feeling something broke in a recent update. This used to work flawlessly for several weeks, but as of yesterday or the day before (?) the heat is not turned back on when the window closes.
image
The call to turn climate back on is simply ignored or doesn’t get there for some reason. Manually enabling them seems to work every time, though. I wonder if 2021.11.5 is responsible.

I have just updated my development instance to 2021.11.5. The blueprint still works for me. Is anybody else experiencing the same behavior?
ezgif-7-535709268f20

I would suggest there is something wrong with your integration, maybe the changes were affected there. Also check the post above, as the climate entity has a similar behavior.

What thermostats are you using and what integration?

I would try the zigbee2mqtt integration Moes BHT-002-GCLZB control via MQTT | Zigbee2MQTT
Deconz does not have a “thermostat” device class, and maybe that is the reason of the strange behavior.

I’m using zigbee2mqtt with a CC2652P based coordinator.
Like I said, the blueprint/automation does send the command fine, it just seems it’s not properly passed on to the device by HA. Manually clicking the button on the thermostat card works.
I seem to have fixed it for now by modifying your blueprint slightly to send the command to turn back on twice.