tutorial / Dec 3, 2026

Test a Leak Sensor Message in Home Assistant Without Faking a Leak

Use the Template editor to distinguish wet, dry and missing readings before a leak message reaches a household dashboard.

By Stackarr EditorialHome Assistant · Leak sensors · Smart home
Three checks for a leak message: identify the probe, exercise the wording and compare a live reading.
Test what the message says separately from whether the probe works.

The difference between dry and not reporting

A leak probe under a utility sink can answer a narrow question: did its contacts detect moisture? A dashboard that says ‘Dry’ whenever the answer is not ‘Wet’ quietly changes the question. Disconnect the radio bridge and the same reassuring message could appear without a reading. Before putting that wording on a wall tablet, test how it handles silence. The exercise below produces a message in a preview pane, not an alarm, notification or valve command.

In a self-hosted homelab the home server and the sensor bridge may recover at different times after a power cut. Being able to open the dashboard over the LAN does not mean the bridge has supplied a reading. For a moisture-class binary sensor, Home Assistant stores the positive reading as on and the negative reading as off. The binary sensor reference distinguishes those readings from unknown and unavailable. Reserve the word dry for one explicit input, not for everything left over after checking for water.

On means wet, off means dry, and any other reading gets no verdict.
A missing reading is not evidence of a dry floor.

Prerequisites

Use an administrator account on your local Home Assistant instance and a leak probe already paired through its integration. A battery-powered Zigbee sensor may expose several entities with similar names. The battery warning can itself be a binary sensor: checking only the domain does not establish that the value represents water. In Settings > Tools > States, locate the entity for the correct room and check that its device_class attribute is moisture. Copy its entity ID. Do not use the Set state button.

If you do not have a probe yet, the sample test still works. Stop before the live comparison and label your result ‘wording tested, device unverified’. No shell, configuration file, MQTT publish or restart is needed. If the Template editor already contains useful work, copy it somewhere safe before replacing the text.

Setup: rehearse four inputs in the editor

  1. Open Settings > Tools > Template. Use the plain template editor, not the Actions tab. The Tools guide describes the distinction: the template pane renders text, while other tabs can perform actions or change state.
  2. Paste the snippet below. The first line supplies a local sample string; the following lines turn it into a sentence. Keep the quotation marks around each sample so it remains text.
  3. Read the result for off. Change only the first line, replacing off with on, and read it again. You should see two different sentences, each describing what the probe reports rather than promising the entire room is safe.
  4. Repeat with unknown and unavailable. Both should produce the third sentence. Try dry as well: although it sounds reasonable to a person, it is not the stored negative value. The template should decline to interpret it.
jinja
{% set reading = 'off' %}
{% if reading == 'on' %}Probe reports moisture.
{% elif reading == 'off' %}Probe reports dry contacts.
{% else %}No usable moisture reading.
{% endif %}

Verification: compare one live reading

Replace only the first line with {% set reading = states('binary_sensor.utility_sink_leak') %}. Substitute the exact ID copied from States; the name shown here is an example, not a discovery command. The templating guide shows how states() reads an entity by ID. Leave the other lines intact so the live reading passes through the same branches you just checked.

Exercise sample strings first, then read the entity and compare the result with States.
Only the last two checks use live data; none writes to the sensor.

Return to States in a second tab. Compare the stored value there with the rendered sentence at roughly the same moment. If States reads off, the expected sentence mentions dry contacts. If the Zigbee coordinator is offline and States reads unavailable, the expected result is no usable reading. That is a pass for the wording but not a pass for the sensor. Record which part passed. An off value is not proof of recent radio contact or working batteries; this check does not measure freshness.

Troubleshooting

If both samples produce the same result, check which line you edited. A literal off left in the first line ignores the real sensor entirely. If every live test gives the fallback, compare the spelling and domain with the copied ID before diagnosing a radio fault. If the result is a syntax error instead of a sentence, restore the sample block and check the paired delimiters and closing endif. An error is a failed test, not a negative moisture reading.

For a probe near a basement NAS, never pour water near powered equipment to make a dashboard change colour. A manufacturer-approved hardware test away from equipment is a separate task. Likewise, do not force a state in a running household system to exercise the wet branch: an existing automation may respond to the synthetic change.

Recovery and rollback

Restore the editor text you saved, or clear this scratch template if the pane was empty. There is no integration to remove and no valve or notification to reset when you use only these read and preview steps. Keep the three expected sentences alongside the probe ID for a later dashboard change. If you use them in a real notification, test delivery separately: a correct sentence in the editor proves neither that a phone received it nor that anyone heard an alarm.

Verification ledger

Sources and further reading

  1. ToolsHome Assistant · Primary source
  2. TemplatingHome Assistant · Primary source
  3. Binary sensorHome Assistant · Primary source