Cover template with binary_sensor

I have an RF controlled motor to open/close a window. And there is an AQARA zigbee sensor that reports state of the window. It’s a binary sensor that has the states “on & off”.

The cover template now only accepts open/close or true/false. How can I still use this binary sensor to get the state for the window?

Thank in advance!!

### FENSTER Dachgeschoss

- platform: template
  covers:
    fenster_dg_osten:
      device_class: window
      friendly_name: "Fenster DG Osten"
      value_template: "{{ states('binary_sensor.aqara_fenster_dg_osten') }}"
      open_cover:
        service: script.fenster_dg_osten_auf
      close_cover:
        service: script.fenster_dg_osten_zu

This reports true if the binary_sensor’s state is on. Otherwise it reports false.

{{ is_state('binary_sensor.aqara_fenster_dg_osten', 'on') }}

Here it is in your cover configuration:

### FENSTER Dachgeschoss

- platform: template
  covers:
    fenster_dg_osten:
      device_class: window
      friendly_name: "Fenster DG Osten"
      value_template: "{{ is_state('binary_sensor.aqara_fenster_dg_osten', 'on') }}"
      open_cover:
        service: script.fenster_dg_osten_auf
      close_cover:
        service: script.fenster_dg_osten_zu

Excellent. THANKS A LOT. Learned something today :slight_smile: :+1:

1 Like