ESPHome 2024.5.0 brick my ESP devices

Hi All,

For months all devices working perfect. Updated ESPhome to 2024.5.0 and update just one device and its over. (this happend also with a version released in November 2023)

What can I do to find out what this can be?

Here log after its wireless flashed:

INFO ESPHome 2024.5.0
INFO Reading configuration /config/esphome/meek-dressoir.yaml...
INFO Detected timezone 'Europe/Amsterdam'
INFO Generating C++ source...
INFO Compiling app...
Processing meek-dressoir (board: esp01_1m; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
Dependency Graph
|-- ESPAsyncTCP-esphome @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.2.0
|-- DNSServer @ 1.1.1
|-- ESP8266WiFi @ 1.0
|-- ESP8266mDNS @ 1.2
|-- ArduinoJson @ 6.18.5
|-- NeoPixelBus @ 2.7.3
|-- noise-c @ 0.1.4
RAM:   [=====     ]  48.0% (used 39288 bytes from 81920 bytes)
Flash: [======    ]  58.1% (used 594973 bytes from 1023984 bytes)
========================= [SUCCESS] Took 2.07 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.100.207
INFO Uploading /data/build/meek-dressoir/.pioenvs/meek-dressoir/firmware.bin (599120 bytes)
INFO Compressed to 407668 bytes
Uploading: [============================================================] 100% Done...

INFO Upload took 13.49 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.100.207 using esphome API
INFO Successfully connected to meek-dressoir @ 192.168.100.207 in 11.320s
INFO Successful handshake with meek-dressoir @ 192.168.100.207 in 3.028s
[15:36:11][I][app:100]: ESPHome version 2024.5.0 compiled on May 15 2024, 14:37:21
[15:36:16][W][component:237]: Component api took a long time for an operation (287 ms).
[15:36:21][W][component:237]: Component api took a long time for an operation (286 ms).
[15:36:31][W][component:237]: Component api took a long time for an operation (287 ms).
[15:36:44][W][api.connection:106]: : Reading failed: HANDSHAKESTATE_SPLIT_FAILED errno=11

Then try to check log and its connected and disconnected all the time:

INFO ESPHome 2024.5.0
INFO Reading configuration /config/esphome/meek-dressoir.yaml...
INFO Detected timezone 'Europe/Amsterdam'
INFO Starting log output from 192.168.100.207 using esphome API
INFO Successfully connected to meek-dressoir @ 192.168.100.207 in 0.004s
WARNING meek-dressoir @ 192.168.100.207: Connection error occurred: meek-dressoir @ 192.168.100.207: EOF received
WARNING Can't connect to ESPHome API for meek-dressoir @ 192.168.100.207: meek-dressoir @ 192.168.100.207: EOF received (SocketClosedAPIError)
INFO Trying to connect to meek-dressoir @ 192.168.100.207 in the background
INFO Successfully connected to meek-dressoir @ 192.168.100.207 in 0.004s
WARNING meek-dressoir @ 192.168.100.207: Connection error occurred: meek-dressoir @ 192.168.100.207: EOF received
INFO Successfully connected to meek-dressoir @ 192.168.100.207 in 0.005s
WARNING meek-dressoir @ 192.168.100.207: Connection error occurred: meek-dressoir @ 192.168.100.207: EOF received
INFO Successfully connected to meek-dressoir @ 192.168.100.207 in 0.005s
WARNING meek-dressoir @ 192.168.100.207: Connection error occurred: meek-dressoir @ 192.168.100.207: The connection dropped immediately after encrypted hello; Try enabling encryption on the device or turning off encryption on the client (ESPHome Logs 2024.5.0).
INFO Successfully connected to meek-dressoir @ 192.168.100.207 in 0.105s
INFO Successful handshake with meek-dressoir @ 192.168.100.207 in 2.931s
[15:42:04][I][app:100]: ESPHome version 2024.5.0 compiled on May 15 2024, 14:37:21

How old is the config? Are you using an encryption key?

I only suggest this because of your error message:

WARNING meek-dressoir @ 192.168.100.207:
Connection error occurred: meek-dressoir @ 192.168.100.207:
The connection dropped immediately after encrypted hello;
Try enabling encryption on the device or turning off encryption on the client (ESPHome Logs 2024.5.0).
#########################################################
# Below all fixed settings for dressoir PCB
#########################################################
substitutions:
  devicename: meek-dressoir
  friendly: Diningroom
  friendly_switch_1: Dressoir
  friendly_switch_2: Balcony
  ip: 192.168.100.207
  neopixel: GPIO02 # (D4)
  touch_power: GPIO16 # (D0)
  gpio_touch1: GPIO14 # (D5)
  gpio_touch2: GPIO13 # (D7)
  gpio_relay1: GPIO05 # (D1)
  gpio_relay2: GPIO4 # (D2)
  gpio_relay3: GPIO15 # (D8)

#########################################################
# Everything below can be copy/paste without problem
#########################################################
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  reboot_timeout: 0s
  fast_connect: true
  output_power: 20.0
  manual_ip:
    static_ip: ${ip}
    gateway: 192.168.100.1
    subnet: 255.255.255.0
    dns1: 192.168.100.1
  ap:
    ssid: ${devicename}
    password: !secret password
    channel: 4

  on_disconnect:
    - light.turn_on:
        id: neopixel
        red: 1
        green: 1
        blue: 1

    - light.turn_on:
        id: neopixel
        effect: strobe

esphome:
  name: ${devicename}
  on_boot:
    priority: 600
    then:
      - switch.turn_off: touch_power
      - delay: 2s
      - switch.turn_on: touch_power
      - light.turn_on:
          id: neopixel
          red: 1
          green: 1
          blue: 1

esp8266:
  board: esp01_1m
  restore_from_flash: true

api:
  encryption:
    key: !secret api_key
  reboot_timeout: 15min

  on_client_connected:
    - light.turn_on:
        id: neopixel
        red: 1
        green: 1
        blue: 1

    - light.turn_on:
        id: neopixel
        effect: strobe

    - delay: 5s

    - light.turn_on:
        id: neopixel
        effect: none

    - light.turn_on:
        id: neopixel
        red: 1
        green: 0
        blue: 0
        brightness: 100%

    - delay: 5s

    - homeassistant.service:
        service: persistent_notification.create
        data:
          title: "HA - Notification"
          message: "Meek ${friendly} connected again"
          notification_id: "Meek ${friendly}"

time:
  - platform: homeassistant
    id: homeassistant_time

captive_portal:

web_server:
  port: 80

preferences:
  flash_write_interval: 1min

logger:
  level: INFO

ota:
  safe_mode: true
  password: !secret password
  reboot_timeout: 0s

button:
  - platform: factory_reset
    name: "${friendly} - Reset"

switch:
  - platform: safe_mode
    name: "${friendly} - safe mode"
    id: "${friendly}_safe_mode"

sensor:
  - platform: wifi_signal
    id: "wifi_db_signal"
    name: "${friendly} - Wifi Signal"
    update_interval: 5min

  - platform: uptime
    name: "${friendly} - Uptime"
    update_interval: 5min
    
  - platform: template
    name: "${friendly} WiFi Percentage"
    id: wifi_percentage
    entity_category: diagnostic
    state_class: measurement
    update_interval: 10s
    unit_of_measurement: "%"
    accuracy_decimals: 0
    icon: mdi:wifi
    lambda: >
      auto signal = id(wifi_db_signal).state;
      float perc = 0;
      if (signal < -92.0) 
        perc = 100.0; 
      else if (signal > -21.0) 
        perc = 1.0; 
      else 
        perc = round(( -0.0154 * signal * signal )-( 0.3794 * signal ) + 98.182 );

      if(perc <= 0)
        return 0.0;
      else if(perc >= 100)
        return 100.0;
      else
        return perc;

text_sensor:
  - platform: wifi_info
    ip_address:
      name: "${friendly} - IP"
      icon: mdi:lan
    ssid:
      name: "${friendly} - SSID"
      icon: mdi:lan
    bssid:
      name: "${friendly} - BSSID"
      icon: mdi:lan
    mac_address:
      name: "${friendly} - MAC"
      icon: mdi:lan

  - platform: version
    name: "${friendly} - Version"
    hide_timestamp: true

light:
  - platform: neopixelbus
    default_transition_length: 0s
    type: GRB
    variant: 800KBPS
    pin: ${neopixel}
    num_leds: 2
    name: "${friendly_switch_1} - Neopixel All"
    restore_mode: RESTORE_DEFAULT_OFF
    id: neopixel
    effects:
      - strobe:
      - addressable_rainbow:
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_random_twinkle:
      - addressable_flicker:
      - pulse:
          name: "Slow Pulse"
          update_interval: 1s

#########################################################
# Only needed when you use more then 1 neopixel
#########################################################
  - platform: partition
    name: "${friendly_switch_1} - neopixel"
    restore_mode: RESTORE_DEFAULT_OFF
    default_transition_length: 0s
    id: neopixel1
    segments:
      - id: neopixel
        from: 0
        to: 0
    effects:
      - strobe:
      - flicker:
      - addressable_rainbow:
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_random_twinkle:
      - addressable_flicker:
      - pulse:
          name: "Slow Pulse"
          update_interval: 1s
      - addressable_lambda:
          name: "Green Pink"
          update_interval: 100ms
          lambda:
            static int state = 0;
            if (initial_run){
              state = 0;
              it.all() = ESPColor(0,255,0);
            } else {
              it.all() = ESPColor(255, 0, 127);
              if(state==0){
                int i = rand() % it.size();
                it[i] = ESPColor(0,255,0);
                state += 1;
              } else {
                state += 1;
                state = state % 10;
              }
            }
  
  - platform: partition
    name: "${friendly_switch_2} - neopixel"
    restore_mode: RESTORE_DEFAULT_OFF
    default_transition_length: 0s
    id: neopixel2
    segments:
      - id: neopixel
        from: 1
        to: 1
    effects:
      - strobe:
      - flicker:
      - addressable_rainbow:
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_random_twinkle:
      - addressable_flicker:
      - pulse:
          name: "Slow Pulse"
          update_interval: 1s
      - addressable_lambda:
          name: "Green Pink"
          update_interval: 100ms
          lambda:
            static int state = 0;
            if (initial_run){
              state = 0;
              it.all() = ESPColor(0,255,0);
            } else {
              it.all() = ESPColor(255, 0, 127);
              if(state==0){
                int i = rand() % it.size();
                it[i] = ESPColor(0,255,0);
                state += 1;
              } else {
                state += 1;
                state = state % 10;
              }
            }

switch:
  - platform: gpio
    pin: ${touch_power}
    name: "${friendly} - Touch 1 power"
    icon: mdi:electric-switch
    id: touch_power

  - platform: template
    name: "${friendly_switch_1} - Light Switch"
    icon: mdi:nintendo-switch
    restore_mode: RESTORE_DEFAULT_OFF
    id: switch1
    optimistic: true

  - platform: template
    name: "${friendly_switch_1} - Switch longpress"
    restore_mode: RESTORE_DEFAULT_OFF
    id: switch_longpress1
    optimistic: true
    icon: mdi:nintendo-switch

  - platform: template
    name: "${friendly_switch_2} - Light Switch"
    icon: mdi:nintendo-switch
    restore_mode: RESTORE_DEFAULT_OFF
    id: switch2
    optimistic: true

  - platform: template
    name: "${friendly_switch_2} - Switch longpress"
    restore_mode: RESTORE_DEFAULT_OFF
    id: switch_longpress2
    optimistic: true
    icon: mdi:nintendo-switch

  - platform: gpio
    pin: ${gpio_relay1}
    name: "${friendly_switch_1} - Relay"
    icon: mdi:electric-switch

  - platform: gpio
    pin: ${gpio_relay2}
    name: "${friendly_switch_2} - Relay"
    icon: mdi:electric-switch

binary_sensor:
  - platform: gpio
    pin: ${gpio_touch1}
    name: "${friendly_switch_1} - Touch"
    icon: mdi:gesture-tap-button
    on_click:
      - min_length: 10ms
        max_length: 500ms
        then:
          - switch.toggle: switch1
      - min_length: 1000ms
        max_length: 2000ms
        then:
          - switch.toggle: switch_longpress1

  - platform: gpio
    pin: ${gpio_touch2}
    name: "${friendly_switch_2} - Touch"
    on_click:
      - min_length: 10ms
        max_length: 500ms
        then:
          - switch.toggle: switch2
      - min_length: 1000ms
        max_length: 2000ms
        then:
          - switch.toggle: switch_longpress2

I wonder if your on_client_connected sequence is messing things up?

[15:36:11][I][app:100]: ESPHome version 2024.5.0 compiled on May 15 2024, 14:37:21
[15:36:16][W][component:237]: Component api took a long time for an operation (287 ms).
[15:36:21][W][component:237]: Component api took a long time for an operation (286 ms).
[15:36:31][W][component:237]: Component api took a long time for an operation (287 ms).

These timestamps gaps align nicely with the delays you have. Try commenting that out or moving it to a separate automation?

When I check the log with a old ESPhome version (2023.11) next to the latest one this is in the log:

16:10:02	[E]	[json:041]	
Could not allocate memory for JSON document! Requested 872 bytes, largest free heap block: 872 bytes
16:10:25	[E]	[json:041]	
Could not allocate memory for JSON document! Requested 736 bytes, largest free heap block: 736 bytes
16:10:25	[E]	[json:041]	
Could not allocate memory for JSON document! Requested 352 bytes, largest free heap block: 352 bytes

I have comment out the whole part and build new image. See what happen

After rebuild and flash


========================= [SUCCESS] Took 74.18 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.100.207
INFO Uploading /data/build/meek-dressoir/.pioenvs/meek-dressoir/firmware.bin (591936 bytes)
INFO Compressed to 403762 bytes
Uploading: [============================================================] 100% Done...

INFO Upload took 12.09 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.100.207 using esphome API
INFO Successfully connected to meek-dressoir @ 192.168.100.207 in 19.459s
WARNING Can't connect to ESPHome API for meek-dressoir @ 192.168.100.207: Handshake timed out after 30.0s (TimeoutAPIError)
INFO Trying to connect to meek-dressoir @ 192.168.100.207 in the background
WARNING meek-dressoir @ 192.168.100.207: Connection error occurred: meek-dressoir @ 192.168.100.207: Connection lost
INFO Successfully connected to meek-dressoir @ 192.168.100.207 in 0.004s
INFO Successful handshake with meek-dressoir @ 192.168.100.207 in 2.629s
[16:21:45][I][app:100]: ESPHome version 2024.5.0 compiled on May 15 2024, 16:20:01
[16:21:50][W][component:237]: Component api took a long time for an operation (286 ms).
[16:21:50][W][component:238]: Components should block for at most 30 ms.
[16:21:53][W][component:237]: Component api took a long time for an operation (287 ms).

Log part of ESPhome 2023.11


|16:21:41|[W]|[component:170]|Component api cleared Warning flag|
| --- | --- | --- | --- |
|16:21:41|[W]|[component:237]|Component api took a long time for an operation (292 ms).|
|16:21:41|[W]|[component:238]|Components should block for at most 30 ms.|
|16:21:43|[I]|[app:100]|ESPHome version 2024.5.0 compiled on May 15 2024, 16:20:01|
|16:21:47|[W]|[component:237]|Component api took a long time for an operation (286 ms).|
|16:21:47|[W]|[component:238]|Components should block for at most 30 ms.|
|16:21:51|[W]|[component:237]|Component api took a long time for an operation (287 ms).|
|16:21:51|[W]|[component:238]|Components should block for at most 30 ms.|

Why don’t you share your entire yaml, so we can try to duplicate the issue. :wink:
Please make sure you hide any sensitive info (wifi credentials, etc) before sharing.

I did see above

They did: ESPHome 2024.5.0 brick my ESP devices - #3 by poudenes

1 Like

Revert back to 2023.11 and device is solid as a rock again

Same happened to me. The strange thing is that out of 5 devices, 3 worked fine. Out of the 5, 3 have the same firmware, and only worked on one. I even tried to flash the same rom on all and same errors, I thought the mini d1 was gone, but I revert back to 2024.4.2 and all devices just work with no issue, after flashing all devices again.

I think I’ve had similar with an IRBlaster I’ve got (here).
I dont still have the logs of it failing though, so can’t be 100% sure.

After updating esphome, it was refusing to connect back to tthe wifi.
After a lot of messing about, I found that if I removed some IR remote buttons from my yaml and got the resulting binary onto the device, it started behaving again.
It took quite a few retrys, restarts, and generally messing with it to get the smaller code uploaded.

I’d hit a similar thing previously, where adding more IR buttons to it made it do the same. Whatever limit I’ve been hitting seems to happen earlier (with fewer buttons) after updating. I’m not sure what the limit is or where it’s coming from though.

To try to narrow down what’s going on, it might be useful to cut chunks out of your yaml and retry updating?

This update’s causing trouble with a smart speaker/assistant I’ve got thats using esphome too (here), but doing the same with that hasn’t get it going again so I’ve rolled back the update.

ESPHome 2024.5.0 + D1 Mini + LD2410 = The connection dropped immediately after encrypted hello · Issue #5790 · esphome/issues · GitHub ?

1 Like

I had a similar thing happen here. I have a lot of ESP devices around the home and I always faithfully upgraded everything. Then with ESPHome 2024.4, some of those devices (especially the Sonoff Basic modules) would not connect to WiFi.

Installing ESPHome 2023.9 fixed the problem.

I tried raising the issue with the ESPHome devs, but it was dismissed with a weak excuse that I am using old hardware. As I said, recompiling with ESPHome 2023.9 fixed the issue.

I’m experiencing the same issue, I used to be on 2024.4, ESPhome docker is always updated.
I noticed by removing the “encryption” and the “key” from API it’s working fine.

I am experiencing the same on a D1 Mini, i upgraded, the device resets twice and then is active on wifi and stable, there is no output on logging when connected to usb and also wont repsond to API requests. all my ESP32 devices are fine, just the two D1 Mini’s i have arent working

Reverted to 2024.3.2 and now it is working again

I have a 2024.4.2 version of the firmware. I flashed it back and the device boots. But not all entities are there anymore in home assistant. I am using for monitoring my inverter and solar. On the old firmware the entities there are working but the main sensors for electricity monitoring are not and the entities no longer exist in home assistant