Snobs76
(Snobs76)
February 3, 2023, 12:52pm
1
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
tylas13
(Tylas13)
February 3, 2023, 1:07pm
2
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:
Snobs76
(Snobs76)
February 3, 2023, 1:28pm
3
This looks easy. Thanks man this option I did not found. Thx man.
Snobs76
(Snobs76)
February 3, 2023, 1:35pm
5
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
tylas13
(Tylas13)
February 3, 2023, 5:17pm
6
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"
tylas13
(Tylas13)
February 3, 2023, 5:22pm
7
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.