Rainwater tank top-up and pump protection on a level probe
A pressure-based level probe keeps the 3 000 L rainwater tank between 40 % and 85 %, tops up from mains only during the cheap night window, and cuts the pump below 15 % so it never runs dry and burns its seal.
# HearthNodes recipe 24 - rainwater tank top-up
alias: "Water - tank top-up and pump protection"
id: hn_water_tank_topup
description: "Hold 40-85 percent, top up only in the cheap night window"
mode: single
max_exceeded: silent
trigger:
- platform: numeric_state
entity_id: sensor.rain_tank_level
below: 42
id: low
- platform: numeric_state
entity_id: sensor.rain_tank_level
above: 84
id: high
- platform: numeric_state
entity_id: sensor.rain_tank_level
below: 15
id: pump_danger
variables:
topup_valve: valve.mains_topup
pump: switch.tank_pump
pump_cut_pct: 15
pump_restore_pct: 25
topup_stop_pct: 85
max_topup_min: 90
condition:
- condition: template
value_template: >-
{{ (now() - states.sensor.rain_tank_level.last_updated).total_seconds() < 21600 }}
- condition: state
entity_id: binary_sensor.irrigation_running
state: "off"
action:
- choose:
- conditions:
- condition: trigger
id: pump_danger
sequence:
- service: switch.turn_off
target:
entity_id: "{{ pump }}"
- service: input_boolean.turn_on
target:
entity_id: input_boolean.tank_pump_lockout
- service: notify.mobile_app
data:
title: "Tank pump locked out"
message: >-
Level {{ states('sensor.rain_tank_level') }} percent.
Clears above {{ pump_restore_pct }} percent.
- conditions:
- condition: trigger
id: high
sequence:
- service: valve.close_valve
target:
entity_id: "{{ topup_valve }}"
- conditions:
- condition: trigger
id: low
sequence:
- if:
- condition: numeric_state
entity_id: sensor.rain_forecast_24h_mm
below: 2
then:
- service: valve.open_valve
target:
entity_id: "{{ topup_valve }}"
- wait_for_trigger:
- platform: numeric_state
entity_id: sensor.rain_tank_level
above: "{{ topup_stop_pct }}"
timeout:
minutes: "{{ max_topup_min }}"
continue_on_timeout: true
- service: valve.close_valve
target:
entity_id: "{{ topup_valve }}"
else:
- service: logbook.log
data:
name: "top-up deferred"
message: "rain forecast within 24 h"
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.rain_tank_level
above: "{{ pump_restore_pct }}"
sequence:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.tank_pump_lockout
# Probe silent beyond 6 hours -> top-up disabled entirely, pump lockout held: the
# safe state is a partly full tank, never an overflowing one. A reading unchanged
# for 24 hours raises a probe-suspect flag instead of being trusted.
Trigger · numeric_state
sensor.rain_tank_level
Tank level falls below 42 % or rises above 84 %.
Step-by-step
- valve.mains_topupRestrict mains top-up to the cheap four-hour window; the tank's volume means a full top-up takes about 70 minutes at 15 L/min.
open · only during 01:00–05:00 - valve.mains_topupUse both a level stop and a time stop; a level probe that sticks low would otherwise flood the garden.
close at 85 % or after 90 min, whichever first - switch.tank_pumpHard-cut the pump below 15 % and require the level to recover above 25 % before the lockout clears, so it cannot short-cycle around the trip point.
lockout below 15 % - sensor.tank_level_historyLog daily minimum and maximum levels so a slow leak in the tank or a stuck top-up valve becomes visible as a trend.
log · daily min and max
Prefer a pressure probe over an ultrasonic one
In a humid tank, ultrasonic sensors get a false echo from condensation on the transducer face and read a full tank as empty. A pressure probe at the base has no optical path to foul. The trade-off is that it needs a stilling well if the tank can slosh, which is easy on a static rainwater tank.
Keep the pump lockout hysteretic
Cutting at 15 % and restoring at 16 % makes the pump chatter against the trip point for a whole afternoon. A 10-point hysteresis band — cut at 15 %, restore at 25 % — is the difference between a pump that lasts ten years and one that lasts three.
Use both a level stop and a time stop on the top-up
Level alone trusts the probe; time alone over- or under-fills. Both together means a stuck probe cannot flood the garden and a slow fill cannot run all night. Test the time stop deliberately once by setting it to 3 minutes.
Hardware
| Model | Protocol | Link | Role in this chain |
|---|---|---|---|
| Pressure-based level probe (0.1 % full-scale) | wifi |
wired | Measures hydrostatic pressure at the tank base, which is unaffected by foam, condensation or the tank's shape — unlike ultrasonic sensors in a humid tank. |
| Motorised ball valve on the mains top-up line | wifi |
wired | With position feedback, so the automation can prove the valve closed rather than assume it. |
| Tank pump with a dry-run protection input | wifi |
wired | An external dry-run input is the physical backstop if the automation's lockout fails to actuate. |
When it fails
If the level probe stops reporting for more than 6 hours, top-up is disabled entirely and the pump lockout stays engaged — the safe state is a partially full tank, not an overflowing one. If the probe's reading has not changed at all in 24 hours, the automation raises a 'probe suspect' flag rather than trusting a frozen value.