Templating sensor to binary_sensor

Hi,
i bought one “Strips by Sensative” door/window sensor which shows as a normal sensor not as a binary sensor in hass. The open/close Values are only numbers like 22 (open) and 23 (closed). So i created a binary_sensor template to solve this problem:

binary_sensor
  - platform: template
    sensors:
      badezimmer_fenster:
        value_template: >-
          {% if is_state('sensor.badezimmer_access_control', '22') %}
            open
          {% else %}
            closed
          {% endif %}
        friendly_name: Fenster

But the problem is, that the frondend not showing the correct status of the sensor. If i open/close the window the integer value of the original sensor changes, but nothing else.

I read in an old post that it is not possible to do this, but that was early 2016, perhaps its now possible or there are any workarounds to show the “correct” status in the frontend. For automations i can work with the numbers, that not a problem for me.

Thx.

I haven’t worked too much with binary sensors but the regular template sensors you can add the entity_id: sensor.badezimmer_access_control and it should update when that sensor changes. From what I read, it wasn’t necessary so I’m not sure why the binary sensor doesn’t update properly.

Worst case scenario, just create an automation that triggers on the sensor and updates the value of the binary sensor. Not ideal but should also get the job done.

Change the default report type to Binary:

image

You’ll need to wake the sensor before you push Set Config Parameter

1 Like

Thanks Tinkerer, thats works perfectly!

Just wondering what is this screenshot? I am using hass.io but do not have it.
I too actually having some issues with templating binary sensor: they don’t get updated fast enough. I see the actual sensor status gets updated first, but the template binary sensor only was updated seconds later.

Any pointers would be really appreciated.

Travis

It’s in the control panel.

Template sensors should be updated faster than that - what hardware are you running on, and what other add-ons have you installed?

That’s what I thought. The sensors are from Xiaomi/Aqua, using hass.io on Raspberry pi 3.
here is my configuration: https://pastebin.com/CcB3X0Xv
Thanks.

Well, that’s not Z-Wave, that’s Zigbee, so the Z-Wave control panel won’t work for you :wink:

right, but any idea of the template sensor issue ?
thanks.