Binary-sensor. Only “on” or “off” need 0 and 1

Hello,

Here I have declared read-contact switch as a binary sensor with the class moister.
If I want to create an automation in Home Assistant, it would be helpful if I got the status 0 or 1. Otherwise I can only react to changing positions on the switch (read contact).

What’s the best thing to do?
Can this be set in the ESphome code or am I doing something wrong with my automation in home-assistant?

Reason:
I need to query multiple level switches… for example:
For one I need the state change On, Off. With the other level switch, however, I don’t need a change of state but rather the state… is it on or is it off… in the automation I can’t select that at all with my binary sensor… there I only see the possibility of a change of state observe…and react to it.

 - platform: gpio
    #pin: GPIO11
    pin:
      pcf8574: pcf8574_hub_2
      # Use pin number 0
      number: 3
      # One of INPUT or OUTPUT
      mode:
        output: true
      inverted: false
    name: UeberlaufWarnschalter_Giesswasserbecken
    id: max_level_giessbecken
    device_class: moisture
    filters:
      - invert:
      - delayed_on: 10ms
      - delayed_off: 200ms

sorry… i take the misstake in Home-assistant… i think my question was stupid… sorry

It is really not clear to me what you are asking or why, but does this help?

The |bool filter will return true/false (1/0) for 'on'/'off'.

1 Like

yes thats helps a lot to know that … thank you!

1 Like