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.75k stars 30.87k forks source link

husqvarna_automower_ble and multiple bluetooth adapters / proxies #130021

Closed gapthorpe closed 5 days ago

gapthorpe commented 1 week ago

The problem

Hi (First of all, thanks for this awesome integration - have been looking for something like this for a long time!)

My setup has an ESP32 acting as a bluetooth proxy, and also the bluetooth on the local HA device. When in range of the ESP32, it is communicating, but when in range of the local HA device, I am getting authentication errors: Failed setup, will retry: Unable to connect to device XX:XX:XX:XX:XX:XX due to [org.bluez.Error.AuthenticationFailed] Authentication Failed

I am guessing this is due to pairing with the bluetooth proxy but not the local bluetooth adapter - is there a way to allow the integration to use both of these, or ignore one to reduce the errors? Ideally would like to use both adapters to cover the garden area and charging point.

What version of Home Assistant Core has the issue?

core-2024.11.0

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

husqvarna_automower_ble

Link to integration documentation on our website

https://www.home-assistant.io/integrations/husqvarna_automower_ble

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 week ago

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

Code owner commands Code owners of `husqvarna_automower_ble` 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 husqvarna_automower_ble` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


husqvarna_automower_ble documentation husqvarna_automower_ble source (message by IssueLinks)

alistair23 commented 1 week ago

You will need to pair each adapter.

Basically turn on a single adapter, put the mower in pairing mode and the connect to the mower. Then repeat the process for each BLE repeater/adapter.

After that they should all work.

I'm not sure if there is a limit on the number, but I have two BLE proxies and that works fine

gapthorpe commented 1 week ago

Thanks for confirming - is there a best approach to pairing? If I put the mower BLE MAC address in again, it says it is already configured so cannot get further?

I tried deleting the integration and then re-adding near the other adapter, but now that is failing - it is the bluetooth adapter in the Raspberry Pi 4, so not sure if they work as well as the proxy for this... But a separate issue really - just wondered if others had seen problems with this?

thewiep commented 1 week ago

I'm getting similar message with a Bluetooth Proxy on an ESP32:

Failed setup, will retry: Unable to connect to device XX:XX:XX:XX:XX:XX due to esp32-ble-gardena [XX:XX:XX:XX:XX:XX] SILENO minimo 250 -XX:XX:XX:XX:XX:XX is not connected

I first got authentication issues as well in the ESP32 logs but after a few tries they dissappeared. Not with a Husqvarna but with a Gardena Sileno Minimo 250 which people got working in the original AutoMower implementation. It's my first time using a Bluetooth Proxy so I might be missing something but I think I've got it right. I put the mower in pairing by turning off and turning on on the mower itself. Then I added the integration and added the MAC address from the mower. I didn't get any request for a PIN and don't see a way of entering it so this might be part of the issue on my side.

This is a part from the ESP32 log:

[13:08:06][I][bluetooth_proxy:287]: [0] [XX:XX:XX:XX:XX:XX] Connecting v3 without cache [13:08:07][D][esp32_ble_tracker:219]: Pausing scan to make connection... [13:08:07][D][esp32_ble_tracker:219]: Pausing scan to make connection... [13:08:07][D][esp-idf:000][BTU_TASK]: E (3279188) BT_BTM: BTM_BleScan scan not active

[13:08:07][D][esp-idf:000][BTU_TASK]: W (3279192) BT_APPL: bta_dm_ble_scan stop scan failed, status=0x6

[13:08:07][I][esp32_ble_client:067]: [0] [XX:XX:XX:XX:XX:XX] 0x00 Attempting BLE connection [13:08:07][D][esp32_ble_client:110]: [0] XX:XX:XX:XX:XX:XX] ESP_GATTC_CONNECT_EVT [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_OPEN_EVT [13:08:07][D][esp32_ble_tracker:270]: Starting scan... [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_SEARCH_CMPL_EVT [13:08:07][I][esp32_ble_client:227]: [0] [XX:XX:XX:XX:XX:XX] Connected [13:08:07][D][esp32_ble_client:188]: [0] [XX:XX:XX:XX:XX:XX] cfg_mtu status 0, mtu 65 [13:08:07][I][esp32_ble_client:333]: [0] [XX:XX:XX:XX:XX:XX] auth complete. remote BD_ADDR: XXXXXXXXXXXX [13:08:07][D][esp32_ble_client:341]: [0] [XX:XX:XX:XX:XX:XX] auth success. address type = 0 auth mode = 1 [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_READ_CHAR_EVT [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_READ_CHAR_EVT [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_READ_CHAR_EVT [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_READ_CHAR_EVT [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_READ_CHAR_EVT [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_REG_FOR_NOTIFY_EVT [13:08:08][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_WRITE_DESCR_EVT [13:08:13][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_WRITE_CHAR_EVT [13:08:13][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_WRITE_CHAR_EVT [13:08:22][D][esp32_ble_client:306]: [0] [XX:XX:XX:XX:XX:XX] Event 39 [13:08:22][I][esp32_ble_client:084]: [0] [XX:XX:XX:XX:XX:XX] Disconnecting. [13:08:22][D][esp-idf:000][BTU_TASK]: W (3295159) BT_HCI: hci cmd send: disconnect: hdl 0x0, rsn:0x13

[13:08:22][D][esp-idf:000][BTU_TASK]: W (3295164) BT_APPL: gattc_conn_cb: if=3 st=0 id=3 rsn=0x16

[13:08:22][D][esp-idf:000][BTU_TASK]: W (3295168) BT_APPL: gattc_conn_cb: if=4 st=0 id=4 rsn=0x16

[13:08:23][D][esp-idf:000][BTU_TASK]: W (3295172) BT_APPL: gattc_conn_cb: if=5 st=0 id=5 rsn=0x16

[13:08:25][D][esp-idf:000][BTU_TASK]: W (3295188) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x16

If unrelated please ignore and I'll post a new issue if I can't get it sorted.

alistair23 commented 1 week ago

Thanks for confirming - is there a best approach to pairing? If I put the mower BLE MAC address in again, it says it is already configured so cannot get further?

I tried deleting the integration and then re-adding near the other adapter, but now that is failing - it is the bluetooth adapter in the Raspberry Pi 4, so not sure if they work as well as the proxy for this... But a separate issue really - just wondered if others had seen problems with this?

You should just be able to reload the integration.

HA recommends using ESPHome Proxies: https://www.home-assistant.io/integrations/bluetooth/#before-you-begin, so it's possibly an issue with the adapter

alistair23 commented 1 week ago

I'm getting similar message with a Bluetooth Proxy on an ESP32:

Failed setup, will retry: Unable to connect to device XX:XX:XX:XX:XX:XX due to esp32-ble-gardena [XX:XX:XX:XX:XX:XX] SILENO minimo 250 -XX:XX:XX:XX:XX:XX is not connected

I first got authentication issues as well in the ESP32 logs but after a few tries they dissappeared. Not with a Husqvarna but with a Gardena Sileno Minimo 250 which people got working in the original AutoMower implementation. It's my first time using a Bluetooth Proxy so I might be missing something but I think I've got it right. I put the mower in pairing by turning off and turning on on the mower itself. Then I added the integration and added the MAC address from the mower. I didn't get any request for a PIN and don't see a way of entering it so this might be part of the issue on my side.

This is a part from the ESP32 log:

[13:08:06][I][bluetooth_proxy:287]: [0] [XX:XX:XX:XX:XX:XX] Connecting v3 without cache [13:08:07][D][esp32_ble_tracker:219]: Pausing scan to make connection... [13:08:07][D][esp32_ble_tracker:219]: Pausing scan to make connection... [13:08:07][D][esp-idf:000][BTU_TASK]: E (3279188) BT_BTM: BTM_BleScan scan not active [13:08:07][D][esp-idf:000][BTU_TASK]: W (3279192) BT_APPL: bta_dm_ble_scan stop scan failed, status=0x6 [13:08:07][I][esp32_ble_client:067]: [0] [XX:XX:XX:XX:XX:XX] 0x00 Attempting BLE connection [13:08:07][D][esp32_ble_client:110]: [0] XX:XX:XX:XX:XX:XX] ESP_GATTC_CONNECT_EVT [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_OPEN_EVT [13:08:07][D][esp32_ble_tracker:270]: Starting scan... [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_SEARCH_CMPL_EVT [13:08:07][I][esp32_ble_client:227]: [0] [XX:XX:XX:XX:XX:XX] Connected [13:08:07][D][esp32_ble_client:188]: [0] [XX:XX:XX:XX:XX:XX] cfg_mtu status 0, mtu 65 [13:08:07][I][esp32_ble_client:333]: [0] [XX:XX:XX:XX:XX:XX] auth complete. remote BD_ADDR: XXXXXXXXXXXX [13:08:07][D][esp32_ble_client:341]: [0] [XX:XX:XX:XX:XX:XX] auth success. address type = 0 auth mode = 1 [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_READ_CHAR_EVT [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_READ_CHAR_EVT [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_READ_CHAR_EVT [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_READ_CHAR_EVT [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_READ_CHAR_EVT [13:08:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_REG_FOR_NOTIFY_EVT [13:08:08][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_WRITE_DESCR_EVT [13:08:13][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_WRITE_CHAR_EVT [13:08:13][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_WRITE_CHAR_EVT [13:08:22][D][esp32_ble_client:306]: [0] [XX:XX:XX:XX:XX:XX] Event 39 [13:08:22][I][esp32_ble_client:084]: [0] [XX:XX:XX:XX:XX:XX] Disconnecting. [13:08:22][D][esp-idf:000][BTU_TASK]: W (3295159) BT_HCI: hci cmd send: disconnect: hdl 0x0, rsn:0x13 [13:08:22][D][esp-idf:000][BTU_TASK]: W (3295164) BT_APPL: gattc_conn_cb: if=3 st=0 id=3 rsn=0x16 [13:08:22][D][esp-idf:000][BTU_TASK]: W (3295168) BT_APPL: gattc_conn_cb: if=4 st=0 id=4 rsn=0x16 [13:08:23][D][esp-idf:000][BTU_TASK]: W (3295172) BT_APPL: gattc_conn_cb: if=5 st=0 id=5 rsn=0x16 [13:08:25][D][esp-idf:000][BTU_TASK]: W (3295188) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x16

If unrelated please ignore and I'll post a new issue if I can't get it sorted.

The ESP is connecting, but then disconnecting. Ideally you need the logs from the automower component in HA as the ESP logs don't say too much.

Have you unlocked the mower by entering the PIN there?

We do support the PIN the communication, but HA doesn't expose it yet

wtaferner commented 1 week ago

I am having probably a similar issue like @thewiep as the mower is requesting a PIN at least if I connect via Automower Direct (in the official app) it does ask me every time. I was entering the PIN on the mower to unlock manually and also reduced security as much as possible on the mower, but no success to control the mower via HA, it runs into the error underneath.

Logger: automower_ble.mower
Source: components/husqvarna_automower_ble/coordinator.py:83
First occurred: November 7, 2024 at 16:41:06 (853 occurrences)
Last logged: 08:52:58

Response failed validation

Debug Log:

2024-11-08 09:02:54.935 DEBUG (MainThread) [homeassistant.components.husqvarna_automower_ble] Polling device
2024-11-08 09:02:54.936 DEBUG (MainThread) [homeassistant.components.husqvarna_automower_ble] Trying to reconnect
2024-11-08 09:02:54.936 INFO (MainThread) [automower_ble.protocol] starting scan...
2024-11-08 09:02:54.936 INFO (MainThread) [automower_ble.protocol] connecting to device...
2024-11-08 09:02:55.317 INFO (MainThread) [automower_ble.protocol] connected
2024-11-08 09:02:55.317 INFO (MainThread) [automower_ble.protocol] pairing device...
2024-11-08 09:02:55.532 INFO (MainThread) [automower_ble.protocol] paired
2024-11-08 09:02:55.532 INFO (MainThread) [automower_ble.protocol] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-11-08 09:02:55.890 INFO (MainThread) [automower_ble.protocol] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-11-08 09:02:55.890 INFO (MainThread) [automower_ble.protocol] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-11-08 09:03:01.258 INFO (MainThread) [automower_ble.protocol] Writing: b'02fd160000000000002e14f9b97f73000000004d61696e00e003'
2024-11-08 09:03:01.431 INFO (MainThread) [automower_ble.protocol] Received: b'02fd0d0000000000006315f9b97f73ca03'
2024-11-08 09:03:01.431 INFO (MainThread) [automower_ble.protocol] Final response: b'02fd0d0000000000006315f9b97f73ca03'
2024-11-08 09:03:01.432 INFO (MainThread) [automower_ble.protocol] Writing: b'02fd0a00f9b97f7300d408012803'
2024-11-08 09:03:01.740 INFO (MainThread) [automower_ble.protocol] Received: b'02fd0b00f9b97f7300e90901011403'
2024-11-08 09:03:01.740 INFO (MainThread) [automower_ble.protocol] Final response: b'02fd0b00f9b97f7300e90901011403'
2024-11-08 09:03:01.741 INFO (MainThread) [automower_ble.protocol] Writing: b'02fd1000f9b97f7301fa00af0a1014000000bf03'
2024-11-08 09:03:01.930 INFO (MainThread) [automower_ble.protocol] Received: b'02fd1200f9b97f73018001af0a10140000010063'
2024-11-08 09:03:01.930 INFO (MainThread) [automower_ble.protocol] Received: b'f803'
2024-11-08 09:03:01.930 INFO (MainThread) [automower_ble.protocol] Final response: b'02fd1200f9b97f73018001af0a10140000010063f803'
2024-11-08 09:03:01.930 WARNING (MainThread) [automower_ble.mower] Response failed validation
2024-11-08 09:03:01.931 DEBUG (MainThread) [homeassistant.components.husqvarna_automower_ble] battery_level99
2024-11-08 09:03:01.931 INFO (MainThread) [automower_ble.protocol] Writing: b'02fd1000f9b97f7301fa00afea1103000000e503'
2024-11-08 09:03:02.041 INFO (MainThread) [automower_ble.protocol] Received: b'02fd1200f9b97f73018001afea11030000010000'
2024-11-08 09:03:02.044 INFO (MainThread) [automower_ble.protocol] Received: b'ef03'
2024-11-08 09:03:02.046 INFO (MainThread) [automower_ble.protocol] Final response: b'02fd1200f9b97f73018001afea11030000010000ef03'
2024-11-08 09:03:02.046 WARNING (MainThread) [automower_ble.mower] Response failed validation
2024-11-08 09:03:02.047 DEBUG (MainThread) [homeassistant.components.husqvarna_automower_ble] activity:0
2024-11-08 09:03:02.047 INFO (MainThread) [automower_ble.protocol] Writing: b'02fd1000f9b97f7301fa00afea11020000006a03'
2024-11-08 09:03:02.254 INFO (MainThread) [automower_ble.protocol] Received: b'02fd1200f9b97f73018001afea11020000010008'
2024-11-08 09:03:02.347 INFO (MainThread) [automower_ble.protocol] Received: b'1a03'
2024-11-08 09:03:02.348 INFO (MainThread) [automower_ble.protocol] Final response: b'02fd1200f9b97f73018001afea110200000100081a03'
2024-11-08 09:03:02.348 WARNING (MainThread) [automower_ble.mower] Response failed validation
2024-11-08 09:03:02.348 DEBUG (MainThread) [homeassistant.components.husqvarna_automower_ble] state:8
2024-11-08 09:03:02.348 DEBUG (MainThread) [homeassistant.components.husqvarna_automower_ble] Finished fetching husqvarna_automower_ble data in 7.414 seconds (success: True)
2024-11-08 09:03:02.349 DEBUG (MainThread) [homeassistant.components.husqvarna_automower_ble] AutomowerLawnMower: _handle_coordinator_update

The model is a 420. Not sure if it is supported or how I can help further to analyze the issue. Just let me know.

alistair23 commented 1 week ago

The log seems to show everything working. It's querying the battery level and the states

wtaferner commented 1 week ago

The log seems to show everything working. It's querying the battery level and the states

Ok, so, currently having exactly one entity is the expected result? And the battery and other stuff is just not available, this is why I get these warnings, right?

alistair23 commented 1 week ago

Exactly

jordiinstalaciones commented 1 week ago

Hi Alistair23,

I wanted to express my sincere gratitude for your fantastic work on the Automower BLE integration. It has been incredibly valuable and greatly simplifies controlling my lawn mower, allowing me to start, pause, and send it back to the base with ease.

I was also wondering if you have any plans to add more features in the future, like viewing more status details or even adjusting some additional settings. It would be exciting to see how this integration could evolve.

Thank you so much for sharing your expertise with the community. Your effort makes a huge difference for all of us who enjoy home automation and smart home technology!

Best regards, Jordi Jordà Moncho

alistair23 commented 1 week ago

Every feature first needs to be supported by: https://github.com/alistair23/AutoMower-BLE

After that it can be exposed to HA. I do want to expose a few more data points, but it just takes time and effort to do

gapthorpe commented 5 days ago

Thanks for confirming - is there a best approach to pairing? If I put the mower BLE MAC address in again, it says it is already configured so cannot get further? I tried deleting the integration and then re-adding near the other adapter, but now that is failing - it is the bluetooth adapter in the Raspberry Pi 4, so not sure if they work as well as the proxy for this... But a separate issue really - just wondered if others had seen problems with this?

You should just be able to reload the integration.

HA recommends using ESPHome Proxies: https://www.home-assistant.io/integrations/bluetooth/#before-you-begin, so it's possibly an issue with the adapter

Thanks again @alistair23 - can confirm this worked with restarting the integration near the bluetooth device while the mower was in pairing mode. Thanks again for your excellent work on this!