Translating window sensor state with platform: template

Recently I bought a neo-coolcam z-wave door/windows sensor. It’s paired with my Vera z-wave controller, which in turn is linked to my home assistant.

I see the sensor showing up as binary_sensor.door__window_sensor_61 in home assistant, and after adding it to a group, it showed up on the screen.

As soon as I trigger the sensor, I see it change from on to off right away, so that’s great!
The only thing I would like to change is the “On” / “Off” to open / closed.

Apparently, the way to do that is with a “platform: template” entity. For that, I created the following in my configuration.yaml:

binary_sensor:
  - platform: template
    sensors:
      raamzolder:
        value_template: >-
          {% if states('binary_sensor.door__window_sensor_61')  == 'on' %}
            Open
          {% elif states('binary_sensor.door__window_sensor_61')  == 'off' %}
            Closed
          {% else %}
            Unknown
          {% endif %}

Unfortunately, the sensor just shows up as “Off” and doesn’t change when the sensor is triggered. When I go into “templates” and put the same code in there (after >-), it works like a charm.

Any idea where I’m going wrong?

In sensors.yaml I have the following…

rflkitchendoormag:
  value_template: '{% if is_state("switch.rfl_kitchen_door",  "on") %}open{% else %}closed{% endif %}'
  friendly_name: 'RFLKitchenDoorState'

and it works a treat :slight_smile:

I found the solution: Instead of a “binary_sensor”, I just had to declare it as a “sensor”.:man_facepalming:

You should mark this as being solved then! :wink:

Ok, but I can’t figure out how to do that, should I just put it in the topic title?

If you click on the three dots by your comment there should be a check mark icon. That’ll let you mark your comment as the solution!