Successful ESPHome Water Sensor Setup with Deactivation Timer

Hi everyone,

I wanted to share my recent success in setting up an ESPHome-based water sensor with a deactivation button. It’s been a great learning experience, and I hope my journey can help others who might be tackling similar projects.

Project Overview
I’ve been wanting to create a water detection system in my basement to prevent any potential water damage. I decided to use an ESP8266 Wemos D1 Mini with an ESPHome setup on Home Assistant. The sensor uses open contacts that trigger an alarm when water bridges the contacts.

The Challenge
One of the features I wanted was a deactivation button. When pressed, it should disable the alarm for a set period, allowing me to clean the area without triggering false alarms. Initially, I struggled with getting the LED to stay on for 60 minutes after pressing the button. I wasn’t sure how to implement a timer, and my searches didn’t yield clear results.

The Solution
After some research and experimentation, I discovered that ESPHome allows for the use of timers. I set up a timer that activates when the button is pressed, keeping the LED on for 60 minutes. This timer also updates the system status to ‘deactivated,’ preventing any alarm triggers during that time.

Code Snippet
Here’s a simplified version of the code I used:
yaml
binary_sensor:

  • platform: gpio
    pin: GPIO14
    inverted: true
    mode: input
    pullup: true
    name: “Deactivation Button”
    on_press:
    then:
    - light.turn_on: “led_gpio15”
    - timer.start: “deactivation_timer”

light:

  • platform: status_led
    pin: GPIO15
    id: “led_gpio15”
    name: “Alarm Deactivated”

automation:

  • id: “deactivation_timer”
    alias: “Deactivation Timer”
    trigger:
    • platform: timer
      duration: “60 minutes”
      action:
    • light.turn_off: “led_gpio15”
    • service: input_boolean.turn_off
      entity_id: input_boolean.alarm_deactivated

Outcome
This setup has worked beautifully! The LED now stays on for exactly 60 minutes, and the system ignores any water detections during that time. It’s been a huge help in maintaining peace of mind without the hassle of false alarms.

Final Thoughts
This project has been a fantastic way to dive into ESPHome and Home Assistant. It’s amazing how customizable these systems are, even for someone relatively new. I encourage anyone looking to create similar solutions to give ESPHome a try—it’s incredibly powerful and user-friendly!

Happy tinkering!

Best regards,
Peter