ESPHome switches keep self powering off

I’m having some network issues, and noticed that my wall switches running ESPHome have a blinking light. That’s normal, but based on logs, I can’t quite seem to tell what is the issue.

And worst of all, it keeps powering off after 15 minutes or so, everyone in the household is complaining and I can’t even start to fix my netwokr…

esphome:
  name: esph-toilet-3gang
  friendly_name: Toilet 3 Gang

bk72xx:
  board: cb3s

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "..."

ota:
  - platform: esphome
    password: "..."

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  use_address: 192.168.9.157
  
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Toilet 3 Gang Fallback Hotspot"
    password: "..."

captive_portal:

text_sensor:
  - platform: libretiny
    version:
      name: LibreTiny Version

binary_sensor:
  - platform: gpio
    id: binary_switch_soap_in_toilet
    pin:
      number: P14
      inverted: true
      mode: INPUT_PULLUP
    on_press:
      then:
        - switch.toggle: switch_soap_in_toilet
  - platform: gpio
    id: binary_switch_light_in_walkway
    pin:
      number: P26
      inverted: true
      mode: INPUT_PULLUP
    on_press:
      then:
        - switch.toggle: switch_light_in_walkway
  - platform: gpio
    id: binary_switch_light_in_toilet
    pin:
      number: P24
      inverted: true
      mode: INPUT_PULLUP
    on_press:
      then:
        - switch.toggle: switch_light_in_toilet

switch:
  - platform: gpio
    id: switch_soap_in_toilet
    name: Soap
    pin: P7
  - platform: gpio
    id: switch_light_in_walkway
    name: Walkway
    pin: P8
  - platform: gpio
    id: switch_light_in_toilet
    name: Toilet
    pin: P9

status_led:
  pin:
    number: P6
    inverted: true
INFO ESPHome 2024.11.2
INFO Reading configuration /config/esphome/toilet-3-gang.yaml...
INFO Starting log output from 192.168.9.157 using esphome API
INFO Successfully connected to esph-toilet-3gang @ 192.168.9.157 in 0.112s
INFO Successful handshake with esph-toilet-3gang @ 192.168.9.157 in 0.451s
[20:21:24][I][app:100]: ESPHome version 2024.10.3 compiled on Nov 11 2024, 14:11:12
[20:21:24][C][status_led:019]: Status LED:
[20:21:24][C][status_led:020]:   Pin: 6
[20:21:24][C][wifi:600]: WiFi:
[20:21:24][C][wifi:428]:   Local MAC: C4:82:E1:56:B8:3A
[20:21:24][C][wifi:433]:   SSID: [redacted]
[20:21:24][C][wifi:436]:   IP Address: 192.168.9.157
[20:21:24][C][wifi:439]:   BSSID: [redacted]
[20:21:24][C][wifi:441]:   Hostname: 'esph-toilet-3gang'
[20:21:24][C][wifi:443]:   Signal strength: -63 dB ▂▄▆█
[20:21:24][C][wifi:447]:   Channel: 6
[20:21:24][C][wifi:448]:   Subnet: 255.255.255.0
[20:21:24][C][wifi:449]:   Gateway: 192.168.9.1
[20:21:24][C][wifi:450]:   DNS1: 192.168.9.1
[20:21:24][C][wifi:451]:   DNS2: 192.168.9.1
[20:21:24][C][logger:185]: Logger:
[20:21:24][C][logger:186]:   Level: DEBUG
[20:21:24][C][logger:188]:   Log Baud Rate: 115200
[20:21:24][C][logger:189]:   Hardware UART: UART2
[20:21:24][C][switch.gpio:068]: GPIO Switch 'Soap'
[20:21:24][C][switch.gpio:090]:   Restore Mode: always OFF
[20:21:24][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'binary_switch_soap_in_toilet'
[20:21:24][C][gpio.binary_sensor:016]:   Pin: 14
[20:21:24][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'binary_switch_light_in_walkway'
[20:21:24][C][gpio.binary_sensor:016]:   Pin: 26
[20:21:24][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'binary_switch_light_in_toilet'
[20:21:24][C][gpio.binary_sensor:016]:   Pin: 24
[20:21:24][C][captive_portal:089]: Captive Portal:
[20:21:24][C][mdns:116]: mDNS:
[20:21:24][C][mdns:117]:   Hostname: esph-toilet-3gang
[20:21:24][C][esphome.ota:073]: Over-The-Air updates:
[20:21:24][C][esphome.ota:074]:   Address: 192.168.9.157:8892
[20:21:24][C][esphome.ota:075]:   Version: 2
[20:21:24][C][esphome.ota:078]:   Password configured
[20:21:24][C][safe_mode:018]: Safe Mode:
[20:21:24][C][safe_mode:019]:   Boot considered successful after 60 seconds
[20:21:24][C][safe_mode:021]:   Invoke after 10 boot attempts
[20:21:24][C][safe_mode:022]:   Remain in safe mode for 300 seconds
[20:21:24][C][api:140]: API Server:
[20:21:24][C][api:141]:   Address: 192.168.9.157:6053
[20:21:24][C][api:143]:   Using noise encryption: YES
[20:21:24][C][lt.component:013]: LibreTiny:
[20:21:24][C][lt.component:014]:   Version: v1.7.0 on cb3s, compiled at Nov 11 2024 14:10:43, GCC 10.3.1 (-O1)
[20:21:24][C][lt.component:015]:   Loglevel: 3
[20:21:24][D][text_sensor:064]: 'LibreTiny Version': Sending state 'v1.7.0 on cb3s, compiled at Nov 11 2024 14:10:43, GCC 10.3.1 (-O1)'

Hi, try “reboot_timeout: 0s” in the API call.

That’s where the 15min frequency is coming from

thanks, omg how can this be a default

Question is: do You have Home Assistant ?
If not - just remove api: section - it useless for You.
If yes - need to fix network issues to keep connection from HA to device stable.

1 Like
  1. Yes, I have home assistant.
  2. I only recently started using ESPHome because of tuya chips.
  3. I have never had such misbehavior from Tasmota, how do they prevent this scenario?

Status LED still blinking while connection to WiFi and then from HA is in progress.
If device not added to HA through adding ESPHome integration - HA will not connect to device and reboot_timeout will force reboot after specified timeout.

So, if my HomeAssistant dies, I will have to watch my ESPHome devices power off every 15 minutes until I recover my HA in total darkness???

Use

api:
  reboot_timeout: 0min

to prevent rebooting. Setting to 0min disable rebooting when lost connection to HA.

That can use to prevent rebooting in no WiFi available:

wifi:
  reboot_timeout:  0min
1 Like

I added only api.reboot_timeout: 0min and it creates another headache:

When I bring down my wifi to make changes (10-15 mins), ESPHome decides to blink forever and don’t connect with HA. Now I have to power cycle my whole house?

The choice is really yours how you want your devices to behave in your situation.

How do you want your devices to behave?

You can change the default state on boot to on/off/last if you like using restore_mode.

You could change the reboot time to something longer like 1hr that might better tradeoff self-recovery of devices and reducing reboots?

You may find setting static ip addresses help the devices rejoin the network faster. They should be trying. If they don’t then something is wrong.

You can remove the status led feature if you want.

I would also make sure you are on the latest stable releases of both HA and ESPHome.

I’m trying to point out everything on the table has been a piecemeal hack that does not address the whole situation - there are no good options. Saying the choice is mine sounds like I’m being too demanding.

I want:

  1. the ESPHome devices to NOT turn on me (pun 101% intended) when there are network problems
  2. the ESPHome devices to NOT self destruct their flash

I do not think the above 2 are unreasonable. I estimated the flash will last about 8 years based on usage… replacing the chip or whole switch is a waste of human and material resources, I have multiple daily usage mobiles/computers that lasted longer than 8 years.

I noticed this sometime does happen with beken running esphome.
But not with openbeken, the wifi is rock solid and reconnect instantly once the router reboots

Wifi can never be guaranteed, and my issue isn’t with the wifi, but the behavior of getting back on track.

Out of the box, my openbeken does not reconnect back to the MQTT broker at times. Able to share your openbeken config?

Just the basic mqtt login details, that’s just it really