Change return Value from ON to Ok or similar

Hello,

I have a working binary sensor. If button ist pressed it sends on and if released off. The sensor check the water level on a tank for a plant. The goal is, to sent instead of on and off to ok and empty or someting else. But how do change the return values in esphome ?

BR
Sascha

I have used this type of remapping in my ESPHome components before

# Example configuration entry
- platform: template
  # ...
  filters:
    - map:
      - on -> full
      - off -> empty

You can find more detail here:

This looks easy. Thanks man this option I did not found. Thx man.

binary_sensor:        
  - platform: gpio
    id: waterlevel_sensor
    name: Wassterstand
    icon: mdi:water-alert
    pin:
      number: D2
      mode: INPUT_PULLUP
      inverted: True
    filters:
      - map:
        - on -> full
        - off -> empty

    on_release:
      - if:
          condition:
            - switch.is_on: prelay
          then:
            - switch.turn_off: prelay
   
    on_press:
      - if:
          condition:
            - sensor.in_range:
                id: erdbeeren_moist_sensor
                below: 70
          then:
            - logger.log: Water filled up, moisture low, watering
            - delay: 10s
            - switch.turn_on: prelay
            - delay: 15s
            - switch.turn_off: prelay

Sadly it did not work.

  filters: 
    - 
      Unable to find filter with the name 'map'.
      map: 
        - on -> full
        - off -> empty

You would have to change ‘on’ and ‘off’ with the the exact output of your sensor data, and the ‘full/empty’ you can change to your liking.

Another option is to use Substitution instead:

# Example configuration entry
- platform: template
  # ...
  filters:
    - substitute:
      - "suf -> foo"
      - "pre -> bar"

Hey, I totally forgot! Map is set up to replace a list of known text list, so it wouldn’t work in this case. Substitution will hopefully work, it’s been a while since I edited my sensors.