I have an ultrasonic sensor monitoring my watersoftener salt level hooked up to an ESP8266 with ESPHome. Has been working fine for a few years, but on updating to 2023.12.0 I am getting a compile error:
sensor.ultrasonic: [source <unicode string>:61]
Pin 5 is used in multiple places.
platform: ultrasonic
trigger_pin:
number: 5
mode:
output: True
input: False
open_drain: False
pullup: False
pulldown: False
analog: False
inverted: False
echo_pin:
number: 4
mode:
input: True
output: False
open_drain: False
pullup: False
pulldown: False
analog: False
inverted: False
name: Salt level in percent
update_interval: 5s
filters:
- lambda: !lambda |-
return (0.42-x)*(100/0.42);
unit_of_measurement: %
disabled_by_default: False
force_update: False
icon: mdi:arrow-expand-vertical
accuracy_decimals: 2
state_class: measurement
timeout: 2.0
pulse_time: 10us
sensor.ultrasonic: [source <unicode string>:73]
Pin 5 is used in multiple places.
platform: ultrasonic
trigger_pin:
number: 5
mode:
output: True
input: False
open_drain: False
pullup: False
pulldown: False
analog: False
inverted: False
echo_pin:
number: 4
mode:
input: True
output: False
open_drain: False
pullup: False
pulldown: False
analog: False
inverted: False
name: Salt level in cm
update_interval: 5s
filters:
- lambda: !lambda |-
return (0.42-x)*100;
unit_of_measurement: cm
disabled_by_default: False
force_update: False
icon: mdi:arrow-expand-vertical
accuracy_decimals: 2
state_class: measurement
timeout: 2.0
pulse_time: 10us
Pin 4 is used in multiple places
Pin 4 is used in multiple places
I am presuming that this is because I use the same pins to give me HA sensors reporting in both cm and %:
sensor:
- platform: ultrasonic
trigger_pin: D1
echo_pin: D2
name: "Salt level in percent"
update_interval: 5s
filters:
# Calculates in %
# Replace 0.42 by the height of your container. From the sensor to the bottom.
# I used this website to know how I should multiply my values :https://www.skillsyouneed.com/num/percent-change.html
- lambda: return (0.42-x)*(100/0.42);
unit_of_measurement: "%"
- platform: ultrasonic
trigger_pin: D1
echo_pin: D2
name: "Salt level in cm"
update_interval: 5s
filters:
# Replace the 0.42 by the height of your container. From the sensor to the bottom.
# I multiplied by 100 in order to get CM since the sensor works in meters
- lambda: return (0.42-x)*100;
unit_of_measurement: "cm"
Is there any way in the new version that I can keep the sensor logic on the device itself, or do I need to remove the translation to % and cm to my HA config?