Hi!
I have an ESPHome ultrasonic sensor that use the calibrate_linear
to convert distance to percent:
- platform: ultrasonic
trigger_pin: GPIO18
echo_pin: GPIO19
name: "Silo"
unit_of_measurement: "%"
accuracy_decimals: 0
filters:
- median:
update_interval: 10s
- calibrate_linear:
method: least_squares
datapoints:
- 0.0 -> 100
- 0.65 -> 0.0
When the tank is full (distance from the sensor is 0 cm.) it is 100%. When it is empty (distance is 65 cm.) it is 0%. This works fine for my needs.
However, I would like to create a template sensor for Home Assistant (not using ESPHome) that do the same conversion for another sensor also measuring distance.
I can’t find any documentation if the calibrate_linear
feature is available for a template sensor.
What would be the easiest way of creating a template sensor doing this kind of conversion?