This project was born out of necessity; in my cellar I have two drainage hols with a pump to prevent my cellar gets wet. This installation was installed in 2001. Last winter the pumps needed to get back in action after some time of inactivity but the vertical pump floats appeared to be a bit sticky and their operating became unreliable.
I deactivated these floats (just turning them upside down) and replaced it with the combi:
- Smart Switch; any smart switch will do provided they work with HA and have a reliable connection
- Water Leak Sensor; again more choices here, any water leak or door sensors will do the trick.
- 1 automation
After implementing this project the pumps can mange (if desired) a longer on/off level than a standard pump float.
For the sensor I am using a Zigbee Waterleak Sensor (TS0207 / _TZ3000_upgcbody). This sensor works in Z2M flawlessly and based upon the pump activity over the last 4 months this was around 86,000 times (the battery is still on 100%, but to be honest not sure if I ever changed these, anyone same experience with this sensor?)
I did replace the small sensor with an “eurostekker” (preferred a waterproof one) because this original sensor can suffer from capillary working between the two small polls (if also the plastic get wet).
We only need 1 automation to turn it on, off or spot for errors:
- On: just when it gets wet
- Off: based upon experience turn switch off after x seconds
- error: should handle unavailable sensor due to low battery or always wet (I really like the “not_to” option).
alias: Drainage Pump Trap
description: "on/off/error actions "
trigger:
- platform: state
entity_id:
- binary_sensor.drainage_pomp_trap_water_leak
for:
hours: 0
minutes: 0
seconds: 0
id: go2on
to: "on"
- platform: state
entity_id:
- switch.smart_plug_drainage_pomp_trap
for:
hours: 0
minutes: 0
seconds: 7
id: go2off
to: "on"
- platform: state
entity_id:
- binary_sensor.drainage_pomp_trap_water_leak
not_to: "off"
for:
hours: 0
minutes: 0
seconds: 15
id: error
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- go2on
sequence:
- service: switch.turn_on
metadata: {}
data: {}
target:
entity_id:
- switch.smart_plug_drainage_pomp_trap
- conditions:
- condition: trigger
id:
- go2off
sequence:
- service: switch.turn_off
target:
entity_id: switch.smart_plug_drainage_pomp_trap
data: {}
- conditions:
- condition: trigger
id:
- error
sequence:
- service: notify.notify_mail
data:
message: Is the sensor of Drainage Pump Trap still working?
title: Pump (Trap) inactivity?
enabled: true
mode: single
Also created a historical stats sensor which calculate the “running” hourly total . This give a better result than total activity each hour (at least in this situation).
ERRETA: viewing the HA logs I noticed my original line with (“now().replace(hour=now().hour-1)”) was creating too much lines due to error:
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 588, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ValueError: hour must be in 0..23
Replaced it with the new line (“now() - timedelta(hours=1)”")
- platform: history_stats
name: Drainage Pomp Trap Frequency
unique_id: 20240428_001
entity_id: binary_sensor.drainage_pomp_trap_water_leak
state: "on"
type: count
start: "{{now() - timedelta(hours=1)}}"
end: "{{ now() }}"
Giving the following result:
That’s all, hope you like it