UltraSonic for messuring water level

Hello, ive been having issues with a ultrasonic sensor messuring water, im sure its just a setting i have wrong

with log running, the sensor send back 10-11cm from top of the water(wich is tank full). and from the top of the water line to the bottem of the tank is 100cm and i get back 94% with the config i have

- platform: ultrasonic
    trigger_pin: GPIO23
    echo_pin: GPIO25
    unit_of_measurement: "%"
    accuracy_decimals: 0
    name: "Water Tank Level"
    update_interval: 30s
      - calibrate_linear:
          - 10 -> 100
          - 99.0 -> 0

What values do you get without the filter?

havent tryed, ill try now

[D][ultrasonic.sensor:040]: ‘Water Tank Level’ - Got distance: 0.12 m
[12:17:43][D][sensor:125]: ‘Water Tank Level’: Sending state 0.12022 % with 0 decimals of accuracy

really far out now lol

The values are in meters. You need to adjust the filter to that, because your current filter is in cm.

can i just change how it reads out the messurement, i tryed adding unit_of_measurement but i get a error since i already have it in there as %

You need to change the filter. I think this will work:

      - calibrate_linear:
          - 0.12 -> 100
          - 1.0 -> 0

[ultrasonic.sensor:040]: ‘Water Tank Level’ - Got distance: 0.13 m
[12:36:49][D][sensor:125]: ‘Water Tank Level’: Sending state 99.01988 % with 0 decimals of accuracy

thats way closer, sweet thank you

now i gotta put a ssr on my heater, cuz the thermostat is fooked, and keeping my wellhouse 25c when it only needs to be like 5-8

Hi can you help me please?
I have an ultrasonic sensor, the tank I use for the test is 11.0 cm high, the maximum water level is 9.0 cm (+ 2.0 cm of space between sensor and max level = 11 cm tot)

With max water level (9 cm), in the esphome log it indicates 0.02 m (2 cm).

With min water level (0 cm), in the esphome log it indicates 0.09 m (9 cm).

This is my sensor code, now the level is at max but on homeassistant it returns -0.9 cm

Hi, is the sensor you use capable of measuring short distances? For example a HC-SR04 can measure a minimum distance of 2 cm, and in your case that is needed. Buit this is very close to the limit of the spec and cliud cause false readings.
I would first check the values you get from the sensor. Simplify the lambda function and skip the calibrate_lineair.

  - filter_out: nan
  - lambda: return x

If these values look ok, then you can add the other filters

You are specifying unit as cm, but using a calibrate linear to convert it to a % as well as adding a lambda into the mix. What are you wanting? A % full, or of cm measurement?

I would like the measurement in%, but with those tank parameters that I indicated earlier…