Esp32 dropped connection

Whether I use MQTT or esphome’s own API both connections are dropped in Homeassistant. Restarting either node or the HA can fix it but that isn’t a solution for the automation platform.

Any more information? What do the logs say? HA/esphomme logs? :see_no_evil:

And what does this hall sensor tells us? :thinking:

This is the logs from HA

2022-11-24 04:01:02.367 INFO (MainThread) [aioesphomeapi.reconnect_logic] Disconnected from ESPHome API for esphome-aquarium-light @ 192.168.18.243
2022-11-24 04:01:15.462 WARNING (MainThread) [aioesphomeapi.reconnect_logic] Can't connect to ESPHome API for esphome-aquarium-light @ 192.168.18.243: Hello timed out

Hall effect sensor is present on the board and its value is constantly changing, if there is flat line, this means no data is being sent to the HA from ESPhome, since HA is refusing connection.

====

19:23:53	[W]	[api.connection:082]	
::FFFF:C0A8:1276: Reading failed: BAD_INDICATOR errno=11

logs from another esphome node.

this one is on old firmware but same issue on latest 2022.11.2

this new value updated is because I deleted the node in HA> integration> and re-added it.

====

Logs from another node. after removing and adding again from integrations.

|19:35:01|[W]|[api.connection:083]|aioesphomeapi (::FFFF:C0A8:12C8): Connection closed|
| --- | --- | --- | --- |
|19:35:01|[D]|[api:102]|Accepted ::FFFF:C0A8:12C8|
|19:35:01|[D]|[api.connection:917]|Home Assistant 2022.11.4 (::FFFF:C0A8:12C8): Connected successfully|
|19:35:02|[D]|[text_sensor:067]|'Current Time': Sending state '19:35:01'|
|19:35:03|[D]|[text_sensor:067]|'Current Time': Sending state '19:35:02'|

What is your wifi connection like?


Direct line of sight hardly few meters from the router.

Connection is lost after 2 hour each time, fix is either restart HA or disable and re-enable the node in HA>integrations

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:545
First occurred: 11:24:08 AM (2 occurrences)
Last logged: 1:27:48 PM

Updating state for sensor.wled_heatindex (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) took 0.707 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
Updating state for sensor.esp32_hall_sensor (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) took 0.472 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+esphome%22
Logger: aioesphomeapi.reconnect_logic
Source: runner.py:119
First occurred: 11:23:37 AM (4 occurrences)
Last logged: 1:16:20 PM

Can't connect to ESPHome API for camera @ 192.168.18.144: Error connecting to ('192.168.18.144', 6053): [Errno 113] Connect call failed ('192.168.18.144', 6053)
Can't connect to ESPHome API for aquariumnode @ 192.168.18.223: Timeout while connecting to ('192.168.18.223', 6053)
Logger: homeassistant.components.mqtt.client
Source: components/mqtt/client.py:704
Integration: MQTT (documentation, issues)
First occurred: 1:27:44 PM (2 occurrences)
Last logged: 1:27:49 PM

Disconnected from MQTT server localhost:1883 (16)
2022-11-28 13:27:54.493 INFO (MainThread) [aioesphomeapi.connection] esphome-aquarium-light @ 192.168.18.243: Error while reading incoming messages: Error while reading data: 0 bytes read on a total of 1 expected bytes
2022-11-28 13:27:54.497 INFO (MainThread) [aioesphomeapi.connection] aquariumnode @ 192.168.18.223: Error while reading incoming messages: Error while reading data: 0 bytes read on a total of 1 expected bytes
2022-11-28 13:27:55.201 INFO (MainThread) [aioesphomeapi.connection] esphome-aquarium-light @ 192.168.18.243: Ping Failed: Error while reading data: 0 bytes read on a total of 1 expected bytes
2022-11-28 13:27:55.202 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/_frame_helper.py", line 70, in write_packet
    await self._writer.drain()
  File "/usr/local/lib/python3.10/asyncio/streams.py", line 372, in drain
    await self._protocol._drain_helper()
  File "/usr/local/lib/python3.10/asyncio/streams.py", line 171, in _drain_helper
    raise ConnectionResetError('Connection lost')
ConnectionResetError: Connection lost

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/connection.py", line 130, in _do_cleanup
    await self._process_task
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/connection.py", line 538, in _process_loop
    await self._handle_internal_messages(msg)
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/connection.py", line 579, in _handle_internal_messages
    await self.send_message(PingResponse())
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/connection.py", line 394, in send_message
    await self._frame_helper.write_packet(
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/_frame_helper.py", line 72, in write_packet
    raise SocketAPIError(f"Error while writing data: {err}") from err
aioesphomeapi.core.SocketAPIError: Error while writing data: Connection lost
2022-11-28 13:27:55.309 INFO (MainThread) [aioesphomeapi.connection] aquariumnode @ 192.168.18.223: Ping Failed: Error while reading data: 0 bytes read on a total of 1 expected bytes

some relevant logs