Beken BK7231T devices don't automatically reconnect to WiFi

I have several devices (power sockets and switches) that contain a Beken chip and if the WiFi is interrupted for some reason (like when I reboot the WiFi router), they fail to reconnect. I then have to go around the house and power-cycle each device to get them to reconnect to my WiFi.

The module inside all of these devices is a wb2s and is based on a BK7231T.

This is the YAML common to each of these devices:

esphome:
  name: smart-socket-1
  friendly_name: eBlanket east

bk72xx:
  board: wb2s

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "lots of characters"

ota:
  platform: esphome
  password: "more random characters"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Smart-Socket-1 Fallback Hotspot"
    password: "random characters"

captive_portal:

Is there something that I could / should add to the above code that would force the device to try to reconnect to the WiFi?

With the yaml as you have it there, the device should reboot after 15 minutes of the api losing connection… Are you waiting that long?

You can adjust the timeout value - see reboot_timeout: -

And just to explain what is happening.

Your WiFi takes time to come online again and in that time it takes the ESPhome devices have given up and started up their fallback AP and captive portal feature.
After a while in this state and no actions from an user it will restart itself.

What Zoogara suggest is adjusting the time it waits with the fallback AP and captive portal open before it restarts.

The should be an option to set the time for when the fallback AP and captive portal gets activated too and you also have the option to disable it completely, but that will also remove the “emergency” option for changing other settings.

1 Like

Both your explanations (@zoogara & @WallyR) make perfect sense, so I thought I would do a more specific test.

I have a “3-node” mesh WiFi setup, so I power-cycled one of the nodes that had a connected device with a Beken chip in it. The device is a “Tuya MINI Smart Switch WiFi” that I have installed ESPHome on and use to control the ceiling lights in my garage. It is hard-wired to the lights circuit and is hidden in the wall behind the normal light switch.

The lights were already on in the garage when I power-cycled the WiFi node.

  1. The Tuya MINI Smart Switch immediately became offline in ESPHome Builder and stayed that way for 5 hours (until now, as I write this).
  2. The lights in the garage stayed on and are still on some 5 hours later.
  3. The Tuya MINI Smart Switch never went into “AP mode” as I could not see it listed on my phone as an access point at any stage.

It seems to me that the BK7231T inside the Tuya MINI Smart Switch has “hung” at the point of loosing WiFi connectivity and that’s why I have to power-cycle each device to get them back online.

All of the Expressif devices (ESP32’s or ESP8266’s) connected to that WiFi node recovered correctly and were back online almost immediately.

I have a mixture of Expressif and Beken based devices throughout the house and it is only ever the Beken based devices that don’t recover from a WiFi interruption.

Am I seeing a bug in the ESPHome code for the BK7231T that is preventing it from doing a graceful recovery?

Your test looks sound, so you might see a bug.
I do not have a Beken device, so I can not say anything about that chip.

You can flash it with OpenBeken and see if you have the same behaviour.

I noticed with openbeken, this wifi issue doesn’t occur and the connection has been rock solid. Not exactly sure why it only happens with esphome

You might be - yes. Log an issue on Github and see what response you get…