home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.69k stars 30.82k forks source link

There are errors in Home Assistant when I power on my ESP32 BLE scanner device #90823

Closed tanklist closed 1 year ago

tanklist commented 1 year ago

The problem

I've got ESP32 BLE tracker device, it scan nearby device advertices and send them to MQTT broker. But when I power it on there are errors appear in Home Assistant log:

2023-04-05 06:02:49.902 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry ESP32_BLE_GATEWAY for update
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 383, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/update/__init__.py", line 117, in async_setup_entry
    return await component.async_setup_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 166, in async_setup_entry
    raise ValueError("Config entry has already been setup!")
ValueError: Config entry has already been setup!
2023-04-05 06:02:55.977 ERROR (MainThread) [homeassistant.util.logging] Exception in setup_update_entity when dispatching 'esphome_43b551f2fa338cdfe4a0877339ddbb90_on_device_update': ()
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/esphome/update.py", line 56, in setup_update_entity
    async_add_entities([ESPHomeUpdateEntity(entry_data, dashboard)])
  File "/usr/src/homeassistant/homeassistant/components/esphome/update.py", line 90, in __init__
    if coordinator.supports_update and not self._device_info.has_deep_sleep:
  File "/usr/src/homeassistant/homeassistant/components/esphome/dashboard.py", line 91, in supports_update
    raise RuntimeError("Data needs to be loaded first")
RuntimeError: Data needs to be loaded first

Could you tell me a reason for that? What is going on?

My configuration: Home Assistant 2023.3.6 (virtual machine) Supervisor 2023.03.3 Operating System 9.5 Frontend 20230309.1 - latest

Device is ESP32-WROOVER

YAML-file which is used for making ESP32 firmware is attached. esp32-ble-gateway.zip

ESP32 connects to WiFi router via WiFi, my PC in not in this subnet, just forwarding ports 6053, 64134, 3232

What version of Home Assistant Core has the issue?

core-2023.3.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

esphome, mosquito mqtt broker

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

esphome:
  name: esp32-ble-gateway
  friendly_name: ESP32_BLE_GATEWAY

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

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

ota:
  password: "some_pass"

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

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

captive_portal:

esp32_ble_tracker:
  scan_parameters:
    interval: 1s

text_sensor:
  - platform: ble_scanner
    id: id_ble_record
    name: "BLEDevScan"
    on_value:
        - mqtt.publish_json:
            topic: "ble/dev"
            payload: |-
              root["key"] = "1";
              root["greeting"] = "Hello World";

mqtt:
  discovery: false
  broker: MY_VIRTUAL_MACHINE_IP
  port: 1883
  username: mqtt-ble
  id: mqtt_client
  on_connect:
    - logger.log: MQTT is connected!
  on_disconnect:
    - logger.log: MQTT is disconnected...

Anything in the logs that might be useful for us?

INFO Reading configuration /config/esphome/esp32-ble-gateway.yaml...
INFO Starting log output from /dev/ttyUSB0 with baud rate 115200
[09:53:18]ets Jun  8 2016 00:22:57
[09:53:18]
[09:53:18]rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
[09:53:18]flash read err, 1000
[09:53:18]ets_main.c 371 
[09:53:19]ets Jun  8 2016 00:22:57
[09:53:19]
[09:53:19]rst:0x10 (RTCWDT_RTC_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
[09:53:19]configsip: 0, SPIWP:0xee
[09:53:19]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[09:53:19]mode:DIO, clock div:2
[09:53:19]load:0x3fff0030,len:1184
[09:53:19]load:0x40078000,len:13132
[09:53:19]load:0x40080400,len:3036
[09:53:19]entry 0x400805e4
[09:53:19][I][logger:258]: Log initialized
[09:53:19][C][ota:469]: There have been 2 suspected unsuccessful boot attempts.
[09:53:19][D][esp32.preferences:113]: Saving 1 preferences to flash...
[09:53:19][D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[09:53:19][I][app:029]: Running through setup()...
[09:53:19][C][esp32_ble:026]: Setting up BLE...
[09:53:20][D][esp32_ble:042]: BLE setup complete
[09:53:20][D][esp32_ble_tracker:246]: Starting scan...
[09:53:20][C][wifi:037]: Setting up WiFi...
[09:53:20][C][wifi:038]:   LocalВ MAC: --------
[09:53:20][D][wifi:386]: Starting scan...
[09:53:24][D][wifi:401]: Found networks:
[09:53:24][I][wifi:445]: - 'MY_NET'
[09:53:24][D][wifi:446]:     Channel: 11
[09:53:24][D][wifi:447]:     RSSI: -44 dB
[09:53:24][I][wifi:257]: WiFi Connecting to 'MY_NET'...
[09:53:25][D][text_sensor:067]: 'BLEDevScan': Sending state '{"timestamp":5,"address":"--------","rssi":-56,"name":"HONOR Band 5-215"}'
[09:53:27][W][wifi_esp32:494]: Event: Disconnected ssid='MY_NET' bssid=--------[redacted] reason='Auth Expired'
[09:53:27][W][wifi:549]: Error while connecting to network.
[09:53:27][W][wifi:585]: Restarting WiFi adapter...
[09:53:27][D][esp-idf:000]: E (16615) wifi:
[09:53:27][D][esp-idf:000]: timeout when WiFi un-init, type=4
[09:53:27][D][esp-idf:000]: 
[09:53:27]
[09:53:28][I][wifi:518]: WiFi Connected!
[09:53:28][C][wifi:362]:   Local MAC: --------
[09:53:28][C][wifi:363]:   SSID: 'MY_NET'[redacted]
[09:53:28][C][wifi:364]:   IP Address: 192.168.100.184
[09:53:28][C][wifi:367]:   Hostname: 'esp32-ble-gateway'
[09:53:28][C][wifi:369]:   Signal strength: -43 dB
[09:53:28][C][wifi:373]:   Channel: 11
[09:53:28][C][wifi:374]:   Subnet: 255.255.255.0
[09:53:28][C][wifi:375]:   Gateway: 192.168.100.3
[09:53:28][C][wifi:376]:   DNS1: 192.168.100.3
[09:53:28][C][wifi:377]:   DNS2: 0.0.0.0
[09:53:28][D][wifi:527]: Disabling AP...
[09:53:28][C][ota:093]: Over-The-Air Updates:
[09:53:28][C][ota:094]:   Address: esp32-ble-gateway.local:3232
[09:53:28][C][ota:097]:   Using Password.
[09:53:28][W][ota:103]: Last Boot was an unhandled reset, will proceed to safe mode in 8 restarts
[09:53:28][C][api:025]: Setting up Home Assistant API server...
[09:53:28][C][mqtt:029]: Setting up MQTT...
[09:53:28][I][mqtt:176]: Connecting to MQTT...
[09:53:30][D][api:102]: Accepted 192.168.1.244
[09:53:30][D][api.connection:920]: Home Assistant 2023.3.6 (192.168.1.244): Connected successfully
[09:53:30][D][api:102]: Accepted 192.168.1.244
[09:53:30][D][api.connection:920]: Home Assistant 2023.3.6 (192.168.1.244): Connected successfully
[09:53:31][D][text_sensor:067]: 'BLEDevScan': Sending state '{"timestamp":11,"address":"--------","rssi":-76,"name":"Mi Smart Band 6"}'
[09:53:36][D][text_sensor:067]: 'BLEDevScan': Sending state '{"timestamp":16,"address":"--------","rssi":-55,"name":"HONOR Band 5-215"}'
[09:53:46][D][main:250]: MQTT is disconnected...
[09:53:46][W][mqtt:264]: MQTT Disconnected: TCP disconnected.
[09:53:47][I][mqtt:176]: Connecting to MQTT...

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @ottowinter, @jesserockz, mind taking a look at this issue as it has been labeled with an integration (esphome) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `esphome` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign esphome` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


esphome documentation esphome source (message by IssueLinks)

bdraco commented 1 year ago

This is like cause by the dashboard reload which should be fixed in 2023.7

bdraco commented 1 year ago

If the problem still happens on 2023.7.x, restart ha twice. If it continue to appear please reopen this issue or start a new one (preferred)