ESP32 BLE Tracker update failing

Hi everyone,

I’ve been using a ESP32 as BLE tracker reliably for a good while but I needed to add a sensor. Because of this I noticed I had to update the ESPHome add-on in Home Assistant, which seemed to work. But when I try to install the new updated .yaml it gives some errors and it seems to be missing dependencies or something. In the error message it seems to be referring to missing headers.
I’ve tried running ‘Clean Build Files’ prior to installing but this doesn’t seem to change the outcome. Also tried it via USB without change.

Any help would be appreciated.

Below the configuration and the install log.

ESPHome version: 2023.10.1 Documentation
Previous version (and currently running on the ESP32): 2021.12.3

Home Assistant Core: 2023.9.3 2023.10.5
Home Assistant Operating System: 10.5 11.0
Hardware: Raspberry Pi 4 & ESP32

Configuration

esphome:
  name: esp32-ble
  friendly_name: Bluetooth Low Energy Receiver

esp32:
  board: esp32dev

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "xxx"

wifi:
  ssid: "xxx"
  password: "xxx"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-Ble Fallback Hotspot"
    password: "xxx"

esp32_ble_tracker:

sensor:
  - platform: xiaomi_lywsd03mmc
    mac_address: "A4:C1:38:65:C2:18"
    bindkey: "7C42A98B437A40DEBFE401469707F424"
    temperature:
      name: "ATC #01 Temperature"
    humidity:
      name: "ATC #01 Humidity"
    battery_level:
      name: "ATC #01 Battery-Level"

  - platform: xiaomi_lywsd03mmc
    mac_address: "A4:C1:38:39:46:38"
    bindkey: "B65666AFB0A78631B39DA05E42B16BCD"
    temperature:
      name: "ATC #02 Temperature"
    humidity:
      name: "ATC #02 Humidity"
    battery_level:
      name: "ATC #02 Battery-Level"

  - platform: xiaomi_lywsd03mmc
    mac_address: "A4:C1:38:5D:06:B3"
    bindkey: "B65666AFB0A78631B39DA05E42B16BCD"
    temperature:
      name: "ATC #03 Temperature"
    humidity:
      name: "ATC #03 Humidity"
    battery_level:
      name: "ATC #03 Battery-Level"

  - platform: xiaomi_lywsd03mmc
    mac_address: "A4:C1:38:AC:E3:76"
    bindkey: "B65666AFB0A78631B39DA05E42B16BCD"
    temperature:
      name: "ATC #04 Temperature"
    humidity:
      name: "ATC #04 Humidity"
    battery_level:
      name: "ATC #04 Battery-Level"

  - platform: xiaomi_lywsd03mmc
    mac_address: "A4:C1:38:9D:64:71"
    bindkey: "B65666AFB0A78631B39DA05E42B16BCD"
    temperature:
      name: "ATC #05 Temperature"
    humidity:
      name: "ATC #05 Humidity"
    battery_level:
      name: "ATC #05 Battery-Level"

  - platform: xiaomi_lywsd03mmc
    mac_address: "A4:C1:38:40:13:12"
    bindkey: "B65666AFB0A78631B39DA05E42B16BCD"
    temperature:
      name: "ATC #06 Temperature"
    humidity:
      name: "ATC #06 Humidity"
    battery_level:
      name: "ATC #06 Battery-Level"

  - platform: xiaomi_lywsd03mmc
    mac_address: "A4:C1:38:3A:E5:A6"
    bindkey: "B65666AFB0A78631B39DA05E42B16BCD"
    temperature:
      name: "ATC #07 Temperature"
    humidity:
      name: "ATC #07 Humidity"
    battery_level:
      name: "ATC #07 Battery-Level"

  - platform: xiaomi_lywsd03mmc
    mac_address: "A4:C1:38:33:30:3C"
    bindkey: "B65666AFB0A78631B39DA05E42B16BCD"
    temperature:
      name: "ATC #08 Temperature"
    humidity:
      name: "ATC #08 Humidity"
    battery_level:
      name: "ATC #08 Battery-Level"

  - platform: xiaomi_lywsd03mmc
    mac_address: "A4:C1:38:D3:16:A8"
    bindkey: "B65666AFB0A78631B39DA05E42B16BCD"
    temperature:
      name: "ATC #09 Temperature"
    humidity:
      name: "ATC #09 Humidity"
    battery_level:
      name: "ATC #09 Battery-Level"

  - platform: xiaomi_lywsd03mmc
    mac_address: "A4:C1:38:BE:6C:5B"
    bindkey: "B65666AFB0A78631B39DA05E42B16BCD"
    temperature:
      name: "ATC #10 Temperature"
    humidity:
      name: "ATC #10 Humidity"
    battery_level:
      name: "ATC #10 Battery-Level"

  - platform: xiaomi_lywsd03mmc
    mac_address: "A4:C1:38:D2:3E:37"
    bindkey: "310F0F263C2190D396EA25EC209BB146"
    temperature:
      name: "Zolder achterkamer Temperature"
    humidity:
      name: "Zolder achterkamer Humidity"
    battery_level:
      name: "Zolder achterkamer Battery-Level"

captive_portal:

Install log

INFO ESPHome 2023.10.1
INFO Reading configuration /config/esphome/esp32-ble.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing esp32-ble (board: esp32dev; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
Library Manager: Installing esphome/AsyncTCP-esphome @ 2.0.1
INFO Installing esphome/AsyncTCP-esphome @ 2.0.1
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Installing esphome/ESPAsyncWebServer-esphome @ 3.1.0
INFO Installing esphome/ESPAsyncWebServer-esphome @ 3.1.0
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Resolving dependencies...
INFO Resolving dependencies...
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.0.1
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.1.0
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
Compiling .pioenvs/esp32-ble/src/esphome/components/api/api_connection.cpp.o
Compiling .pioenvs/esp32-ble/src/esphome/components/api/api_frame_helper.cpp.o
Compiling .pioenvs/esp32-ble/src/esphome/components/api/api_pb2.cpp.o
Compiling .pioenvs/esp32-ble/src/esphome/components/api/api_pb2_service.cpp.o
In file included from src/esphome/components/socket/socket.h:6,
                 from src/esphome/components/api/api_frame_helper.h:14,
                 from src/esphome/components/api/api_connection.h:3,
                 from src/esphome/components/api/api_connection.cpp:1:
src/esphome/components/socket/headers.h:156:10: fatal error: sys/ioctl.h: No such file or directory
 #include <sys/ioctl.h>
          ^~~~~~~~~~~~~
compilation terminated.
*** [.pioenvs/esp32-ble/src/esphome/components/api/api_connection.cpp.o] Error 1
In file included from src/esphome/components/socket/socket.h:6,
                 from src/esphome/components/api/api_frame_helper.h:14,
                 from src/esphome/components/api/api_frame_helper.cpp:1:
src/esphome/components/socket/headers.h:156:10: fatal error: sys/ioctl.h: No such file or directory
 #include <sys/ioctl.h>
          ^~~~~~~~~~~~~
compilation terminated.
*** [.pioenvs/esp32-ble/src/esphome/components/api/api_frame_helper.cpp.o] Error 1
In file included from src/esphome/components/api/proto.h:4,
                 from src/esphome/components/api/api_pb2.h:5,
                 from src/esphome/components/api/api_pb2.cpp:3:
src/esphome/core/log.h:14:10: fatal error: esp_err.h: No such file or directory

*****************************************************************
* Looking for esp_err.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:esp_err.h"
* Web  > https://registry.platformio.org/search?q=header:esp_err.h
*
*****************************************************************

 #include <esp_err.h>
          ^~~~~~~~~~~
compilation terminated.
*** [.pioenvs/esp32-ble/src/esphome/components/api/api_pb2.cpp.o] Error 1
In file included from src/esphome/components/api/proto.h:4,
                 from src/esphome/components/api/api_pb2.h:5,
                 from src/esphome/components/api/api_pb2_service.h:5,
                 from src/esphome/components/api/api_pb2_service.cpp:3:
src/esphome/core/log.h:14:10: fatal error: esp_err.h: No such file or directory

*****************************************************************
* Looking for esp_err.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:esp_err.h"
* Web  > https://registry.platformio.org/search?q=header:esp_err.h
*
*****************************************************************

 #include <esp_err.h>
          ^~~~~~~~~~~
compilation terminated.
*** [.pioenvs/esp32-ble/src/esphome/components/api/api_pb2_service.cpp.o] Error 1
========================== [FAILED] Took 5.26 seconds ==========================

Allright, did a re-install of ESPHome and this time it worked.
The compiling when starting the installation/update of the ESP32 took a while. I think this got somehow interrupted the first time around on the first install of ESPHome and that wasn’t restarted. In any case. It all works like a charm.