ESPhome connection issues during compilation

Hi All,

I installed Homeassistant Supervised (In docker) on a raspberry pi 4 running Debian 10 (Buster). I installed several addons: Mosquitto MQTT broker, Zigbee2MQTT and ESPHome.

I wanted to use a ESP-32S as a bridge between several LYWSD03MMC temperature and humidity sensors and integrate that into homeassistant via ESPHome.

I prepared the configuration file based on several examples i found on the internet as shown below: (Passes validation)

esphome:
  name: xiaomi_sensor_bridge_1
  platform: ESP32
  board: nodemcu-32s
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
logger:
  level: debug
api:
  reboot_timeout: 60min
ota:
  password: !secret ota_password
time:
  - platform: homeassistant
  
esp32_ble_tracker:
switch:
  - platform: gpio
    name: "Onboard-LED"
    pin: 2
    inverted: True
  - platform: restart
    name: restart
    id: restart_switch
sensor:
  - platform: uptime
    name: "Uptime Sensor"
    
  - platform: wifi_signal
    name: "WiFi Signal"
    update_interval: 60s
    
  - platform: xiaomi_lywsd03mmc
    mac_address: A4:C1:38:FA:4C:CB
    bindkey: "8ab5d4db49b2e003c6d6db9955763841"
    temperature:
      name: "Temperature"
    humidity:
      name: "Humidity"
    battery_level:
      name: "Battery Level"

Then, upon compiling the firmware for the ESP-32S i run into issues when the compiler is trying to access web-based resources. Namely when trying to update/upgrade platformio and install libraries such as: toolchain-xtensa32, AsyncTCP-esphome @ 1.1.1 and platformio/tool-scons @ ~4.40001.0.
Ultimately the compile always fails due to “Failed to establish a new connection: [Errno -2] Name or service not known”. The order in which these dependencies are installed seems to vary over time (while the system has been “idle”) and as such the error log also varies.

ESPHome compiler log:

INFO Reading configuration /config/esphome/xiaomi_sensor_bridge_1.yaml...
INFO Detected timezone 'CET' with UTC offset 1 and daylight savings time from 27 March 02:00:00 to 30 October 03:00:00
INFO Generating C++ source...
INFO Compiling app...
INFO Running:  platformio run -d /config/esphome/xiaomi_sensor_bridge_1
Processing xiaomi_sensor_bridge_1 (board: nodemcu-32s; framework: arduino; platform: [email protected])
--------------------------------------------------------------------------------
Tool Manager: Installing toolchain-xtensa32 @ ~2.50200.0
Tool Manager: Warning! More than one package has been found by toolchain-xtensa32 @ ~2.50200.0 requirements:
 - platformio/toolchain-xtensa32 @ 2.50200.97
 - tasmota/toolchain-xtensa32 @ 2.80400.2020
Tool Manager: Please specify detailed REQUIREMENTS using package owner and version (showed above) to avoid name conflicts
Downloading  [####################################]  100%          
Unpacking  [####################################]  100%          
Tool Manager: toolchain-xtensa32 @ 2.50200.97 has been installed!
Tool Manager: Installing platformio/tool-scons @ ~4.40001.0
WARNING Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf66d9cb0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /v3/packages/platformio/tool/tool-scons
WARNING Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf66d9cf0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /v3/packages/platformio/tool/tool-scons
WARNING Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf66d9db0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /v3/packages/platformio/tool/tool-scons
Error: Please read http://bit.ly/package-manager-ioerror
Tool Manager: Tool Manager: Warning! Package Mirror: HTTPSConnectionPool(host='dl.registry.nm1.platformio.org', port=443): Max retries exceeded with url: /tools/4b/5d/7f5a13840b4ac9110d535744aa4414e9266c1b18b8ca69919f97aa6cdeb6/tool-scons-4.40001.0.tar.gz (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf66c0bb0>: Failed to establish a new connection: [Errno -2] Name or service not known',))
Tool Manager: Looking for another mirror...
Tool Manager: tool-scons @ 4.40001.0 has been installed!
Tool Manager: Removing tool-scons @ 3.30102.0
Tool Manager: tool-scons @ 3.30102.0 has been removed!
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
PACKAGES: 
 - framework-arduinoespressif32 3.10004.200129 (1.0.4) 
 - tool-esptoolpy 1.20600.0 (2.6.0) 
 - toolchain-xtensa32 2.50200.97 (5.2.0)
Library Manager: Installing AsyncTCP-esphome @ 1.1.1
HTTPClientError: HTTPSConnectionPool(host='api.registry.ns1.platformio.org', port=443): Max retries exceeded with url: /v3/packages?query=type%3A%22library%22+name%3A%22asynctcp-esphome%22 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf63a6270>: Failed to establish a new connection: [Errno -2] Name or service not known',)):
  File "/usr/local/lib/python3.6/dist-packages/platformio/builder/main.py", line 170:
    env.SConscript("$BUILD_SCRIPT")
  File "/root/.platformio/packages/tool-scons/scons-local-4.0.1/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/root/.platformio/packages/tool-scons/scons-local-4.0.1/SCons/Script/SConscript.py", line 287:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/root/.platformio/platforms/espressif32/builder/main.py", line 223:
    target_elf = env.BuildProgram()
  File "/root/.platformio/packages/tool-scons/scons-local-4.0.1/SCons/Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/platformio/builder/tools/platformio.py", line 62:
    env.ProcessProjectDeps()
  File "/root/.platformio/packages/tool-scons/scons-local-4.0.1/SCons/Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/platformio/builder/tools/platformio.py", line 140:
    project_lib_builder = env.ConfigureProjectLibBuilder()
  File "/root/.platformio/packages/tool-scons/scons-local-4.0.1/SCons/Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/platformio/builder/tools/piolib.py", line 1062:
    project.install_dependencies()
  File "/usr/local/lib/python3.6/dist-packages/platformio/builder/tools/piolib.py", line 898:
    lm.install(spec)
  File "/usr/local/lib/python3.6/dist-packages/platformio/package/manager/_install.py", line 49:
    spec, silent=silent, skip_dependencies=skip_dependencies, force=force
  File "/usr/local/lib/python3.6/dist-packages/platformio/package/manager/library.py", line 86:
    force=force,
  File "/usr/local/lib/python3.6/dist-packages/platformio/package/manager/_install.py", line 99:
    pkg = self.install_from_registry(spec, search_filters, silent=silent)
  File "/usr/local/lib/python3.6/dist-packages/platformio/package/manager/_registry.py", line 88:
    packages = self.search_registry_packages(spec, search_filters)
  File "/usr/local/lib/python3.6/dist-packages/platformio/package/manager/_registry.py", line 135:
    return self.get_registry_client_instance().list_packages(filters=filters)[
  File "/usr/local/lib/python3.6/dist-packages/platformio/clients/registry.py", line 131:
    "get", "/v3/packages", params=params, cache_valid="1h"
  File "/usr/local/lib/python3.6/dist-packages/platformio/clients/http.py", line 144:
    response = self.send_request(method, path, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/platformio/util.py", line 73:
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/platformio/clients/http.py", line 131:
    raise HTTPClientError(str(e))
========================= [FAILED] Took 43.51 seconds =========================

I have done some research and some people seem to be talking about DNS issues. However, my setup seems rather straightforward. My Raspberry pi is connected to my router which manages its own subnet behind a modem (Required for my IPTV to work). Besides ESPHome the raspberry does not seem to have internet connection issues (Maybe aside from some spurious connection errors in the homeassistant log: 21-03-28 17:21:05 ERROR (MainThread) [supervisor.api.ingress] Ingress error: Cannot connect to host 172.30.32.1:64042 ssl:default [Connect call failed (‘172.30.32.1’, 64042)]).
I have followed the second answer on: https://stackoverflow.com/questions/39400886/docker-cannot-resolve-dns-on-private-network
But unfortunately to no avail.

I was able to manually access the addresses and download contents that failed to be resolved by ESPHome during firmware compilation.

Has anyone else had this problem or can help me solve it? I know some linux and networking basics, but unfortunately i am not very knowledgeable on networking stuff or linux.

I have tried your script in my Esphome and i was able to compile. So as you said its not an issue with the script. Were you able to compile any other firm wares before or is it the first time? There could be an issue with the addon.

If you can’t access stuff in the internet, then blame networking.

ie fix your networking.

@sheminasalam
First compile

@nickrout
Yes, i understand your answer. But the issue is that it does not seem to be a general networking issue. It seems specifically related to Homeassistant/ESPhome (or docker?).
For example, i was able to install Homeassistant and ESPhome add-on themselves without issue (from the internet on the Pi running its OS).

Try reinstalling esphome

Sometimes platformio is not 100% reliable. It may have been down for a while.

Also I am not 100% sure that esp32-s is supported yet in esphome.

What would that do to affect this problem? This is not windows!

Something not quite right in docker?

Strange, i am fairly sure i was able to access the packages (following the URL in the error message) on at least my windows PC at the time, i believe i was also able to on the Pi, for (at least) one of them.

Either way, i had everything idle overnight and for some reason compile seems to succeed now. I did not change anything since my hours of attempts to compile yesterday. Could the issue have been related to DST somehow? The pi was rebooted several (>10) times during the day.

But interestingly it doesnt seem to download/install the same packages as yesterday.
(Installing platformio/tool-scons @ ~4.40001.0 and toolchain-xtensa32 @ 2.50200.97)
Yesterdat in the log it said it installed them. But on subsequent compiling attempts it would again occassionally attempt to install them again (this was the variability i mentioned, logs warent always the same. Sometimes some stuff succeeded, sometimes it didnt. Sometimes it wouldnt even try, possibly because it failed at “an earlier stage”. Which is strange because a script should always behave the same way right?).

INFO Reading configuration /config/esphome/xiaomi_sensor_bridge_1.yaml...
INFO Detected timezone 'CET' with UTC offset 1 and daylight savings time from 27 March 02:00:00 to 30 October 03:00:00
INFO Generating C++ source...
INFO Compiling app...
INFO Running:  platformio run -d /config/esphome/xiaomi_sensor_bridge_1
Processing xiaomi_sensor_bridge_1 (board: nodemcu-32s; framework: arduino; platform: [email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
PACKAGES: 
 - framework-arduinoespressif32 3.10004.200129 (1.0.4) 
 - tool-esptoolpy 1.20600.0 (2.6.0) 
 - toolchain-xtensa32 2.50200.97 (5.2.0)
Library Manager: Installing AsyncTCP-esphome @ 1.1.1
Library Manager: AsyncTCP-esphome @ 1.1.1 has been installed!
Library Manager: Installing Hash
Library Manager: Already installed, built-in library
Dependency Graph
|-- <AsyncTCP-esphome> 1.1.1
|-- <ESPmDNS> 1.0
|   |-- <WiFi> 1.0
|-- <Update> 1.0
|-- <WiFi> 1.0
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/api/api_connection.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/api/api_pb2.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/api/api_pb2_service.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/api/api_server.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/api/list_entities.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/api/proto.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/api/subscribe_state.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/api/user_services.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/api/util.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/gpio/switch/gpio_switch.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/homeassistant/time/homeassistant_time.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/logger/logger.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/ota/ota_component.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/restart/restart_switch.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/ruuvi_ble/ruuvi_ble.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/sensor/automation.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/sensor/filter.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/sensor/sensor.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/switch/automation.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/switch/switch.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/time/automation.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/time/real_time_clock.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/uptime/uptime_sensor.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/wifi/wifi_component.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/wifi/wifi_component_esp32.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/wifi/wifi_component_esp8266.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/wifi_signal/wifi_signal_sensor.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/xiaomi_ble/xiaomi_ble.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/components/xiaomi_lywsd03mmc/xiaomi_lywsd03mmc.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/core/application.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/core/component.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/core/controller.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/core/esphal.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/core/helpers.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/core/log.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/core/preferences.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/core/scheduler.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/esphome/core/util.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/src/main.cpp.o
Generating partitions /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/partitions.bin
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/lib7f2/AsyncTCP-esphome/AsyncTCP.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/lib789/WiFi/ETH.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/lib789/WiFi/WiFi.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/lib789/WiFi/WiFiAP.cpp.o
Archiving /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/lib7f2/libAsyncTCP-esphome.a
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/lib789/WiFi/WiFiClient.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/lib789/WiFi/WiFiGeneric.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/lib789/WiFi/WiFiMulti.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/lib789/WiFi/WiFiSTA.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/lib789/WiFi/WiFiScan.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/lib789/WiFi/WiFiServer.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/lib789/WiFi/WiFiUdp.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/libe94/ESPmDNS/ESPmDNS.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/liba61/Update/Updater.cpp.o
Archiving /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/libFrameworkArduinoVariant.a
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/Esp.cpp.o
Archiving /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/lib789/libWiFi.a
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/FunctionalInterrupt.cpp.o
Archiving /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/libe94/libESPmDNS.a
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/HardwareSerial.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/IPAddress.cpp.o
Archiving /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/liba61/libUpdate.a
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/IPv6Address.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/MD5Builder.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/Print.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/Stream.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/StreamString.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/WMath.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/WString.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/base64.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/cbuf.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-adc.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-bt.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-cpu.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-dac.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-gpio.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-i2c.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-ledc.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-matrix.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-misc.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-psram.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-rmt.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-sigmadelta.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-spi.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-time.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-timer.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-touch.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/esp32-hal-uart.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/libb64/cdecode.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/libb64/cencode.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/main.cpp.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/stdlib_noniso.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/wiring_pulse.c.o
Compiling /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/FrameworkArduino/wiring_shift.c.o
Archiving /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/libFrameworkArduino.a
Linking /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/firmware.elf
Building /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/firmware.bin
Retrieving maximum program size /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/firmware.elf
Checking size /data/xiaomi_sensor_bridge_1/.pioenvs/xiaomi_sensor_bridge_1/firmware.elf
RAM:   [==        ]  18.5% (used 60644 bytes from 327680 bytes)
Flash: [========  ]  80.4% (used 1475554 bytes from 1835008 bytes)
======================== [SUCCESS] Took 120.76 seconds ========================
INFO Successfully compiled program.

Are you on the dev version of esphome?

Not as far as i am aware of (Current version: 1.16.2).

OK because the dev version downloads new stuff all the time!

Aaaaand today the problem is back. I am surprised ESPhome is downloading the dependencies it downloaded yesterday, again. Wouldn’t it make more sense to store that information so subsequent compilations are not internet dependent?

Either way, the log below:

INFO Reading configuration /config/esphome/xiaomi_sensor_bridge_2.yaml...
INFO Detected timezone 'CET' with UTC offset 1 and daylight savings time from 27 March 02:00:00 to 30 October 03:00:00
INFO Generating C++ source...
INFO Compiling app...
INFO Running:  platformio run -d /config/esphome/xiaomi_sensor_bridge_2
Processing xiaomi_sensor_bridge_2 (board: nodemcu-32s; framework: arduino; platform: [email protected])
--------------------------------------------------------------------------------
Tool Manager: Installing toolchain-xtensa32 @ ~2.50200.0
Tool Manager: Warning! More than one package has been found by toolchain-xtensa32 @ ~2.50200.0 requirements:
 - platformio/toolchain-xtensa32 @ 2.50200.97
 - tasmota/toolchain-xtensa32 @ 2.80400.2020
Tool Manager: Please specify detailed REQUIREMENTS using package owner and version (showed above) to avoid name conflicts
WARNING Retrying (Retry(total=5, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf68ba610>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /download/platformio/tool/toolchain-xtensa32/2.50200.97/toolchain-xtensa32-linux_armv6l-2.50200.97.tar.gz
WARNING Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf68ba650>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /download/platformio/tool/toolchain-xtensa32/2.50200.97/toolchain-xtensa32-linux_armv6l-2.50200.97.tar.gz
WARNING Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf68ba770>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /download/platformio/tool/toolchain-xtensa32/2.50200.97/toolchain-xtensa32-linux_armv6l-2.50200.97.tar.gz
WARNING Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf68ba810>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /download/platformio/tool/toolchain-xtensa32/2.50200.97/toolchain-xtensa32-linux_armv6l-2.50200.97.tar.gz
WARNING Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf68ba890>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /download/platformio/tool/toolchain-xtensa32/2.50200.97/toolchain-xtensa32-linux_armv6l-2.50200.97.tar.gz
WARNING Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf68ba930>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /download/platformio/tool/toolchain-xtensa32/2.50200.97/toolchain-xtensa32-linux_armv6l-2.50200.97.tar.gz
Error: HTTPSConnectionPool(host='dl.registry.platformio.org', port=443): Max retries exceeded with url: /download/platformio/tool/toolchain-xtensa32/2.50200.97/toolchain-xtensa32-linux_armv6l-2.50200.97.tar.gz (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf68ba9f0>: Failed to establish a new connection: [Errno -2] Name or service not known',))

The adress “dl.registry.platformio.org/download/platformio/tool/toolchain-xtensa32/2.50200.97/toolchain-xtensa32-linux_armv6l-2.50200.97.tar.gz” (Also not HTTPS) is definitely reachable from my PC and i get a download popup. However, the raspberry Pi cannot reach that address via ping in the terminal (ping dl.registry.platformio.org goes out, but does not return anything). However, it can reach it via the built-in chromium browser and automatically starts downloading the package (both http and https). But strangely enough ESPhome still can’t reach it.

EDIT: My significant other just mentioned that she restarted our router this afternoon after her Netflix binge was interrupted by a dropped internet connection.

The router logs do not show a blocked connection attempt from the Pi.

Now about 2 hours later it does manage to download the toolchain-xtensa dependency but gets stuck on another one. Again, the system has only been idling in the meantime. And havent changed anything. I have only been browing on my PC.

INFO Reading configuration /config/esphome/xiaomi_sensor_bridge_2.yaml...
INFO Detected timezone 'CET' with UTC offset 1 and daylight savings time from 27 March 02:00:00 to 30 October 03:00:00
INFO Generating C++ source...
INFO Compiling app...
INFO Running:  platformio run -d /config/esphome/xiaomi_sensor_bridge_2
Processing xiaomi_sensor_bridge_2 (board: nodemcu-32s; framework: arduino; platform: [email protected])
--------------------------------------------------------------------------------
Tool Manager: Installing toolchain-xtensa32 @ ~2.50200.0
Tool Manager: Warning! More than one package has been found by toolchain-xtensa32 @ ~2.50200.0 requirements:
 - platformio/toolchain-xtensa32 @ 2.50200.97
 - tasmota/toolchain-xtensa32 @ 2.80400.2020
Tool Manager: Please specify detailed REQUIREMENTS using package owner and version (showed above) to avoid name conflicts
Downloading  [####################################]  100%          
Unpacking  [####################################]  100%          
Tool Manager: toolchain-xtensa32 @ 2.50200.97 has been installed!
Tool Manager: Installing platformio/tool-scons @ ~4.40001.0
WARNING Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf630b630>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /v3/packages/platformio/tool/tool-scons
WARNING Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf630b670>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /v3/packages/platformio/tool/tool-scons
WARNING Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf630b730>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /v3/packages/platformio/tool/tool-scons
WARNING Retrying (Retry(total=5, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf645bb70>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /download/platformio/tool/tool-scons/4.40001.0/tool-scons-4.40001.0.tar.gz
WARNING Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf645bc30>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /download/platformio/tool/tool-scons/4.40001.0/tool-scons-4.40001.0.tar.gz
WARNING Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf630b6f0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /download/platformio/tool/tool-scons/4.40001.0/tool-scons-4.40001.0.tar.gz
WARNING Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf630b530>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /download/platformio/tool/tool-scons/4.40001.0/tool-scons-4.40001.0.tar.gz
WARNING Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf630b7f0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /download/platformio/tool/tool-scons/4.40001.0/tool-scons-4.40001.0.tar.gz
WARNING Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf630b750>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /download/platformio/tool/tool-scons/4.40001.0/tool-scons-4.40001.0.tar.gz
Error: HTTPSConnectionPool(host='dl.registry.platformio.org', port=443): Max retries exceeded with url: /download/platformio/tool/tool-scons/4.40001.0/tool-scons-4.40001.0.tar.gz (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xf630b490>: Failed to establish a new connection: [Errno -2] Name or service not known',))

And half an hour later it suddenly works once again.

What you might try, is doing a build from your pc, using the command line version of the ESPHome build. If you get that going, then you have a way to verify if the issues are specific to the raspberry or not.

The errors seem to suggest DNS lookup issues, which might be a symptom of a flaky network connection. If the raspberry is on WiFi, you could try hooking it up with a cable to your router/switch, to see if the WiFi is the issue here.

Ill see if i want to spend the time on that or just deal with unreliable compilation. (It is a set-up only issue afterall albeit a bit annoying.). The RPi is connected over wired LAN. (Running headless and i tend to VNC-in when i need to do stuff i am not sure of how to do over the commandline using putty.)

So i have tried various DNS adresses on the raspberry pi.
I pointed it to my router subnet .1 (which is in a DMZ of the modemrouter net .0) which in turn points to google.
I pointed it to my modemrouter net .0 which in turn points to google.
Directly to google DNS 8.8.8.8.
My ISP default DNS.

I confirmed the DNS used with dnsutils (dig command)

To test more thoroughly i adjusted the DNS settings of my router and modem router as well.

None of this solved the issue.

EDIT:
Could i work around this issue by manually downloading packages on my PC and extracting them somewhere on the Pi? If so, where would i extract those dependency archives for ESPhome compilations? It wouldn’t help with my other name resolutions ofcourse but it would give me a workaround in ESPhome for the time being.

Yo

Kinda had the same issue, I have an adguard home docker container that has an issue from time to time not sure what it is yet still debugging.

So I figured it was acting up again since I wasn’t able to download the same packages as you
My docker-compose.yaml is

---
version: "2.1"
services:
  esphome:
    image: esphome/esphome-armv7:latest
    container_name: esphome
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Brussels
    volumes:
      - /home/pi/containers/esphome:/config:rw
    restart: unless-stopped
    healthcheck:
      test: curl --fail -s http://192.168.1.5:6052 || exit 1
      interval: 1m30s
      timeout: 10s
      retries: 3
    dns: 1.1.1.1
    networks:
      macvlan:
        ipv4_address: 192.168.1.5
networks:
    default:
        external:
            name: macvlan
    macvlan:
        external: true

After adding DNS 1.1.1.1(cloudflare) my builds compile without any issues.
Not sure if this will help, but it worked for me.

good luck

1 Like