Notes / esphomeesp8266home-assistantiot
ESPHome device reboots every 15 minutes: "[E][api] No clients; rebooting"
An ESPHome node with no Home Assistant connected rebooted about every 15 minutes, logging "No clients; rebooting". The api component has its own reboot_timeout (default 15min) that fires when no API client connects. Setting reboot_timeout to 0s under api: stopped the reboots.
Symptoms #
An ESP8266 running ESPHome rebooted roughly every 15 minutes. It joined Wi-Fi normally, then restarted. This happened while it was being developed on the bench, before any Home Assistant instance was connecting to it.
The log line just before each restart:
text[E][api:127]: No clients; rebooting
Because the device was on a test network at the time, the first suspect was Wi-Fi. It was not Wi-Fi.
Root cause #
The native api: component has its own reboot_timeout, separate from the one in
wifi:. If no API client (normally Home Assistant) connects within that time, the node
reboots on purpose. The ESPHome docs describe it as:
The amount of time to wait before rebooting when no client connects to the API. This is needed because sometimes the low level ESP functions report that the ESP is connected to the network, when in fact it is not - only a full reboot fixes it. Can be disabled by setting this to
0s. Defaults to15min.
So any ESPHome node that includes api: but that no Home Assistant ever talks to (bench
testing, a device you control only through web_server:, a network Home Assistant can't
reach) will restart every 15 minutes, and the log says so in plain words.
Fix #
Set the API reboot timeout to 0s (disabled):
yamlapi:
encryption:
key: !secret api_encryption_key
reboot_timeout: 0s
After reflashing, the node stayed up (no further reboots on the bench).
On this device reboot_timeout: 0s was also set under wifi:, so it keeps retrying
Wi-Fi forever instead of rebooting:
yamlwifi:
ssid: "your-ssid"
password: "your-wifi-password"
reboot_timeout: 0s
That second setting was a deliberate choice for this device, not part of the 15-minute
fix: the reboot loop was caused by api: alone.
Caveat: the API timeout exists for a reason. Once Home Assistant is connecting reliably,
you may want to put a non-zero reboot_timeout back under api: so a node whose network
stack has silently wedged recovers on its own.
References #
- ESPHome docs, Native API Component,
reboot_timeout.