How to convert input_boolean to binary_sensor of type window

Hello,
I have several HomeKit BLE window sensors, that I want to get into Home Assistant. As I don’t want to unpair with HomeKit and get all the hassle with BLE pairing, I did a common trick, to create dummy input_boolean in HASS via helpers and exported these via HomeKit Integration. In Apple Home I made automations, that switch that dummy input_boolean accordingly. So input_bolean is on if window is opened. That works super good and I have now all window sensor states in HASS. However Alarmo only allows binary sensors as inputs. So I wanted to convert the input_boolean to binary sensor of type window.
This is what I put into config.yaml

binary_sensor:
  - platform: template
    sensors:
      alarmo_fenster_esstisch:
        value_template: "{{ is_state('input_boolean.dummy_fenster_esstisch', 'on') }}"
        friendly_name: Alarmo_Sensor_Esstisch
        device_class: window

However, it doesn’t seem to work. If I open that window that input boolean switches immediately to “on”, but the binary_sensor stays on “closed”. What am I doing wrong?

I think you are mixing the old style (where the top level binary_sensor has sub-sections for each platform type) with the new style (where the top level would be template), which may have something to do with the problem. Also, I’m pretty sure the attribute name is state and not value_template.

Try this:

template:
  - binary_sensor:
    - name: Alarmo Fenster Esstisch
      state: "{{ is_state('input_boolean.dummy_fenster_esstisch', 'on') }}"
      device_class: window
    - name: Alarmo Fenster Zwei
      state: "{{ is_state('input_boolean.dummy_fenster_zwei', 'on') }}"
      device_class: window

…etc…

You could probably just have states('input_boolean.dummy_fenster_esstisch') in the state attribute, too. The template binary sensor should interpret that correctly.

1 Like

Thanks. That‘s it. The last comment with the states command did the trick.