Change Device Class from switch to binary_sensor

Hi everyone. I just bought a fibaro smart implant to transfer all my old home alarm sensors to z wave. However, it shows my device as a switch and has the on off. I can’t find any way to transfer it to “binary_sensor” open or close. Is there any way that I can change it to “binary_sensor”, so it only shows open or close? Thank you.

You can’t. You’d have to wrap it with a template binary sensor.

1 Like

Thank you for your response. I did add the code below to my /config/configuration.yaml. However, it didn’t work. I don’t know how to fix it.

binary_sensor:

  • platform: template
    sensors:
    switch.smart_implant_6:
    friendly_name:
    device_class: opening
    value_template: “{{ is_state(‘switch.door’, ‘on’) }}”

The entity of the switch in our screenshot is called “switch.smart_implant_6”. So the value_template needs to check for that.

binary_sensor:
  - platform: template
    sensors:
      smart_implant_6:
        friendly_name: Smart implant 6
        value_template: "{{ is_state('switch.smart_implant_6', 'on') }}"
2 Likes

binary_sensor:

  • platform: template
    sensors:
    smart_implant_6:
    friendly_name: Smart implant 6
    value_template: “{{ is_state(‘switch.smart_implant_6’, ‘on’) }}”

I added it in my /config/configuration.yaml. However, it still shows On-Off and not become binary_sensor” open or close. I don’t know what to do next.

Screenshot 2021-04-14 105213

Since those switches are called “Main Door” and “Back Door” I would guess that you need to change your lovelace card and add the binary sensor there.

Look for the sensor at the state page. It should be called “binary_sensor.smart_implant_6”.

I put binary_sensor.smart_implant_6 in the Lovelace. Then, it just shows “Door closed and On”. I don’t know why it so hard to make it show the open and close.

You’ve missed out device_class: door in your binary_sensor definition

2 Likes

Finally, it working. Thank everyone.

Can you show your entire code for that and where did you put it? Sitting in the same boat with a Telldus Door sensor.

Here is the entire code that I used.

binary_sensor:
  - platform: template
    sensors:
      smart_implant_1_6:
        friendly_name: Back Door
        device_class: door
        value_template: "{{ is_state('switch.smart_implant_1_6', 'off') }}"
      smart_implant_2_6_2:
        friendly_name: Garage Door
        device_class: door
        value_template: "{{ is_state('switch.smart_implant_2_6_2', 'off') }}"
      smart_implant_1_5:
        friendly_name: Main Door
        device_class: door
        value_template: "{{ is_state('switch.smart_implant_1_5', 'off') }}"

I hope it helps.

1 Like

Thanks for the help

I have almost the same problem but I am struggeling with my code. The sensor says unavailable. What have I done wrong with this code?

sensor øvre garasje:
  - platform: template
    sensors:
      ovregarasje:
        value_template: >-
          {% if states('switch.smart_implant_5') | on %}
              Lukket
          {% else %}
              Åpen
          {%- endif %}
        icon_template: '{% if is_state("sensor.ovregarasje", "lukket") %}mdi:garage-variant{% else %}mdi:garage-open-variant{% endif %}'
        friendly_name: "Øvre garasje status"