Home Assistant Auto Recovery Power Controller

Overview

This project was born from an unfortunate real-world experience.

While travelling several thousand miles from home, I was remotely monitoring my Home Assistant installation. Unfortunately, I made the mistake of allowing a software update and the subsequent restart. The Home Assistant host failed to come back online, leaving me with no remote access to my home automation system.

Although this particular failure was caused by a software update, similar situations can occur at any time due to:

  • Home Assistant becoming unresponsive
  • A stalled or crashed hosting PC or Raspberry Pi
  • Internet router lockups
  • Loss of internet connectivity
  • Other unexpected system failures

Without someone physically present to reboot the equipment, remote access can be permanently lost.

This project attempts to provide an automatic recovery mechanism for these situations.

Project Description

The Home Assistant Auto Recovery Power Controller is a standalone ESP32-based device that monitors the health of both Home Assistant and the internet connection. If either appears to have failed for longer than an acceptable period, the controller attempts recovery by briefly interrupting the AC power supply to either the Home Assistant host or the internet router.

The design uses:

  • ESP32 D1 Mini (or many other compatible ESP32 development boards)
  • Two relay outputs
  • Optional status LED
  • 5 V AC-DC power supply module
  • Various passive components and connectors

The device operates independently once powered. Home Assistant and ESPHome are only required to provide the regular heartbeat signal and monitoring information.

How It Works

The ESP32 continuously monitors two independent conditions.

Home Assistant Health

Home Assistant periodically sends a healthy heartbeat signal to the ESP32 using ESPHome.

If this heartbeat is not received within the configured timeout period, the controller assumes that the Home Assistant host has stalled or crashed.

The relay controlling the host computer is then activated, interrupting its AC supply briefly before restoring power to initiate a reboot.

Internet Connectivity

The ESP32 also periodically checks internet connectivity by communicating with an internet time server.

If the time server cannot be reached for longer than the configured timeout, the controller assumes that the router or internet connection has failed.

The router relay is activated, removing power briefly before restoring it, forcing a router reboot.

Independent Recovery

The router and Home Assistant host are monitored independently.

Each has its own recovery timer, retry logic and power interruption cycle.

This allows either device to be restarted without affecting the other unless necessary.

Recovery Mitigation

Simply rebooting equipment whenever a timeout occurs could easily lead to repeated reset cycles.

To prevent this, the firmware includes recovery mitigation.

For example:

  • After the router has been power cycled, sufficient time is allowed for the router to restart, reconnect to the ISP and re-establish the Wi-Fi network.
  • Only after this delay does monitoring of the Home Assistant host resume.
  • Similar timing logic prevents unnecessary repeated recovery attempts.

These delays greatly reduce the possibility of “reset chasing” where one recovery action immediately triggers another.

Monitoring

The project integrates with ESPHome, allowing Home Assistant to display useful operational information.

Typical entities include:

  • Current controller status
  • Home Assistant heartbeat status
  • Internet connectivity status
  • Router power cycle count
  • Host computer power cycle count
  • Timing information
  • Diagnostic values

This makes it easy to monitor long-term reliability while allowing the controller itself to remain fully autonomous.

Status LED

An optional status LED may be fitted.

Once the configured healthy period has been satisfied, the LED slowly pulses to indicate that:

  • Home Assistant heartbeat is healthy
  • Internet connectivity is healthy
  • No recovery action is currently required

This provides a simple visual indication that the system is operating normally.

Relay Configuration

The design uses two active-low relay modules.

A logic LOW output from the ESP32 energises the corresponding relay.

The relays are wired using their Normally Closed (NC) contacts.

Under normal operation:

  • Relays remain de-energised.
  • AC power passes normally through the NC contacts.
  • During a recovery cycle, the relay energises briefly, opening the NC contact and interrupting the AC supply.
  • When the relay is released, power is automatically restored.

This arrangement ensures that, if the controller itself loses power or fails, power continues to be supplied to both the router and the Home Assistant host.

Hardware

The design is intentionally simple.

Typical hardware includes:

  • ESP32 D1 Mini or compatible ESP32 board
  • 5 V dual relay module with optocoupler isolation (active low)
  • 5 V AC-DC power supply module (for example the Hi-Link HLK-15M05C or similar)
  • Optional LED and resistor
  • Screw terminals or suitable connectors
  • Appropriate enclosure

Equivalent components from suppliers such as AliExpress, Amazon or other electronics distributors may be used.

Documentation

This repository includes:

  • Firmware source
  • Circuit diagram (PDF)
  • ESPHome configuration
  • Additional connection documentation describing:
    • ESP32 pin assignments
    • Relay wiring
    • Configuration options
    • Hardware connections

Please refer to these documents during construction.

Safety Notice

WARNING – MAINS VOLTAGE

This project switches AC mains power.

Mains electricity has the potential to cause serious injury, fire, or death.

If you are considering building this project, you must have sufficient knowledge and practical experience of working safely with mains electrical systems.

The constructor is entirely responsible for ensuring that:

  • All mains wiring complies with local electrical regulations.
  • Components are correctly rated for the intended voltage and current.
  • Appropriate fuses or circuit protection are provided.
  • Wiring is of suitable type and current rating.
  • Adequate insulation and creepage distances are maintained.
  • The completed unit is housed within a robust insulated enclosure providing both electrical isolation and mechanical protection.

This project is provided for educational and experimental purposes only.

The author accepts no responsibility for injury, damage, loss of data, equipment failure, fire, or any other consequences resulting from the construction or use of this project.

Motivation

The purpose of this project is not to replace proper system administration or backups.

Instead, it provides one additional layer of resilience for unattended Home Assistant installations where physical access may not always be possible.

For anyone who relies on remote access to their smart home, a simple automatic power-cycle can often be enough to recover from a software crash, hardware lock-up, or router failure without requiring someone to visit the property.