Water level automation

Hello I am using esphome to detect the water level in my automatic plant watering system. I’ve also setup an automation to send me a message whenever the tank is empty.

- alias: Plant water tank empty
  initial_state: on
  trigger:
    platform: state
    entity_id: binary_sensor.plant_tank
    to: "off"
    for:
      seconds: 200
  action:
  - service: notify.mobile_app_xxxx
    data:
      title: "Attention"
      message: "{{ states(\"sensor.date_time\") }} Water tank empty!!"

So when the tank is empy the binary_sensor goes to off and after 200 seconds a message is sent. The problem is whenever the esphome device has a severed connection and becomes unavaliable, the state of the binary_sensor goes to “unavaliable” too. So when it comes back online. The automation is triggered after 200 seconds and sends another message.
Is there a way to fix this?

Have you tried specifying a “from” in addition to a “to”, i.e.

  trigger:
    platform: state
    entity_id: binary_sensor.plant_tank
    from: "on"
    to: "off"
    for:
      seconds: 200
1 Like

That should to it. Thank you.

Hi @sendorm
I am trying to do the same thing… Monitor the water level i my aquarium

Would you mind sharing how you did it? Hardware, configurations, instructions?

I mainly use ESPHome for the water level sensor.

switch:
  - platform: gpio
    id: sulama
    restore_mode: ALWAYS_OFF
    pin: 
      number: GPIO23
      inverted: true
    name: "Water Pump On"

  - platform: restart
    name: "Plant Water Restart"

    
binary_sensor:
  - platform: gpio
    pin: 
      number: GPIO21
      mode: INPUT_PULLUP
    filters:
    - delayed_off: 500ms
    - delayed_on: 500ms
    name: "Plant Water Level"
    device_class: moisture

Just connect the gpio pin to a relay which in turns controls a AC pump. For water level monitoring I am using something like this:

If you are only interested in the water level sensor this will not be relevant but for any one interested a digital relay is much more robust for the problem.

1 Like

Thanks for this.
I have ordered the components and my reach back out once they arrive

Hi. Im really interested in your setup. Do you mind sharing pictures of the connection between the relay, esp32 and the float switch?

It would be a great help. Thanks

I do a similar thing but for the water level in my pool. However, in that particular case, I am using a Fibaro ZWave Smart Implant instead of an ESP-based device. I don’t only get a warning but the automation actually adds water to the pool automatically.

You can connect the float switch to any pin on the esp and woth ground.

For the relay the same thing. Connect the control pin to any pin you want. Then connect to ground and 5V.

Nothing special.

1 Like