Smart Sump Pump Monitor with ESPHome & Home Assistant

I recently finished a sump pump monitoring project using ESPHome and Home Assistant, and wanted to share the setup and lessons learned in case it helps others designing something similar.


Goals

I wanted a solution that:

  • Tells me where the water level is, not just “dry” or “already flooded”
  • Complements my Aqara leak sensor
  • Counts how many times the pump actually drains
  • Uses simple, reliable, waterproof hardware

Hardware

  • Wemos D1 Mini
  • 2 LEDs
  • Lower float: mounted just below the pump’s normal trigger point
  • Upper float: mounted well above normal high water as an overflow warning
  • Floats mounted to the discharge pipe using 3D-printed brackets and zip ties
  • Simple wiring: GPIO → float → GND (INPUT_PULLUP)

Wiring:


Home Assistant

Dashboard Design
:green_circle: Drained – both floats OFF
:yellow_circle: High – lower float ON
:red_circle: Overflow – upper float ON
:1234: Drain Cycles – counter with double-tap reset


Derived “Drained” State (Green Indicator)
To get a clean “pump just ran / pit is empty” indicator, I added a Template Binary Sensor helper via the UI:

{{ is_state('binary_sensor.sump_pump_sump_rising', 'off')
and is_state('binary_sensor.sump_pump_sump_overflow_risk', 'off') }}

ON → pit drained (green)
OFF → water at or above a float


Esphome config:

captive_portal:
output:
  - platform: gpio
    id: yellow_led
    pin: GPIO13   # D7

  - platform: gpio
    id: red_led
    pin: GPIO4

  - platform: gpio
    id: green_led
    pin: GPIO5    # D1

binary_sensor:
  - platform: gpio
    name: "Sump Rising"
    id: sump_rising
    pin:
      number: GPIO14 #D5
      mode: INPUT_PULLUP
      inverted: false
    filters:
      - delayed_on: 200ms
      - delayed_off: 500ms
    on_press:
      - output.turn_on: yellow_led
    on_release:
      - output.turn_off: yellow_led

  - platform: gpio
    name: "Sump Overflow Risk"
    id: sump_overflow
    pin:
      number: GPIO12 #D6
      mode: INPUT_PULLUP
      inverted: false
    filters:
      - delayed_on: 200ms
      - delayed_off: 500ms
    on_press:
      - output.turn_on: red_led
    on_release:
      - output.turn_off: red_led

  - platform: status
    name: "Sump Pump Online"

Helpers


Drained Template:

{{ is_state('binary_sensor.sump_pump_sump_rising', 'off')
   and is_state('binary_sensor.sump_pump_sump_overflow_risk', 'off') }}

Automations
#Increments the counter every time the lower sensor is on (closed).

alias: Sump pump-  Increment drain cycles
description: ""
triggers:
  - entity_id:
      - binary_sensor.sump_pump_sump_rising
    to:
      - "off"
    trigger: state
    from:
      - "on"
actions:
  - action: counter.increment
    data: {}
    target:
      entity_id: counter.sump_drain_cycles
mode: single

#High water phone notification

alias: Sump Pump – High Water Alert
mode: single
trigger:
  - platform: state
    entity_id: binary_sensor.sump_pump_sump_rising
    to: "on"
    for: "00:00:10"
action:
  - service: notify.mobile_app_xxxxx_s_s22
    data:
      title: "Sump Pump Alert"
      message: "Water reached the high-water float. Check the sump pit."
      data:
        priority: high
        ttl: 0

This setup has gives me more confidence in the sump system than a single “water detected” sensor does.

If you have any ideas on how to improve it or questions, feel free to ask any questions.

1 Like

@nateokane , thank you for sharing your project. I installed a simple sensor in the sump a few years ago. It’s based on an WSP8266 but only uses one float. I like your idea of two floats and will be upgrading my Sump Monitor before winter thaw and spring rains start in March.

1 Like

Everything looks cool for the most part but, if i may make a few recommendations do you??

First thing is I personally would’ve used a single double float switch sensor instead of using 2 individual ones juat for convenience and installation ease. They make these stainless steel double float sensors and ive had a couple in use for a while now and i like them personally FWIW. These double float sensors for if you want a High and a Low level, they come in all sorts of different lengths too.
Double float

Sedond thing is Im not really sure if id agree with needing or use myself and that’s your counter for drain cycles and im not even sure what its purpose is other than just a counter. I would have instead chosen a flow meter and installed it in the outflow hose/pipe and that would give you more useful data because just knowing the pump cycled On/Off and how many times, it doesnt tell you if its still working correctly or potentially if a float sensor is sticking and causing excessive pump cycles or potentially if theres excessive water leaking and that’s the cause for the number of pump cycles. Idk if that makes sense, all im trying to say is as it is currently, the counter isnt able to tell you much useful information based on just an On/Off counter essentially. If you inatead used a flow meter then you could monitor for anything out of the norm, how much water is entering the sump and how quickly and then obviously you can totul up the amount of water being pumped out. Hell, you could even still make a counter from the flow meter based on when water starts/stops flowing through the meter which is the same as what you’re doing now basically.

Another idea/suggestion id suggest that you consider and thats adding some type of audible alert to draw attention in the event things arent working right or for example your pump doesnt turn off for some reason and theres basically no water in there to pump which will eventually burn out that pump. There are lots of examples i could think of too but, you just dont want to eventually find out something failed and youve got 2’ of standing water in your basement as an example… Something I did for my water heater is if any leak sensors get triggered and i fail to respond in HA that i acknowledge theres a leak then it will move onto flsshing red lights in rooms that have smart lights in an effort to get anyones attention and signal theres a problem but, you could lights, audible siren, or ise both as an alert if you wanted.

The last thing id say is the biggest one and an important one. My question first is, why in the loving hell did you use Esphome to create all of your controls and sensor entities and then go over to HA and say, "im gonna go whack and seperate the main device w/controls and sensors and put all the logic/automations in a completely seperate place that adds no benefit and does add lots of potential for failure and reliability issues. By doing that you’ve made it so that if either of the two, wifi or Homeassistant goes down then so does your sump pumps ability to follow your automations/instructions and maybe even do absolutely no pumping even if it desperately needs pumped out but, that depends more on your pump and if you left the built-in float switch inside and didn’t disable it from turning on automatically.

FYI you always want to keep your esphome projects/entities together with the logic/automations that control the esp board projects so that they are even more dependable than HA is and will remain working without internet, local wifi, and HA. Even at the very worst case scenario, you can always access a built-in web-based AP to access controls/sensors, data etc.

Please make your old buddy proud and make those automations using esphome and flash the board again!

Thanks for the thoughtful feedback — I appreciate you taking the time to look through the design and share your experience.

For this build, I intentionally kept the hardware simple and focused on reliable water-level state rather than flow analytics. The drain-cycle counter is meant to confirm successful water removal, not pump performance. Ultimately, I want to know the water level went down, not necessarily how quickly it drained although I could probably create a heuristic for that given how quickly it is filling.

I chose two floats since they have individual failure modes and was a little easier for me to mount on a pipe.

On the ESPHome vs HA split: The pump remains fully autonomous on its internal float, so there’s no pump logic dependent on Wi-Fi or Home Assistant. These sensors are only monitoring water level for sensing purposes, but agree that automating the actual pump would be pretty nuts.

I do like the idea of adding additional alerting (audible/visual) as a future enhancement. That is why I included a phone notification, but it wouldn’t hurt incase I don’t have my phone — good suggestion.

Thanks again for the input!

Where did you get the switch?

On the ESP, why not set a timer when the “full” switch is on to set off an alarm if the sump isn’t draining? (That’s my current plan). If I know it takes five seconds to drain the sump, and ten seconds elapsed and no “empty” condition, then something is wrong.

I had an episode last January when the temperature was in single-digits. The pump discharge froze and blocked any water from leaving. Such an alarm would have notified me long before my wife went to the basement to get dinner from the freezer.

Alternately, watch how long the pump motor runs.

I bought ones identical to the ones below. I don’t remember where exactly I bought them since this is a long time planned project.

Ali Express Link

I never thought of a frozen discharge lines before, but I could total see how that could happen since the water above the check valve is still.

I don’t have a way to detect if the pump is running an theoretically it could stay at the lower float for quite some time if it didn’t accumulate more water. Not having a lower float or a motor sensor is a limitation, but I didn’t want to keep the float submerged and also didn’t want to reach that far down into the pit lol. Lastly, that is what the upper float is for. Theoretically the upper float should NEVER trigger unless there is a big problem.

Appreciate the insight!

Smart switch with power monitoring.

I’m embarrassed I didn’t think of that lol… I was thinking about CT clamps from the ESPHome device which is way more complicated.

I have a bunch of these ‘Thirdreality ZigBee Smart Plug 4 Pack with Real-time Energy Monitoring’. I plan to cut one open to short out the relay contacts to turn it into a power monitor-only device. The relays in these and other smart switches are not rated for inductive loads, and the sump is one place that a relay failure would be bad.

(post deleted by author)

I tried this with the YoLink smart plug that measures “Current”, but like you said the inrush amperage from the pump coming on was too much for it. It didn’t damage it, but also didn’t work. and repurposed it for a washer cycle done notification.

I went back to my longer term solution of using a Functional Devices RIB power sensor (RIB 1 21AJ46) around the hot to the pump. That does take some light electrical work to install. It provides dry contacts when adjusted for the sump pump. I use a YoLink contact sensor to get that out HA but have to believe ESP offers that as well. No batteries or maint for the RIB

That works very reliably to provide not only On/Off but also cycle time. I used high school geometry to measure the volume of my cylindrical sump, subtracted the volume of the pump so can use daily cycles to calc gallons pumped out each day / month in notifications.

https://www.functionaldevices.com/category/RIB-Current-Sensor-Products

1 Like

Thanks for the reminder- I have a clamp-on current sensor from another project that never finished…