Binary Sensor: Substitute failing

Hi Guys

I would really appreciate some advice here as to what I am doing wrong.

I am playing with a 48 input KC868 board and want to rename the input states - from just off and on, to Closed and Open for example.

The yaml snippet for that input is below:

binary_sensor:

  • platform: gpio
    name: “Front Door”
    device_class: motion
    filters:
    • delayed_off: 10s
    • substitute:
      • “On → Open”
      • “Off → Closed”
        pin:
        pcf8574: pcf8574_hub_in_1
        number: 0
        mode: INPUT
        inverted: false

When I do “validate”, I get the error below:

Unable to find filter with the name ‘substitute’

What am I doing wrong here!!! I have searched other yaml files on the web to see if the tabs are wrong, spelling or syntax… just cant find any clues.

One thought, that I have not managed to confirm - is “substitute” not valid for a binary_sensor?

Any help is very much appreciated.

Can’t you just open your yaml with notepad and use find-replace…?

Please use the </> tag to format the code, it makes it more readable. Mark all the code and click </>.

Anyway, Substitute is not a valid binary_sensor filter, however, you can just change the device_class to something that reports Open/Close in HA. Like, for instance, device_class: door. :wink:

1 Like

Thanks Zenzay42… confirmation that iuts not valid for a binary sensor is appreciated.

I have quite a few PIR devices that are connected to the same board, so will want them to be “Motion Detected” and “No Motion” - not just open/closed… hence I had copied in device_class:motion (my bad).

Is there a simpler way to get the device state text correct in ESPhome or should I really be doing this within HomeAssistant?

Thanks - I very much appreciate the help.

As shown on the page I linked to above, a device_class of motion will result in Clear/Detected state. You are free to choose a device_class that suits you better. However, there is no easier way to control the reported state in HA.

If none of the device classes suits you, and you want to customize the reported state you will have to create a template sensor in HA (or a text sensor in ESPHome) that uses the state of the binary sensor to determine what to return.

Or use something like card-mod in HA to change the state text.

Thanks Zenzay42 - all sorted now with your help.