Tested with Home Assistant 2026.9 and the Senvolon level sensor · As of September 22, 2026
A full rainwater tank feels good in summer. In autumn, it is often wasted potential. If a rainy day with 15 millimeters is on the way and the tank is filled to the brim, the roof water runs straight into the overflow.
Days like that are not the exception. The Klimaatlas NRW (the climate atlas for North Rhine-Westphalia, Germany) counts, as a statewide average for 1991 to 2020, around 24 days a year with more than 10 mm of precipitation and six days with more than 20 mm. On each of them, a full rainwater tank cannot take in another drop.
The countermeasure is called rain retention. In new housing developments, the local development plan often requires retention tanks with a fixed outlet orifice that only lets roof water into the sewer at a throttled rate. Commercial systems go further and empty the tank ahead of forecast rain by the amount that is expected to come in. If you monitor the fill level of your rainwater tank, you can rebuild this with Home Assistant. The forecast from Part 2 already tells you how many liters the rain will bring. What is new is the decision whether that still fits, and where the water goes beforehand: into the house or the garden, where it gets used, or early into a soakaway or the sewer, so that it does not arrive there in the middle of the downpour.
Important context: A rainwater tank with a properly connected overflow takes no harm when it is full. Occasional overflowing is even desirable, because it flushes out the floating layer on the water surface. So this article is not about preventing overflow, but about deciding when it happens and where the water goes beforehand. Tanks without an overflow (IBC containers, rain barrels) are a different matter. There is a separate section for them at the end.
Contents
- Prerequisites
- Architecture Overview
- Building Block 1: Free Capacity
- Building Block 2: Short-Term Forecast (48 Hours)
- Building Block 3: Target Level and Overflow Risk
- Building Block 4: The Automation
- Interaction with the Consumption Counter from Part 2
- If the Rainwater Tank Has No Overflow
- Dashboard
- Settling-In Period and Autumn Effect
- Appendix: New Entities at a Glance
Prerequisites
- Senvolon level sensor as a Wi-Fi fill level display for the rainwater tank, integrated into Home Assistant via MQTT, with the "Home Assistant" option enabled (MQTT Discovery). The guide Integrating the level sensor into Home Assistant shows how to do this.
- The building blocks from Part 2 (rain inflow counter, yield factor and the trigger-based forecast sensor in
templates.yaml). Without the learned yield factor, the forecast cannot be converted into liters. - Optionally, the dry-run protection from Part 1, if the rainwater tank is emptied via the garden pump
- A switchable outlet for the water: an irrigation valve, the garden pump on a smart plug, or a submersible pump that feeds into a soakaway
- A configured weather integration with a daily forecast (here: Met.no)
- The following existing entities:
| Entity | Source | Meaning |
|---|---|---|
sensor.level_sensor_fluid |
Sensor | Fill level in liters |
sensor.level_sensor_alert |
Sensor, used in Part 1 | Alarm entity, MIN means risk of running dry |
sensor.zisterne_ertrag_pro_mm |
Part 2 | Learned liter-per-mm factor |
weather.forecast_home |
Weather integration | Forecast entity |
switch.bewaesserung |
Your setup | Switchable water outlet (adjust the entity ID, for example to the smart plug of the garden pump) |
Architecture Overview
Four new building blocks:
- Free capacity: nominal volume minus current fill level. How many liters still fit in?
- Short-term forecast: rain yield for the next 48 hours in liters. The 7-day forecast from Part 2 is good for planning, but too vague for taking action.
- Target level and risk: a calculated target fill level to which the rainwater tank should be lowered before the rain, plus a binary sensor that reports whether any action is needed at all.
- Automation with three response stages: push notification, bringing irrigation forward, or draining early. You choose what suits your setup.
On top of that comes an emergency stop that halts draining independently of everything else as soon as the minimum fill level is reached or the sensor fails.
Building Block 1: Free Capacity
1.1 Storing Nominal Volume and Minimum Fill Level
Two helpers of type Number (Settings → Devices & services → Helpers → + Create helper → Number):
- Name:
Zisterne Volumen(keep the helper names in German exactly as shown; Home Assistant derives the entity IDs used below from them), Minimum0, Maximum100000, Step10, Unit of measurementL, Display modeInput field. Enter the usable volume up to the overflow edge here, for example6000. - Name:
Zisterne Mindestfüllstand, same settings. The tank is never drained below this level, for example1500.
Entity IDs: input_number.zisterne_volumen and input_number.zisterne_mindestfullstand
Pitfall: Home Assistant replaces German umlauts in the entity ID with the plain base letter, not with "ue". So "Mindestfüllstand" becomes
zisterne_mindestfullstand, and "Regenrückhalt" later becomeszisterne_regenruckhalt_aktiv. All YAML examples in this article use this spelling. If you name your helpers differently, check the IDs under Developer tools → States.

With a maximum of 100,000 liters, the display mode Input field makes sense. With a slider, it is almost impossible to hit a value like 6,000 precisely.
Why a minimum fill level? Weather forecasts can be wrong. If the forecast rain never comes, the rainwater tank should not be empty but keep a reserve. The value should be well above the MIN threshold of the sensor from Part 1, so the pump never gets anywhere near the limit.
1.2 Sensor for Free Capacity
Helpers → + Create helper → "Template" → Template a sensor
- Name:
Zisterne freie Kapazität - State:
{% set volumen = states('input_number.zisterne_volumen') | float(0) %}
{% set fluid = states('sensor.level_sensor_fluid') | float(0) %}
{{ [volumen - fluid, 0] | max | round(0) }}
- Unit of measurement:
L - Device class:
Stored volume, State class:Measurement
The [..., 0] | max catches the case where the sensor briefly reports more than the nominal volume because of ripples on the surface or a generously configured tank geometry.
Pitfall: The obvious device class
Watercannot be combined with the state classMeasurement; Home Assistant then refuses to save.Wateris meant for meters that only count up. For a stock value such as fill level or free capacity,Stored volumeis the right class.
With the device class Stored volume, Home Assistant shows two decimal places, even though the template rounds to whole liters. If you do not want that, open the entity, click the gear icon and set the Display precision to whole numbers.
Building Block 2: Short-Term Forecast (48 Hours)
The sensor from Part 2 (sensor.zisterne_regenertrag_7d) lives in templates.yaml in a trigger-based block. A second sensor is added there that uses the same weather query and only sums up the first two days of the forecast. The complete block then looks like this:
- trigger:
- trigger: time_pattern
hours: "/1"
action:
- action: weather.get_forecasts
target:
entity_id: weather.forecast_home
data:
type: daily
response_variable: forecast_data
sensor:
- name: "Zisterne Regenertrag 7d"
unique_id: zisterne_regenertrag_7d
unit_of_measurement: L
icon: mdi:weather-pouring
state: >
{% set forecast = forecast_data['weather.forecast_home'].forecast %}
{% set regen_mm = forecast[:7] | map(attribute='precipitation') | map('float', 0) | sum %}
{% set ertrag_pro_mm = states('sensor.zisterne_ertrag_pro_mm') | float(30) %}
{{ (regen_mm * ertrag_pro_mm) | round(0) }}
attributes:
regen_mm_7d: >
{% set forecast = forecast_data['weather.forecast_home'].forecast %}
{{ (forecast[:7] | map(attribute='precipitation') | map('float', 0) | sum) | round(1) }}
- name: "Zisterne Regenertrag 48h"
unique_id: zisterne_regenertrag_48h
unit_of_measurement: L
icon: mdi:weather-lightning-rainy
state: >
{% set forecast = forecast_data['weather.forecast_home'].forecast %}
{% set regen_mm = forecast[:2] | map(attribute='precipitation') | map('float', 0) | sum %}
{% set ertrag_pro_mm = states('sensor.zisterne_ertrag_pro_mm') | float(30) %}
{{ (regen_mm * ertrag_pro_mm) | round(0) }}
attributes:
regen_mm_48h: >
{% set forecast = forecast_data['weather.forecast_home'].forecast %}
{{ (forecast[:2] | map(attribute='precipitation') | map('float', 0) | sum) | round(1) }}
No restart is needed. Check the configuration under Developer tools → YAML → Check configuration, then click Template entities in the YAML configuration reloading list. This also picks up trigger-based templates.
At the next full hour, the new sensor appears under Developer tools → States with the attribute regen_mm_48h:

Pitfall:
forecast[:2]contains today and tomorrow. Depending on the weather service, today's entry in the daily forecast only covers the remaining hours. If you look at 8 a.m., you are seeing the next 40 hours, not 48. For the decision "make room or not", that does not matter, because the sensor recalculates every hour.Pitfall: After reloading, the new sensor shows
unknownand only gets a value at the next full hour. If you want to test right away, temporarily set the trigger tominutes: "/2"(then set it back and reload again, otherwise Home Assistant calls the weather API unnecessarily often).
Building Block 3: Target Level and Overflow Risk
3.1 Calculating the Target Level
The target level is the fill level at which the expected rain just about fits in, with a 20 percent safety margin on top of the forecast. However, it must never drop below the minimum fill level.
Helpers → + Create helper → "Template" → Template a sensor
- Name:
Zisterne Zielstand vor Regen - State:
{% set volumen = states('input_number.zisterne_volumen') | float(0) %}
{% set minimum = states('input_number.zisterne_mindestfullstand') | float(0) %}
{% set prognose = states('sensor.zisterne_regenertrag_48h') | float(0) %}
{% set ziel = volumen - (prognose * 1.2) %}
{{ [ziel, minimum] | max | round(0) }}
- Unit of measurement:
L - Device class:
Stored volume, State class:Measurement
The preview at the bottom of the dialog immediately shows which target level the template calculates with your values:

Example: 6,000 L volume, 1,500 L minimum fill level, forecast 1,800 L. Target level = 6,000 minus 2,160 = 3,840 L. If the rainwater tank is currently at 5,200 L, 1,360 L need to go.
The factor of 1.2 is deliberately conservative. If you have calibrated your yield factor over an entire summer and trust the forecast, you can go down to 1.1. If you would rather adjust the factor on the dashboard, create another Number helper for it and replace the
1.2in the template withstates('input_number.zisterne_sicherheitsfaktor') | float(1.2).
3.2 Overflow Risk as a Binary Sensor
Helpers → + Create helper → "Template" → Template a binary sensor
- Name:
Zisterne Überlaufrisiko - State:
{% set fluid = states('sensor.level_sensor_fluid') | float(0) %}
{% set ziel = states('sensor.zisterne_zielstand_vor_regen') | float(0) %}
{% set regen_mm = state_attr('sensor.zisterne_regenertrag_48h', 'regen_mm_48h') | float(0) %}
{{ regen_mm >= 8 and fluid > ziel + 200 }}
- Device class:
Problem
Entity ID: binary_sensor.zisterne_uberlaufrisiko
The template contains two safeguards:
-
regen_mm >= 8: Nothing should happen for drizzle, even if the rainwater tank is full to the brim. The threshold of 8 mm corresponds to a decent rainy day, not a downpour. If you only want to react to real events, set 15 or 20. -
fluid > ziel + 200: a hysteresis of 200 liters. Without it, the sensor would keep switching on and off around the target level as soon as the first draining run pushes the level just below the target and the next forecast puts it just above it again.
Building Block 4: The Automation
4.1 Enable Switch
A helper of type Toggle: Zisterne Regenrückhalt aktiv (entity ID input_boolean.zisterne_regenruckhalt_aktiv). It lets you switch off the logic in winter, while you are away, or for testing, without touching the automation.
4.2 Choosing the Response Stage
Stage 1: Notify only. A push notification states the forecast, the target level and the amount that would have to go; you decide the rest. If your toilet or washing machine is supplied from the rainwater tank, take the notification as a cue to use water there preferentially over the next two days. That makes room and saves drinking water without draining anything. Stage 1 is also the right way to start and watch the forecast for a few weeks.
Stage 2: Bring irrigation forward. The automation opens the valve or starts the garden pump until the target level is reached. This pays off most after a dry spell, when the soil can absorb the water. If heavy rain is coming anyway, the garden gets little out of it, but the space in the rainwater tank is still gained. In autumn, it is worth adding a condition that the soil is not already saturated, for example via a soil moisture sensor.
Stage 3: Drain early. A submersible pump moves the water to wherever the overflow leads, into a soakaway or the sewer, but before the rain instead of in the middle of it. With a combined sewer system, this can do more than it sounds: when the sewer fills up during heavy rain, diluted wastewater flows untreated into streams and rivers through overflow structures. Every liter that has already drained off beforehand is missing from that peak. The same applies to a soakaway, with one caveat: if the overflow also runs into it, the rain hits soil that is already wet, so a separate infiltration area or swale works better. Whether you are allowed to pump deliberately into the sewer is governed by your municipality's drainage regulations.
The automation below is written for Stage 2. For Stage 3, swap the switch for the pump; for Stage 1, keep the first push notification and delete everything after it.
4.3 Creating the Automation
The quickest way is to use the two blueprints. A blueprint is an automation with placeholders: when you create it, Home Assistant asks in a form which sensor, which switch and which weather entity you mean, and you do not have to adjust any entity IDs in the YAML.
Zisterne Platz schaffen vor Regen
Zisterne Ablassen stoppen (Notbremse)
After importing, click the blueprint under Settings → Automations & scenes → Blueprints and select the entities from building blocks 1 to 3. If you want to see or extend the logic, create the automation directly in YAML:
Settings → Automations & scenes → Create automation → Edit in YAML
alias: Zisterne Platz schaffen vor Regen
description: >
Lowers the fill level to the calculated target level ahead of a
forecast rain event. Sends a push notification first and stops at the
target level, on timeout, or when the forecast drops.
triggers:
- trigger: state
entity_id: binary_sensor.zisterne_uberlaufrisiko
to: "on"
for:
minutes: 30
conditions:
- condition: state
entity_id: input_boolean.zisterne_regenruckhalt_aktiv
state: "on"
- condition: time
after: "08:00:00"
before: "20:00:00"
- condition: numeric_state
entity_id: weather.forecast_home
attribute: temperature
above: 3
- condition: not
conditions:
- condition: state
entity_id: sensor.level_sensor_alert
state: MIN
actions:
- variables:
fluid: "{{ states('sensor.level_sensor_fluid') | float(0) | round(0) | int }}"
ziel: "{{ states('sensor.zisterne_zielstand_vor_regen') | float(0) | round(0) | int }}"
ablassen: "{{ fluid - ziel }}"
regen_mm: "{{ state_attr('sensor.zisterne_regenertrag_48h', 'regen_mm_48h') | float(0) }}"
prognose_l: "{{ states('sensor.zisterne_regenertrag_48h') | float(0) | round(0) | int }}"
- action: notify.mobile_app_ihr_smartphone
data:
title: "Rainwater tank: making room"
message: >
{{ regen_mm }} mm of rain expected in the next 48 h, that is around
{{ prognose_l }} L for the rainwater tank. Currently {{ fluid }} L,
target level {{ ziel }} L. Irrigation is starting and will release
{{ ablassen }} L into the garden.
- action: switch.turn_on
target:
entity_id: switch.bewaesserung
- wait_template: >
{{ states('sensor.level_sensor_fluid') | float(0)
<= states('sensor.zisterne_zielstand_vor_regen') | float(0)
or state_attr('sensor.zisterne_regenertrag_48h', 'regen_mm_48h') | float(0) < 8 }}
timeout:
hours: 4
continue_on_timeout: true
- action: switch.turn_off
target:
entity_id: switch.bewaesserung
- action: notify.mobile_app_ihr_smartphone
data:
title: "Rainwater tank: irrigation finished"
message: >
{% set fluid = states('sensor.level_sensor_fluid') | float(0) %}
{% set ziel = states('sensor.zisterne_zielstand_vor_regen') | float(0) %}
Fill level now {{ fluid | round(0) | int }} L.
{% if not wait.completed %}Time limit of 4 h reached, please check the valve and sensor.
{% elif fluid <= ziel %}Target level of {{ ziel | round(0) | int }} L reached.
{% else %}Rain forecast withdrawn, lowering no longer needed.{% endif %}
mode: single
Replace notify.mobile_app_ihr_smartphone with your own notify service (Developer tools → Actions → filter for notify.), and switch.bewaesserung with your own switch.
The conditions and limits in detail:
-
for: 30 minutes: a single outlier in the forecast does not trigger anything. - 8 a.m. to 8 p.m.: the pump only runs when someone would notice if something goes wrong.
- Above 3 °C: frozen ground barely absorbs any water, and a running line in freezing temperatures is a risk of its own. This refers to the outdoor temperature of the weather entity, not the housing temperature of the sensor.
- Alarm not at MIN: in that case, the dry-run protection from Part 1 has locked the pump.
-
wait_templatewith a four-hour time limit: it ends when the target level is reached or the forecast falls below 8 mm, but after four hours at the latest, in case a valve sticks or the sensor fails. The final notification works out the reason itself, becausewait.completedonly says that the condition was met, not which part of it. -
mode: single: two draining runs in parallel could no longer be stopped cleanly.
Pitfall: The obvious approach would be to stop waiting as soon as the overflow risk goes to
off. Because of the hysteresis, however, that already happens at the target level plus 200 liters; in testing, the irrigation stopped 85 liters too early that way. That is why thewait_templatechecks the fill level directly.
4.4 Emergency Stop
A second automation, independent of the first:
alias: Zisterne Ablassen stoppen (Notbremse)
description: >
Switches off the water outlet as soon as the fill level drops below the
minimum or the sensor fails. Also checks when the outlet is switched on,
so nobody waters below the minimum fill level.
triggers:
- trigger: numeric_state
entity_id: sensor.level_sensor_fluid
below: input_number.zisterne_mindestfullstand
- trigger: state
entity_id: sensor.level_sensor_fluid
to:
- unavailable
- unknown
for:
minutes: 5
- trigger: state
entity_id: switch.bewaesserung
to: "on"
conditions:
- condition: state
entity_id: switch.bewaesserung
state: "on"
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.level_sensor_fluid
below: input_number.zisterne_mindestfullstand
- condition: state
entity_id: sensor.level_sensor_fluid
state:
- unavailable
- unknown
actions:
- action: switch.turn_off
target:
entity_id: switch.bewaesserung
- action: notify.mobile_app_ihr_smartphone
data:
title: "Rainwater tank: emergency stop"
message: "Minimum fill level reached or sensor unreachable, water outlet stopped."
mode: single
It kicks in in three cases: when the fill level drops below the minimum fill level, when the sensor delivers no value for five minutes (otherwise the irrigation would keep running until the time limit), and when someone switches on the irrigation while the rainwater tank is already below the minimum. The third trigger is needed because numeric_state only fires at the moment the threshold is crossed. The conditions check every time whether there really is a reason, so a normal switch-on is left alone.
Pitfall: The emergency stop also kicks in if you switch on the same valve by hand or through another irrigation automation. That is intentional: nobody should water below the minimum fill level.
Interaction with the Consumption Counter from Part 2
The consumption counter from Part 2 adds up every drop in fill level. A draining run of 1,360 liters therefore shows up there as consumption and pushes the calculated supply range down.
For Stage 2, that is correct, because the water ended up in the garden. For Stage 3 (draining early into a soakaway or the sewer), it skews the statistics. If you want to keep the two cleanly apart, you can create a third helper counter Zisterne Retention abgegeben and add a condition to the automation "Zisterne Verbrauch tracken" from Part 2 that switch.bewaesserung (or the submersible pump) is currently off (not covered by this test). To get started, it is enough to be aware of the effect.
If the Rainwater Tank Has No Overflow
IBC containers and rain barrels often have no proper overflow. When they are full, the water spills over the rim or backs up in the downpipe. In this case, Stage 1 (push notification) with a much lower threshold makes sense. As a starting point, not specifically tested: regen_mm >= 3 in the binary sensor, a safety factor of 1.5 in the target level, and the notification comes early enough to switch the inflow with a downpipe diverter or empty the barrel by hand. If you have a submersible pump in the barrel, use Stage 3 as described.
Dashboard
An addition to the rainwater tank dashboard from Part 2, as another section:
- type: grid
cards:
- type: heading
heading: Rain Retention
heading_style: title
- type: entities
title: Before the Rain
entities:
- entity: input_boolean.zisterne_regenruckhalt_aktiv
name: Rain retention active
- entity: binary_sensor.zisterne_uberlaufrisiko
name: Action needed
- entity: sensor.zisterne_regenertrag_48h
name: Expected yield (48 h)
- type: attribute
entity: sensor.zisterne_regenertrag_48h
attribute: regen_mm_48h
name: Rain (48 h)
suffix: " mm"
- entity: sensor.zisterne_freie_kapazitat
name: Free capacity
- entity: sensor.zisterne_zielstand_vor_regen
name: Target level before rain
- entity: input_number.zisterne_volumen
name: Nominal volume
- entity: input_number.zisterne_mindestfullstand
name: Minimum fill level

Settling-In Period and Autumn Effect
The logic is ready to use right away if the yield factor from Part 2 has already been learned. If you are only setting up Part 2 now, you will be running on the placeholder value of 30 L/mm for the first few weeks and should stick with Stage 1 during that time.
One point deserves special attention in autumn. The yield factor from Part 2 is a lifetime average. Leaves in the gutter, a clogged filter basket or a mossy roof reduce the real yield, and the learned value only responds to that sluggishly. The forecast then comes out too high, and the rainwater tank is lowered a little more than necessary. Thanks to the minimum fill level, this is harmless, but if you notice that the tank regularly stays below the target after rainy days, clean the gutter first and then check the yield factor.
Conversely: a clean filter before autumn is the simplest way to make sure the rain you made room for actually arrives.
Appendix: New Entities at a Glance
Helpers:
-
input_number.zisterne_volumen: usable volume up to the overflow edge -
input_number.zisterne_mindestfullstand: lower limit, never drained below -
input_boolean.zisterne_regenruckhalt_aktiv: enables the entire logic
Calculated sensors:
-
sensor.zisterne_freie_kapazitat: volume minus fill level -
sensor.zisterne_regenertrag_48h: expected rain yield for the next two days in liters, attributeregen_mm_48h -
sensor.zisterne_zielstand_vor_regen: fill level to lower the tank to before the rain -
binary_sensor.zisterne_uberlaufrisiko: action needed yes/no, with threshold and hysteresis
Automations:
- Zisterne Platz schaffen vor Regen: push notification, irrigation/pump down to the target level, time limit 4 h
- Zisterne Ablassen stoppen (Notbremse): stops at the minimum fill level, on sensor failure, or when switched on below the minimum