Dry-run protection for the garden pump with Senvolon level sensor & Home Assistant

Dry Run Protection for Garden Pump with Senvolon Level Sensor & Home Assistant

Securing a Cistern with a LiDAR Sensor in Home Assistant

A pump that doesn't know when to quit

A garden pump without dry run protection is a ticking time bomb. If it runs without water, the mechanical seal overheats in seconds. The bearing follows. In the best case, it's an expensive repair; in the worst case, it's a total loss and a withered flowerbed.

The seemingly simple solution is a basic float switch. This works until the float gets stuck, the switch corrodes, or you simply forget that the cistern is only five percent full after a dry August.

An automatic pump control based on a level sensor initially sounds uncomplicated: install the sensor, integrate the values into Home Assistant, define thresholds – done. In practice, however, the reliability of the system is not determined by the automation, but by the quality and suitability of the sensors used.

Detail one: In humid environments, inexpensive ultrasonic sensors lose measurement accuracy. After one to two years of operation in a cistern, condensation damage, altered resonance frequencies, and decreasing reflection sensitivity become apparent. Added to this is a fundamental physical problem: ultrasound measures sound velocity, which is temperature-dependent. An underground cellar cistern fluctuates between 5 °C in winter and 15 °C in summer. Without temperature compensation, systematic measurement errors of several percentage points occur. Dry run protection based on such values is unreliable.

Detail two: Many inexpensive sensors transmit via manufacturer servers. If the cloud service fails, Home Assistant returns 'unavailable'. A naive automation then does nothing. The pump continues to run.

Detail three: A threshold without hysteresis causes the pump to cycle rapidly when the water surface is agitated. This is mechanical stress that damages the pump faster than a single dry-run incident.

This guide shows how to solve this correctly: with a LiDAR sensor that communicates locally via MQTT, with an automation that explicitly treats sensor failure as an error state, and with hysteresis logic that prevents pump cycling.

 

Hardware & Bill of Materials (BOM)

Item

Component

Purpose / Note

1

Senvolon Level Sensor LD WLAN

LiDAR precision, temperature-independent, local MQTT.

2

Optional:
Senvolon Level Sensor LD Bundle: LiDAR sensor with external antenna connection & external 2.4 GHz WLAN antenna

Required for buried concrete cisterns for stable reception.

3

WLAN switching actuator (e.g. Shelly)

Switches the pump based on sensor values.

4

Home Assistant Hub

The control center (Raspberry Pi, HA Green or similar).

5

Spirit level

Essential for exactly horizontal sensor mounting.

 

 

The Technical Implementation


Do you prefer watching videos to reading? Steps 1 to 3 are explained in this YouTube video.

Level Sensor Installation Video


 

Step 1: Mount Sensor

Before touching any software, the mounting must be solid. Errors here are difficult to debug later, and a crookedly mounted sensor produces systematic measurement errors that cannot be calibrated away.

 

Prepare mounting point: Use an angle bracket or a crossbar that sits stably in the shaft access. The sensor must hang horizontally and straight above the water surface. Use a spirit level. Even a slight tilt can falsify the measurement result. The sensor would then measure a longer distance than actually necessary, resulting in a permanent measurement error.

Minimum distance to water surface: 10 cm absolute. For clear rainwater, allow at least 20 cm. Clear water partially transmits light instead of fully reflecting it, making multiple reflections more likely. If mounted too close, you will not get valid readings. The sensor head outside the housing can be rotated 180° (loosen two screws, fasten on the other side) if the installation situation requires it.

WLAN check before final assembly: Before the sensor is permanently installed, establish a connection and read the RSSI value in the sensor's web interface. Below -70 dBm, connection drops are considered likely. Retrofitting an antenna is complex. Therefore: measure first, then seal.

Light cone check before final assembly: The ToF sensor does not have a pinpoint beam. The light cone widens with increasing distance: at 1 m distance, the diameter is 6 cm, at 2 m it is already 12 cm, at 6 m it is 36 cm. Anything that protrudes into this cone – pipes, floats, filling hoses, submersible lines – will be measured and falsify the result. Check the line of sight before final assembly and consistently remove obstacles from the cone.

Underground tank with concrete or steel cover: Such a cover significantly attenuates WLAN signals. The RP-SMA antenna bundle is not a gimmick for this scenario. Route the antenna cable up through the cistern access, mount the antenna externally.

 

Step 2: Integrate sensor into home network

After switching on, the sensor opens its own access point.

  1. Connect to the WLAN "Level Sensor-[ID]" (password: "12345678"). Deactivate mobile data on your smartphone beforehand.
  2. In the browser, go to http://192.168.4.1/wifi.
  3. Select SSID and enter password for your home network, assign a hostname (e.g., "cistern"), save.
  4. The sensor connects to the home network. The assigned IP will be displayed in the bottom left after a successful connection.
  5. Access the sensor web interface: http://[IP-address]. No app download, no platform registration.

 

Fallback: If the sensor loses its WLAN connection, it automatically re-establishes its own access point and is always accessible at 192.168.4.1. The sensor does not disappear without diagnostic options.

Figure 1

 

Step 3: Configure tank parameters in the web interface

All core properties of the sensor are configured via the browser-based frontend. This is the primary configuration method. In the browser, go to http://[IP-address], then select the tank:

 

 Geometry: Choose the appropriate shape (cuboid, vertical cylinder, horizontal cylinder, sphere). For custom tank shapes, a calibration table option or a free formula engine is available.

 Distance to surface: Distance from the sensor to the water surface when completely full, in cm. For clear water, enter at least 20. Measure this value with a tape measure, do not estimate.

 Distance to bottom: Distance from the sensor to the tank bottom, in cm.

Minimum: Minimum alarm threshold, e.g., 10 for 10%. This is the dry-run protection threshold.

HYST min: Hysteresis in percentage points, e.g., 5. The alarm will only clear when the fill level has risen back to 15%. Prevents fluttering with borderline filling.

 

Then Configuration > MQTT:

Broker IP: IP address of the Home Assistant server

Port: 1883

Username: e.g. mqtt_user

Password: corresponding

Sensor Name: cistern (determines all MQTT topics)

Save. The sensor will then connect to the broker.

 

Step 4: Install Mosquitto MQTT Broker in Home Assistant, if not already present

  1. Go to Settings > Add-ons > Add-on Store.
  2. Search for "Mosquitto Broker", click Install, then Start.
  3. Enable "Start on boot".
  4. Create a dedicated MQTT user: Settings > People > Users > Add user.
    1. Name and username: mqtt_user
    2. Assign a strong password and enable "Local user only".

Once setup is complete, the fill level sensor will appear in the overview under "Devices & Services". There, you will immediately see the current readings. The "Alert" entity is particularly helpful: it automatically derives its status from the MIN and HYST_MIN parameters you defined.

 

Figure 2

 

Step 6: Automation: Shutting down the pump in case of dry-run risk

The core of the automation is the "Alert" entity, which calculates its state based on the MIN and HYST_MIN values you configured. As soon as this entity outputs the status "MIN", the system immediately shuts down the pump and sends a notification to your smartphone and to the Home Assistant Dashboard.

alias: Cistern almost empty
description: >
  Shuts down the garden pump if the cistern's fill level falls below the
  configured threshold. Prevents dry running.
triggers:
  - trigger: state
    entity_id:
      - sensor.level_sensor_alert
    to:
      - MIN
      - unavailable
      - unknown
conditions: []
actions:
  - data:
      title: ⚠️ Dry-run protection triggered
      message: >
        Cistern at {{ states('sensor.level_sensor_level') | int }}% (current:
        {{ states('sensor.level_sensor_level') | int }}%). Pump was
        automatically shut down.
      notification_id: trockenlaufschutz
    action: persistent_notification.create
  - action: notify.mobile_app_pixel_8_pro
    data:
      message: >
        Cistern at {{ states('sensor.level_sensor_level') | int }}% (current:
        {{ states('sensor.level_sensor_level') | int }}%). Pump was
        automatically shut down.
      title: ⚠️ Dry-run protection triggered
  - type: turn_off
    device_id: 77d6941f98b5c5bfa363c29b6d1207fb
    entity_id: 267c76857b99807442895b3dcb5fa9d2
    domain: switch
mode: single

Figure 3

 

Step 7: Automation for reactivating the pump

To resume operation after a dry-run shutdown, the system again uses the "Alert" entity as the central control. The logic is based on the MIN and HYST_MIN parameters you defined.

The "MIN" status remains active until the fill level exceeds the threshold defined by HYST_MIN. This hysteresis ensures that the pump is not switched on and off prematurely or at too short intervals due to minimal wave movements on the water surface, which protects the hardware.


alias: Cistern pump can be switched on again
description: >
  Informs when the cistern's fill level rises above the configured
  threshold again. Switches the pump back on
triggers:
  - trigger: state
    entity_id:
      - sensor.level_sensor_alert
conditions:
  - condition: template
    value_template: "{{ states('sensor.level_sensor_alert') not in ['MIN', 'MAX'] }}"
actions:
  - data:
      title: ⚠️ Dry-run protection deactivated
      message: >
        Cistern back at {{ states('sensor.level_sensor_level') | int }}%
        (current: {{ states('sensor.level_sensor_level') | int }}%). Pump was
        automatically switched on.
      notification_id: trockenlaufschutz
    action: persistent_notification.create
  - action: notify.mobile_app_pixel_8_pro
    data:
      message: >
        Cistern back at {{ states('sensor.level_sensor_level') | int }}%
        (current: {{ states('sensor.level_sensor_level') | int }}%). Pump was
        automatically switched on.
      title: ⚠️ Dry-run protection deactivated
  - type: turn_on
    device_id: 77d6941f98b5c5bfa363c29b6d1207fb
    entity_id: 267c76857b99807442895b3dcb5fa9d2
    domain: switch
mode: single

If you prefer more precise control, the automation can be adjusted so that the pump does not start on its own, but merely a notification is sent. Manual reactivation of irrigation can then be conveniently performed via the dashboard presented in the next section.

 

Step 8: Dashboard

This dashboard offers a central control unit: it not only displays the current fill level and pump status, including control options, but also integrates the upcoming weather report and relevant WLAN connection parameters.


views:
  - type: sections
    max_columns: 4
    title: Cistern
    path: zisterne
    icon: mdi:watering-can
    sections:
      - type: grid
        cards:
          - type: heading
            icon: mdi:car-coolant-level
            heading: Fill Level
            heading_style: title
            grid_options:
              columns: 12
              rows: 1
          - type: gauge
            entity: sensor.level_sensor_level
            name: Fill Level
            needle: true
            segments:
              - from: 0
                color: '#EA4335'
              - from: 10
                color: yellow
              - from: 15
                color: '#34A853'
              - from: 85
                color: yellow
              - from: 90
                color: '#EA4335'
            unit: '%'
          - show_name: true
            show_icon: true
            type: button
            icon: mdi:pump
            show_state: true
            name: Water Pump
            icon_height: 50px
            entity: switch.shellypstripg4_e8f60a62ec54_output_2
          - type: tile
            entity: sensor.level_sensor_fluid
            grid_options:
              rows: 1
          - type: vertical-stack
            cards:
              - type: conditional
                conditions:
                  - condition: state
                    entity: sensor.level_sensor_alert
                    state: MIN
                card:
                  type: tile
                  entity: sensor.level_sensor_alert
                  name: 'Alarm Status:'
                  icon: mdi:water-minus
                  color: red
              - type: conditional
                conditions:
                  - condition: state
                    entity: sensor.level_sensor_alert
                    state: MAX
                card:
                  type: tile
                  entity: sensor.level_sensor_alert
                  name: 'Alarm Status:'
                  icon: mdi:water-plus
                  color: red
              - type: conditional
                conditions:
                  - condition: state
                    entity: sensor.level_sensor_alert
                    state: ''
                card:
                  type: tile
                  entity: sensor.level_sensor_alert
                  name: 'Alarm Status: OK'
                  icon: mdi:water-check
                  color: green
            grid_options:
              columns: 6
              rows: auto
          - type: history-graph
            entities:
              - entity: sensor.level_sensor_level
            logarithmic_scale: false
          - type: heading
            icon: mdi:weather-lightning-rainy
            heading: Weather Forecast
            heading_style: title
            grid_options:
              columns: 12
              rows: 1
          - show_current: false
            show_forecast: true
            type: weather-forecast
            entity: weather.forecast_home
            forecast_type: daily
            forecast_slots: 5
            secondary_info_attribute: precipitation_unit
            round_temperature: true
            name: Weather Forecast
          - type: heading
            icon: mdi:wifi
            heading_style: title
            grid_options:
              columns: 12
              rows: 1
            heading: Wi-Fi Connection
          - type: tile
            entity: sensor.level_sensor_ip
          - type: tile
            entity: sensor.level_sensor_rssi
    cards: []
Application example rainwater cistern

Figure 4

 

Physical limits and pitfalls

Minimum distance: Is a hard physical limit. Below 10 cm from the water surface, the sensor does not provide valid readings. For clear rainwater, 20 cm is the safe value.

Light cone diameter: Increases with depth. At 2 m distance, the cone diameter is 12 cm, at 6 m it is 36 cm. Pipes, floats, overflow valves, and immersion lines that protrude into this cone will be measured. Plan the sensor position accordingly.

Horizontal alignment: Tilted mounting extends the light path and changes the reflection angle, leading to systematic measurement errors. The firmware calibration table can only mitigate this, not replace it.

Not for flammable liquids: Do not use for heating oil, diesel, or petrol.

Only for unpressurized containers: Pressure vessels, pressurized hot water tanks, and pneumatic tanks are not valid applications.

 

Troubleshooting: The most common symptoms

 

Symptom

Likely Cause

Fix

Sensor shows unavailable in HA

WLAN connection interrupted or RSSI too weak

Check RSSI in the sensor web interface. Below -70 dBm: install an external antenna. Fallback AP Level Sensor appears when WLAN connection is lost.

Readings jump ±10 cm

Object in the light cone, agitated water surface

Flashlight test: check line of sight. Increase median window in the web interface. Increase READ_INTERVAL.

Automation doesn't switch off the pump

Entity IDs do not match

Developer tools > States: verify the correct entity ID of the socket. Reduce delay_on in the binary sensor to 5 seconds for testing.

Pump switches in short cycles

Hysteresis not configured

Set MINI 10 and HYST_MIN 5 in the sensor. Automation deliberately does not automatically restart the pump.

HA doesn't recognize sensor after MQTT setup

MQTT Discovery deactivated

Settings Devices & Services > MQTT > Configure > Discovery enabled? check.

Sensor consistently shows maximum distance

Light cone hits tank wall instead of water surface

Center sensor, remove obstacles from the light cone.

Entity remains unknown after start

Moving median needs several samples to converge

Wait 2-3 minutes. This is normal on first start.


Why local MQTT is not a nice-to-have here

The LWT (Last Will & Testament) mechanism is the technical basis for the sensor watchdog in automation. If the sensor goes offline, it leaves a predefined offline message with the broker. Home Assistant immediately recognizes this via the availability_topic in the sensor definitions. With cloud-mediated systems, this signal is often delayed or not available at all. The Senvolon LD WLAN publishes directly to the local broker. There is no external dependency and no routing delay. Those who want worldwide access to the measured values can use remote.senvolon.de as an opt-in. Those who remain completely local do not lose any sensor features.

 

Conclusion

This setup is not a tinkering project with an expiry date. A Senvolon level sensor is more durable than ultrasound in humid environments, temperature-independent, and not reliant on sound as a medium. Combined with a local broker, automation logic with hysteresis, and explicit fail-safe in case of sensor failure, a dry-run protection is created that works unattended. If you carry out the installation carefully, check the WLAN RSSI before final assembly, and set the tank parameters correctly once, you will then have protection that works in the background and does not require further maintenance.

Further Links

Senvolon Level Sensor LD WLAN in the shop

Product documentation & operating instructions (linked in the shop)

Questions, experiences, alternative configurations? Share in the Home Assistant Community or contact Senvolon Support directly.