ESPHome - All devices periodically disconnect (see log details)

I have several ESPHome nodes that ALL disconnect at (virtually) the same time at random. They all reconnect after some seconds.

I have recently migrated from Ubuntu/HA to Proxmox. Could there be something amiss with my ESPHome Integration following the snapshot restore from one ‘system’ to another or is this signs of a more fundamental network issue?

Here are the logs for two devices showing (virtually) the same times.

esp32_01 log

[09:13:13][D][sensor:092]: 'esp32_01 WiFi Signal': Sending state -57.00000 dB with 0 decimals of accuracy
WARNING Disconnected from API: Timeout while waiting for message response!
INFO Connecting to esp32_01.local:6053 (192.168.1.207)
INFO Successfully connected to esp32_01.local
[09:13:34][D][api.connection:583]: Client 'Home Assistant 0.114.3 (192.168.1.25)' connected successfully!
[09:13:34][D][time:029]: Synchronized time: Wed Aug 26 09:13:34 2020
[09:13:37][D][api:067]: Disconnecting Home Assistant 0.114.3 (192.168.1.25)
[09:14:09][D][sensor:092]: 'esp32_01 Uptime': Sending state 2015.99097 s with 0 decimals of accuracy

esp32_01 log

[09:13:11][D][sensor:092]: 'Loft Humidity': Sending state 57.30000 % with 1 decimals of accuracy
WARNING Disconnected from API: Timeout while waiting for message response!
INFO Connecting to esp32_02.local:6053 (192.168.1.190)
INFO Successfully connected to esp32_02.local
[09:13:34][D][sensor:092]: 'esp32_02 Uptime': Sending state 1966.03198 s with 0 decimals of accuracy
[09:13:34][D][api:067]: Disconnecting Home Assistant 0.114.3 (192.168.1.25)
[09:13:35][D][api.connection:583]: Client 'Home Assistant 0.114.3 (192.168.1.25)' connected successfully!
[09:13:35][D][time:029]: Synchronized time: Wed Aug 26 09:13:35 2020
[09:13:35][D][xiaomi_ble:161]: Got Xiaomi LYWSDCGQ (58:2D:34:33:B1:85):
[09:13:35][D][xiaomi_ble:164]:   Temperature: 20.4°C
[09:13:35][D][sensor:092]: 'Upstairs Hall Temperature': Sending state 20.40000 °C with 1 decimals of accuracy
[09:13:36][D][api:067]: Disconnecting ESPHome v1.14.5 (192.168.1.25)
[09:13:59][D][xiaomi_ble:161]: Got Xiaomi LYWSDCGQ (58:2D:34:33:AB:4D):
[09:13:59][D][xiaomi_ble:164]:   Temperature: 20.5°C

For info, I have a Unifi network (the UniFi controller is on a Proxmox Container)

Thanks for any help.

Something amiss with your network or the home assistant api. As others are not reporting it my money is on an issue with your network.

Can you set up a ping command on another machine on the network and ping, 1) your router, 2) home assistant?

Check the results around the time your ESPs drop off.

Thanks, that’s a good idea.

I’ve been away all day today but as luck would have it there were no occurrences all day anyway (I have a persistent notification when it does).

I’ll give this a try tomorrow…

I had an issue with this happening after I had installed room-assistant on my rpi that is also running hass. Turns out the on board Bluetooth was clashing with the wired Ethernet controller. I put a usb Bluetooth adapter in and all was good again.

Different problem to you, but effectively the same in the fact it’s certainly network related and not a general issue.

Well it looks like HA is becoming unreachable…

Reply from 192.168.1.25: bytes=32 time<1ms TTL=64
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.1.25: bytes=32 time<1ms TTL=64

I can’t guarantee this is at the same time because I am not sitting here waiting for it to happen but I have caught it twice now so I feel confident.

I’m not sure if this helps…

And your router was still reachable at that time?

Yes it was.

I don’t know if it helps but I have also noticed that my Android tablet seems to give this error at about the same time

Login attempt or request with invalid authentication from 192.168.1.223

This is a known problem with Esphome. Some of the solutions include:

Use static IP addresses for your nodes
Use a fixed/lower band width in your router/wifi
Use a fixed channel in your wifi

Thanks I’ve seen that but I think that relates to random disconnects of individual devices.
For me it is always EVERY device.

I had all my devices disconnect at once several times per day. This fixed the problem.

@tom_l Just for the record I found another NirSoft utility for Ping that gives timestamps (I think there is a NirSoft utility for almost anything!) and here is evidence that only my HA becomes unreachable.

HA Server

27/08/2020 15:45:10	192.168.1.25	0	64	Succeeded	
27/08/2020 15:45:11				Request Timeout	
27/08/2020 15:45:13				Request Timeout	
27/08/2020 15:45:15				Request Timeout	
27/08/2020 15:45:16				Request Timeout	
27/08/2020 15:45:18				Request Timeout	
27/08/2020 15:45:20				Request Timeout	
27/08/2020 15:45:23				Request Timeout	
27/08/2020 15:45:25				Request Timeout	
27/08/2020 15:45:27				Request Timeout	
27/08/2020 15:45:29	192.168.1.25	0	64	Succeeded	

Router

27/08/2020 15:45:10	192.168.1.1	0	64	Succeeded	
27/08/2020 15:45:11	192.168.1.1	0	64	Succeeded	
27/08/2020 15:45:13	192.168.1.1	0	64	Succeeded	
27/08/2020 15:45:15	192.168.1.1	0	64	Succeeded	
27/08/2020 15:45:16	192.168.1.1	11	64	Succeeded	
27/08/2020 15:45:18	192.168.1.1	0	64	Succeeded	
27/08/2020 15:45:20	192.168.1.1	0	64	Succeeded	
27/08/2020 15:45:23	192.168.1.1	0	64	Succeeded	
27/08/2020 15:45:25	192.168.1.1	0	64	Succeeded	
27/08/2020 15:45:27	192.168.1.1	0	64	Succeeded	
27/08/2020 15:45:29	192.168.1.1	0	64	Succeeded	

Ah, ok. Thanks.
Do you know which thing fixed it?

The current docs say:


Some steps that can help with the issue:

  • If you’re using a hidden WiFi network, make sure to enable fast_connect mode in the WiFi configuration (also sometimes helps with non-hidden networks)
  • Give your ESP a static IP.
  • Set the power_save_mode to light in the wifi: config (only helps in some cases, in other it can make things worse). See Power Save Mode.

I am not using a hidden WiFi Network but I have set fast_connect anyway
power_save_mode seems like poor fix if it can make it worse.

I can try a static IP.

Also, did you fix the IP in ESPHome or in the router. (Does it matter?)

Set the IP on the esphome node.

Setting the width of the wifi to 20 mhz and fixed channel instead of auto is what really made a difference for me. In auto mode, the router changes channel and I think that was the main issue for disconnecting all nodes at once

I wanted to thank you for your input.

I have another thread on a related topic but approaching it from a different angle. I posted a thankyou there and tried to copy it here but the forum won’t allow me to post another reply with the same content.

Here is a link to it but TL:DR, I took the nuclear option and rebuilt everything. Seems to be all ok now.