Using a capacitive sensor is possible to “detect” the presence of water within a tank attaching it at a fixed height, so when the water goes down this minimum level the sensor will trigger some alert.
For this purpose I’ve used a XKC-Y25-NPN sensor and a Wemos D1 ESP8266 module plus some few ESPHome code lines.
The wiring requires just three connectors, pay attention to the sensor wires colors, different suppliers could change the order of them:
3D printed case available here
ESPHome code is the following:
esphome: name: plants-water-tank-sensor platform: ESP8266 board: nodemcuv2 # Enable logging logger: # Enable Home Assistant API api: ota: password: "670d70c6dd4ea29b3b9b66b1109dc0d8" wifi: ssid: !secret wifi_ssid password: !secret wifi_password binary_sensor: - platform: gpio pin: number: D2 mode: INPUT_PULLUP name: "Plants Water Tank Low Level" filters: - delayed_on: 10ms
The binary sensor will be available on ESPHome Integration
and usable on any dashboard
alias: Allarme acqua irrigazione description: '' trigger: - type: turned_on platform: device device_id: 107cdcec7a2e43bb990398295828afa5 entity_id: binary_sensor.plants_water_tank_low_level domain: binary_sensor for: hours: 0 minutes: 0 seconds: 2 condition:  action: - service: notify.mobile_app_sm_a525f data: message: Low Level Water mode: single