Home Assistant

Sensor watchdog

When an entity stays unavailable, or stays online and stops updating, cycle the smart plug that powers it. Notify only if that cycle does not bring it back.

Difficulty · BeginnerSetup · 20–40 minutesHA · current stable (blueprint)
Get the pack · from $19Have us set it up

Some hardware links on this page are affiliate links. As an Amazon Associate I earn from qualifying purchases. We may earn a commission if you buy through them, at no extra cost to you. See the affiliate disclosure.

Some devices fail by going unavailable. Others fail by sitting there, still “on,” repeating the last value. A presence sensor stuck on occupied leaves the lights up all night. A temperature node that stops publishing looks fine on a dashboard and quietly breaks every automation that trusts it. Both failures have the same hardware fix when the device is on a smart plug: power it off, wait, power it on.

This pack watches the entities you name. An unavailable or unknown state that lasts through a tolerance starts a cycle. A heartbeat timer, restarted whenever one of those entities actually changes, starts the same cycle if it is allowed to finish. One recovery path serves both, with a cooldown so a flapping device is not rebooted in a loop. A phone notification goes out only when the device is still bad after the plug has come back.

Entity ids are blueprint inputs. Do not publish a live device list.

Offline devices report builds a list of what is down. Self-healing integration reload reloads a Home Assistant config entry. Low battery alerts watches a battery percentage. This pack is the one that clicks a plug. Sensor failover keeps a number flowing to other automations while you would rather not reboot the sensor. Use failover for a reading that has a spare. Use the watchdog for a box you can power-cycle.

What problem it solves

You want a frozen or dropped device back without standing at the outlet, and you want silence when the cycle worked.

How it works

  1. Unavailable — a state trigger to unavailable or unknown, with for: set to the tolerance (pack default 2 minutes). A Zigbee blink that recovers in a few seconds does not qualify.
  2. Frozen — a timer helper is the heartbeat. Every state change of a watched entity to a real value restarts it. If the timer finishes, nothing has reported inside the window. Size the timer longer than the sensor’s normal gap: a node that publishes once a minute wants a timer of several minutes, so one skipped packet is not a reboot.
  3. One cycle — switch.turn_off the recovery plug, wait (pack default 10 seconds), switch.turn_on. An input_datetime records the attempt. A new trigger inside the cooldown (pack default 15 minutes) is ignored. Unavailable and frozen share this path so the two detectors cannot cycle the plug twice.
  4. Gates — for the first few minutes after homeassistant.start, recovery is skipped. Devices look offline while they reconnect, and a boot should not power-cycle the house. Freeze detection also requires an active-hours window, so a motion sensor that is quiet overnight is left alone. Leave the window open for a sensor that must report around the clock.
  5. Failure only — after the plug is back on, wait a settle period (pack default 3 minutes). If an entity is still unavailable, or the heartbeat was never restarted, run the notify action. A cycle that worked sends nothing.
  6. Optional extras — a time trigger can cycle the plug once a day for a device you already know wedges on a schedule. A separate option turns the plug back on if something else switched it off, so the watched device is not left dark. Leave that option off when you want the outlet to stay off.

The recovery plug has to be the supply for the device you are watching. Pointing it at the outlet that feeds Home Assistant, the coordinator, or the network the server needs will take the watchdog down with the target.

Hardware notes

  • Plug. Any switch you can turn off and on from Home Assistant. The linked plug is a 15 A outlet. Read the nameplate of whatever is plugged in. A presence sensor or a small ESP32 supply is a light load. A heater, a pump, or a charger that exceeds the plug is a different circuit.
  • What you can recover. The device has to actually reboot when its mains drops. A battery sensor ignores the plug. A device whose “off” state is a software toggle, with mains still present, will not reboot either.
  • Heartbeat length. Open the sensor’s history. The gap between real updates is the number to beat. Set the timer to a few times that gap. A presence entity that can legitimately hold one state for hours needs the active-hours window, or a second entity from the same device (illuminance next to presence) so either update counts as life.

Snippet

The pack ships a blueprint. Inputs replace the live entities, the plug, and the timer.

mode: single
max_exceeded: silent

trigger:
  - platform: state
    entity_id: !input watched_entities
    to:
      - unavailable
      - unknown
    for: !input unavailable_for
    id: offline
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: !input heartbeat_timer
    id: frozen

action:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ now() - as_datetime(states('input_datetime.watchdog_last_cycle')) > timedelta(minutes=15) }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id: !input recovery_plug
          - delay: "00:00:10"
          - action: switch.turn_on
            target:
              entity_id: !input recovery_plug

watched_entities, unavailable_for, heartbeat_timer, and recovery_plug are blueprint inputs. The full blueprint also restarts the timer on a real state change, holds recovery after a Home Assistant start, limits the freeze trigger to the active-hours window, and notifies only if the settle check still fails. The cooldown above is the pack default of 15 minutes, stored in input_datetime.watchdog_last_cycle.

Setup outline

  1. Put the device on a smart plug that Home Assistant can switch. Create a timer helper for the heartbeat, restored across restarts.
  2. Import the blueprint. Select the entities that prove the device is alive, the plug, the timer, the unavailable tolerance, and a notify target.
  3. Set the heartbeat longer than the normal update gap. Set active hours if a quiet night is normal for this sensor. Leave the start-up hold at a few minutes.
  4. Unplug the device by turning the switch off in Developer Tools, wait out the tolerance, and confirm the blueprint turns it back on. Plug the notify action into a test by leaving the device unplugged at the wall so the cycle cannot succeed, and confirm one failure message after the settle period.
  5. Optional: set a daily time for a preventive cycle, and decide whether a manual off should be turned back on.

Troubleshooting

  • It cycles every sensor at boot. The start-up hold is shorter than the time your devices take to reconnect. Lengthen it. The unavailable tolerance is a second cushion.
  • A quiet night reboots a motion sensor. Freeze detection is running outside the hours that sensor is supposed to move. Set the active-hours window, or add an entity that updates overnight.
  • A chatty sensor never looks frozen. Something else on the same device is still updating, and that update restarts the heartbeat. Watch only the entities you care about.
  • The plug clicks off and stays off. The on step targeted a different entity, or the plug’s integration drops the command when the radio is the thing you just powered down. The recovery plug has to be a different device from the one losing power. A Zigbee plug that is the parent router of the sensor can strand both.
  • Notifications on every success. The settle check treats “still starting” as failure. Lengthen the settle period until a healthy boot finishes inside it.
  • Home Assistant itself went down. The recovery plug is on the server’s outlet, or on the only mains path to the coordinator. Move the plug to the fringe device.

Credits

Based on the community blueprint Sensor Watchdog and the blueprint in TheThinkingHome/Automations. This write-up is an original overview of the unavailable check, the heartbeat timer, and a single cooldown-gated power cycle.

Changelog

v1.0 · Oct 25, 2026: First publish.