Athom Smart Plug V2 is disconnecting every minute

image

Initially, I was using this configuration: athom-configs/athom-smart-plug-v2.yaml at 2ed4e71f389f32036d11606218639ff1c9227b76 · athom-tech/athom-configs · GitHub, but the behavior is the same with the minimal config:

substitutions:
  name: athomplug1
  friendly_name: Athom Plug 1

esphome:
  name: ${name}
  name_add_mac_suffix: false

logger:
  baud_rate: 0
  level: VERY_VERBOSE

esp8266:
  board: esp8285
  restore_from_flash: true

preferences:
  flash_write_interval: 1min

api:

ota:
  password: "xxx"

mdns:
  disabled: false

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

sensor:
  - platform: uptime
    name: "${friendly_name} Uptime Sensor"
  - platform: wifi_signal
    name: $friendly_name WiFi Signal
    update_interval: 60s

switch:
  - platform: gpio
    name: "${friendly_name}"
    pin: GPIO12
    id: relay
    restore_mode: RESTORE_DEFAULT_ON

Error from the HA:

2023-07-26 22:57:54.793 WARNING (MainThread) [aioesphomeapi.connection] athomplug1 @ 172.16.0.57: Connection error occurred: [Errno 104] Connection reset by peer

Log from the ESPHome (very verbose):

[23:00:44][VV][api.service:540]: on_ping_request: PingRequest {}
[23:00:44][VV][api.service:043]: send_ping_response: PingResponse {}
[23:00:45][VV][scheduler:225]: Running interval '' with interval=60000 last_execution=4294946168 (now=38872)
[23:00:47][VV][api.service:540]: on_ping_request: PingRequest {}
[23:00:47][VV][api.service:043]: send_ping_response: PingResponse {}
[23:00:55][VV][scheduler:225]: Running interval 'update' with interval=60000 last_execution=4294956695 (now=49402)
[23:00:55][V][sensor:043]: 'Athom Plug 1 WiFi Signal': Received new state -49.000000
[23:00:55][D][sensor:093]: 'Athom Plug 1 WiFi Signal': Sending state -49.00000 dBm with 0 decimals of accuracy
[23:00:55][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 683989318
  state: -49
  missing_state: NO
}
[23:01:04][VV][api.service:540]: on_ping_request: PingRequest {}
[23:01:04][VV][api.service:043]: send_ping_response: PingResponse {}
[23:01:07][VV][api.service:540]: on_ping_request: PingRequest {}
[23:01:07][VV][api.service:043]: send_ping_response: PingResponse {}
WARNING athomplug1.local: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for athomplug1.local
WARNING Disconnected from API
INFO Successfully connected to athomplug1.local

I see no similar issues with the rest of the devices though they are esp32 based.

preferences:
  flash_write_interval: 1min

This is not something I’ve used before so I’m not aware of the function… Maybe try removing it?

EDIT: I just read up on it and the default is 1min anyway.

How about trying a longer update_interval for the wifi signal sensor?

Changed:

  • update_interval (wifi) to 30s - no changes
  • flash_write_interval to 2min - no changes
  • restore_from_flash to false - no changes

I have no idea what else I can try. The behavior is the same even when the device is not integrated with HA (I see disconnects in the logs console).

Okay, this isn’t a problem with that particular device (athom plug). I’ve just flashed a random esp8266 dev board with esphome and it behaves in the same way.

Did you try already with a lower log level? It’s easily possible to crash a esp8266 when for example a display is attached and setting the log level to very_verbose. :page_with_curl:

Maybe give the default (debug) log level a try or even just set it to info to see if it makes a difference :arrows_counterclockwise:

Yes, I’ve already tried different log levels, and it does not influence disconnects.

Can you get serial logs from this one?

Yes, the logs:

[1B][0;37m[V][sensor:043]: 'Test WiFi Signal': Received new state -69.000000[1B][0m
[1B][0;36m[D][sensor:093]: 'Test WiFi Signal': Sending state -69.00000 dBm with 0 decimals of accuracy[1B][0m
[1B][0;37m[V][sensor:043]: 'Test Uptime Sensor': Received new state 114.971001[1B][0m
[1B][0;36m[D][sensor:093]: 'Test Uptime Sensor': Sending state 114.97100 s with 0 decimals of accuracy[1B][0m
[1B][0;33m[W][api.connection:093]: ESPHome Logs 2023.7.0 (172.16.0.2): Connection reset[1B][0m
[1B][0;37m[V][api:114]: Removing connection to ESPHome Logs 2023.7.0 (172.16.0.2)[1B][0m
ip:172.16.0.205,mask:255.255.255.0,gw:172.16.0.1
[1B][0;37m[V][wifi_esp8266:507]: Event: Got IP static_ip=172.16.0.205 gateway=172.16.0.1 netmask=255.255.255.0[1B][0m
wifi evt: 3
[1B][0;36m[D][api:102]: Accepted 172.16.0.2[1B][0m
[1B][0;33m[W][component:204]: Component api took a long time for an operation (0.28 s).[1B][0m
[1B][0;33m[W][component:205]: Components should block for at most 20-30ms.[1B][0m
[1B][0;37m[V][api.connection:1012]: Hello from client: 'ESPHome Logs 2023.7.0 (172.16.0.2)' | API Version 1.9[1B][0m
[1B][0;36m[D][api.connection:1031]: ESPHome Logs 2023.7.0 (172.16.0.2): Connected successfully[1B][0m
[1B][0;37m[V][sensor:043]: 'Test WiFi Signal': Received new state -63.000000[1B][0m
[1B][0;36m[D][sensor:093]: 'Test WiFi Signal': Sending state -63.00000 dBm with 0 decimals of accuracy[1B][0m
[1B][0;37m[V][sensor:043]: 'Test Uptime Sensor': Received new state 174.970993[1B][0m
[1B][0;36m[D][sensor:093]: 'Test Uptime Sensor': Sending state 174.97099 s with 0 decimals of accuracy[1B][0m

I can’t find a disconnect in the latest serial logs.

Before we got:

Interesting enough that both ends blame the other for the disconnect :grin:

[Errno 104] Connection reset by peer

Do you know if the device restarts? What does the uptime counter do?

No, it doesn’t restart, just reconnects.
I’ve found a lot of similar cases (about 8266) and different suggestions, but in my case, they do to fix the issue.

Very weird. You might want to try to erase the flash of your esp8266 dev board via serial (esptool) and after that flash/install esphome again to this board to be a 100% sure to don’t have any wifi or other configs left.

Also are you using the latest esphome release?

The flash was cleared during the first esphome installation.
ESPHome version is 2023.7.0.

The latest Tasmota also disconnects every 60 sec. I tried tinkering with a router (disabling different modern features) but with no luck.

could try to decrease tx power - maybe that stabilizes your mileage :point_down:

  • output_power (Optional, string): The amount of TX power for the WiFi interface from 8.5dB to 20.5dB. Default for ESP8266 is 20dB, 20.5dB might cause unexpected restarts.

orange-assistant, reduced to 8.5dB, disconnects with the same precise frequency.

NO disconnects after configuring manual_ip, so it’s DHCP that causes the issue.
Right after this, I remembered, that “Lease time” was changed by me during some experiments… and it was set to exactly 60 seconds. No disconnects after changing it to 12 hours.

1 Like