Water Level Sensor does not work with ESPHome?

This is what you need to add to yaml file.

I2C For Sensor

i2c:

  • id: bus_a

    sda: 21

    scl: 22

    scan: true

End of I2C For Sensor

All Sensors

sensor:

Start of Custom Sensor

  • platform: custom

    lambda: |-

    auto my_sensor = new WaterLevelSensor();

    App.register_component(my_sensor);

    return {my_sensor};

    sensors:

    name: “Water Level Sensor”

    unit_of_measurement: “%”

    accuracy_decimals: 1