dmitry-cherkas / esphome-danfoss-eco

Extend Danfoss Eco eTRV BLE range over WiFi with ESPHome.
MIT License
21 stars 11 forks source link

After updating to ESPHome 2023.11.0 cannot establish bluetooth connection to Danfoss Eco #18

Closed reinisb closed 6 months ago

reinisb commented 6 months ago

Hey!

I've been using your component to read and control my Danfoss Eco eTRV for over a year without any major issues. During this time I've also always kept ESPHome up-to-date, which always included updating the ESP32 device. Everything always kepts working after an update until today when I updated to ESPHome 2023.11.0 and also updated my ESP32 device.

In particular, what seems to be going on is that my ESP32 device attempts to establish bluetooth connection with my danfoss, but danfoss does not respond.

Any ideas?

Log

[00:59:08][I][danfoss_eco:058]: [Living room Danfoss] requesting device state
[00:59:08][I][esp32_ble_client:069]: [0] [00:04:2F:06:32:18] 0x00 Attempting BLE connection
[01:00:08][I][danfoss_eco:058]: [Living room Danfoss] requesting device state
[01:00:08][I][esp32_ble_client:069]: [0] [00:04:2F:06:32:18] 0x00 Attempting BLE connection
[01:01:08][I][danfoss_eco:058]: [Living room Danfoss] requesting device state
[01:01:08][I][esp32_ble_client:069]: [0] [00:04:2F:06:32:18] 0x00 Attempting BLE connection

Config

esphome:
  name: esp32-32e
  compile_process_limit: 1
  libraries:
    - xxtea-iot-crypt@2.0.1

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "5oSJzTHRKWyWc1yEE/dPMPwQz+BfVtTVa6lRQNKJocw="

ota:
  password: "0f79ccb11c5c890913b00e3800a44882"

wifi:
  ssid: "Starlink"
  password: "ropazuiela14b16"

external_components:
  - source: github://dmitry-cherkas/esphome-danfoss-eco@v1.1.3
ble_client:
  - mac_address: 00:04:2f:06:32:18
    id: living_room_danfoss
climate:
  - platform: danfoss_eco
    name: "Living room Danfoss"
    ble_client_id: living_room_danfoss
    secret_key: 9f5de77f9c929090793264784a0ee361
    battery_level:
      name: "Living room Danfoss Battery Level"
    temperature:
      name: "Living room Danfoss Temperature"
    update_interval: 1min

button:
  - platform: factory_reset
    name: Restart with Factory Default Settings

Home assistant version

Core 2023.11.2
Supervisor 2023.11.3
Operating System 11.1
Frontend 20231030.2
reinisb commented 6 months ago

Updated to 2023.11.0, does not fix the issue.

Also, when I attempt to factory_reset the ESP32 device though Home Assistant UI it also seems to fail.

[15:56:45][D][button:010]: 'Restart with Factory Default Settings' Pressed.
[15:56:45][I][factory_reset.button:013]: Resetting to factory defaults...
[15:56:45][D][esp32.preferences:176]: Cleaning up preferences in flash...
[15:56:45][I][app:134]: Rebooting safely...
[15:56:45][D][esp32.preferences:114]: Saving 1 preferences to flash...
[15:56:45][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 0 written, 1 failed
[15:56:45][E][esp32.preferences:146]: Error saving 1 preferences to flash. Last error=ESP_ERR_NVS_INVALID_HANDLE for key=233825507
INFO Processing expected disconnect from ESPHome API for esp32-32e
WARNING Disconnected from API
INFO Successfully connected to esp32-32e in 7.253s
INFO Successful handshake with esp32-32e in 0.192s
[15:57:28][I][danfoss_eco:058]: [Living room Danfoss] requesting device state
[15:57:28][I][esp32_ble_client:069]: [0] [00:04:2F:06:32:18] 0x00 Attempting BLE connection
reinisb commented 6 months ago

@dmitry-cherkas when you have a moment could you please have a look at what in 2023.11.0 could have broken the component? Thanks!

hrubosz commented 6 months ago

I have the same problem,

ryssel commented 6 months ago

Me Too

dmitry-cherkas commented 6 months ago

Hi @reinisb et all. I no longer have a device in my possession, so troubleshooting the issue would be tricky. All I can tell at this point is that the component's code compiles with the latest esphome.

Could you please enable the DEBUG logging as follows and share the output here:

logger:
  logs:
    esp32_ble_tracker: DEBUG
    ble_client: DEBUG

Hopefully this would give us some hints.

ckoca commented 6 months ago

I attempted to fix this issue in #19.

trunkenbold71 commented 6 months ago

I attempted to fix this issue in #19.

Tried it, but it's not working for me. No difference to original code.

Sorry

reinisb commented 6 months ago

Could you please enable the DEBUG logging as follows and share the output here:

@dmitry-cherkas Thanks, here you go. Unfortunately, I don't see any more details. It just retries attempting BLE connection every minute.

INFO Waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from esp32-32e.local using esphome API
INFO Successfully connected to esp32-32e in 8.916s
INFO Successful handshake with esp32-32e in 1.142s
[17:28:57][I][app:102]: ESPHome version 2023.11.1 compiled on Nov 18 2023, 17:26:54
[17:28:57][C][wifi:559]: WiFi:
[17:28:57][C][wifi:391]:   Local MAC: E0:5A:1B:13:75:B8
[17:28:57][C][wifi:396]:   SSID: [redacted]
[17:28:57][C][wifi:397]:   IP Address: 192.168.1.54
[17:28:57][C][wifi:399]:   BSSID: [redacted]
[17:28:57][C][wifi:400]:   Hostname: 'esp32-32e'
[17:28:57][C][wifi:402]:   Signal strength: -72 dB ▂▄▆█
[17:28:57][C][wifi:406]:   Channel: 11
[17:28:57][C][wifi:407]:   Subnet: 255.255.255.0
[17:28:57][C][wifi:408]:   Gateway: 192.168.1.1
[17:28:57][C][wifi:409]:   DNS1: 192.168.1.1
[17:28:57][C][wifi:410]:   DNS2: 0.0.0.0
[17:28:57][C][logger:416]: Logger:
[17:28:57][C][logger:417]:   Level: DEBUG
[17:28:57][C][logger:418]:   Log Baud Rate: 115200
[17:28:57][C][logger:420]:   Hardware UART: UART0
[17:28:57][C][logger:424]:   Level for 'esp32_ble_tracker': DEBUG
[17:28:57][C][logger:424]:   Level for 'ble_client': DEBUG
[17:28:57][C][danfoss_eco:032]: Danfoss Eco eTRV 'Living room Danfoss'
[17:28:57][C][danfoss_eco:033]:   MAC Address: 00:04:2F:06:32:18
[17:28:57][C][danfoss_eco:034]: Battery Level 'Living room Danfoss Battery Level'
[17:28:57][C][danfoss_eco:034]:   Device Class: 'battery'
[17:28:57][C][danfoss_eco:034]:   State Class: 'measurement'
[17:28:57][C][danfoss_eco:034]:   Unit of Measurement: '%'
[17:28:57][C][danfoss_eco:034]:   Accuracy Decimals: 0
[17:28:58][C][danfoss_eco:035]: Room Temperature 'Living room Danfoss Temperature'
[17:28:58][C][danfoss_eco:035]:   Device Class: 'temperature'
[17:28:58][C][danfoss_eco:035]:   State Class: 'measurement'
[17:28:58][C][danfoss_eco:035]:   Unit of Measurement: '°C'
[17:28:58][C][danfoss_eco:035]:   Accuracy Decimals: 1
[17:28:58][C][factory_reset.button:011]: Factory Reset Button 'Restart with Factory Default Settings'
[17:28:58][C][factory_reset.button:011]:   Icon: 'mdi:restart-alert'
[17:28:58][C][esp32_ble:374]: ESP32 BLE:
[17:28:58][C][esp32_ble:376]:   MAC address: E0:5A:1B:13:75:BA
[17:28:58][C][esp32_ble:377]:   IO Capability: none
[17:28:58][C][ble_client:027]: BLE Client:
[17:28:58][C][ble_client:028]:   Address: 00:04:2F:06:32:18
[17:28:58][C][esp32_ble_tracker:645]: BLE Tracker:
[17:28:58][C][esp32_ble_tracker:646]:   Scan Duration: 300 s
[17:28:58][C][esp32_ble_tracker:647]:   Scan Interval: 320.0 ms
[17:28:58][C][esp32_ble_tracker:648]:   Scan Window: 30.0 ms
[17:28:58][C][esp32_ble_tracker:649]:   Scan Type: ACTIVE
[17:28:58][C][esp32_ble_tracker:650]:   Continuous Scanning: True
[17:28:58][C][mdns:115]: mDNS:
[17:28:58][C][mdns:116]:   Hostname: esp32-32e
[17:28:58][C][ota:097]: Over-The-Air Updates:
[17:28:58][C][ota:098]:   Address: esp32-32e.local:3232
[17:28:58][C][ota:101]:   Using Password.
[17:28:58][C][api:139]: API Server:
[17:28:58][C][api:140]:   Address: esp32-32e.local:6053
[17:28:58][C][api:142]:   Using noise encryption: YES
[17:28:58][D][api:102]: Accepted 192.168.1.122
[17:28:58][W][component:214]: Component api took a long time for an operation (0.05 s).
[17:28:58][W][component:215]: Components should block for at most 20-30ms.
[17:28:58][D][api.connection:1089]: Home Assistant 2023.11.2 (192.168.1.122): Connected successfully
[17:29:42][I][danfoss_eco:058]: [Living room Danfoss] requesting device state
[17:29:42][I][esp32_ble_client:069]: [0] [00:04:2F:06:32:18] 0x00 Attempting BLE connection
[17:30:42][I][danfoss_eco:058]: [Living room Danfoss] requesting device state
[17:30:42][I][esp32_ble_client:069]: [0] [00:04:2F:06:32:18] 0x00 Attempting BLE connection
reinisb commented 6 months ago

I attempted to fix this issue in #19.

I tried this just now and it worked! Thank you so much @ckoca.

@dmitry-cherkas could you please include the change in the main branch?

dmitry-cherkas commented 6 months ago

Please try v1.1.4

reinisb commented 6 months ago

1.1.4 works for me 👍