Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Pair 305 to HA Supervised #2

Closed
GitWally opened this issue Mar 25, 2024 · 12 comments
Closed

Unable to Pair 305 to HA Supervised #2

GitWally opened this issue Mar 25, 2024 · 12 comments

Comments

@GitWally
Copy link

GitWally commented Mar 25, 2024

Hello,
I have a HA Supervised with an external antenna, and would like to test the integration with my 305.
So I have installed the custom_component, but I'm unable to pair the automower.

This is the home-assistant.log right after HA re-start: 305 is in pair mode with low security.

xxx@yyy:~$ cat /usr/share/hassio/homeassistant/home-assistant.log | grep mow
2024-03-25 18:16:40.861 WARNING (SyncWorker_4) [homeassistant.loader] We found a custom integration husqvarna_automower_ble which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-03-25 18:16:56.690 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Discovered device: <habluetooth.models.BluetoothServiceInfoBleak object at 0x7f5529ff0ec0>
2024-03-25 18:16:56.690 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.config_flow] D8:B6:73:C2:BC:05 manufacturer data: {1062: b'\x02\x05\x00'}
2024-03-25 18:16:56.690 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-03-25 18:18:00.359 INFO (MainThread) [automower_ble.mower] connecting to device...

This is the full 2024-03-25_home-assistant.log.txt file

@alistair23 the message about PyBluez was due to bluetooth_tracker (which I have removed from configuration.yaml)
Thanks

@alistair23
Copy link
Owner

alistair23 commented Mar 25, 2024

It might be worth having a quick read of the log before posting an issue.

The error is

Could not reset the power state of the Bluetooth adapter hci0 [00:E0:03:00:1E:69] due to timeout after 5 seconds

So that seems like some issue with the Bluetooth adapter. There isn't much I can do to help with that. Maybe check the HA issues and see if there are any details there

@alistair23
Copy link
Owner

It seems to be a common issue: home-assistant/core#107981

Maybe an ESPHome Proxy is a better solution?

@GitWally
Copy link
Author

Hello @alistair23 ,
before thinking of a ESPHome Proxy, I found this other post which seems somehow similar.

I will try as soon as possibile and come back to you, sharing results.
Thanks

@GitWally
Copy link
Author

GitWally commented Mar 28, 2024

Hello @alistair23
messages in home-assistant.log obtained with cat /usr/share/hassio/homeassistant/home-assistant.log | grep mow
seems to be similar to the ones of this other issue in this comment

2024-03-28 15:15:52.244 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration husqvarna_automower_ble which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-03-28 15:16:07.401 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Discovered device: <habluetooth.models.BluetoothServiceInfoBleak object at 0x7f257bffa9c0>
2024-03-28 15:16:07.401 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.config_flow] D8:B6:73:C2:BC:05 manufacturer data: {1062: b'\x05\x04$TO\r'}
2024-03-28 15:16:07.401 INFO (MainThread) [automower_ble.mower] connecting to device...
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 55, in async_step_bluetooth
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 69, in async_step_confirm
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 217, in probe_gatts

in the 20240328_home-assistant.log.txt I found these lines:

  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 55, in async_step_bluetooth
    return await self.async_step_confirm()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 69, in async_step_confirm
    (manufacture, device_type, model) = await Mower(
                                        ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 217, in probe_gatts
    await client.connect()
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 300, in connect
    connected = await super().connect(**kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This time I haven't seen messages like this or similar ...

Could not reset the power state of the Bluetooth adapter hci0 [00:E0:03:00:1E:69] due to timeout after 5 seconds

I'm still using a HA Supervised with a Realtek RTL8761BU adapter (ZEXMTE)

Thanks

@alistair23
Copy link
Owner

I see a

bleak.exc.BleakError: failed to discover services, device disconnected

and a

bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Disconnected early

Which is inside the Bluetooth stack.

Maybe the mower is too far away for a reliable connection?

@GitWally
Copy link
Author

GitWally commented Mar 29, 2024

I see a


bleak.exc.BleakError: failed to discover services, device disconnected

and a


bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Disconnected early

Which is inside the Bluetooth stack.

Maybe the mower is too far away for a reliable connection?

Don't think: the distance was less than 4 meters and the antenna should have a range of 180 (in fact in the past days it was discovering hundreds of devices).

Anyhow I tried once again, at less than 1 m (my wife is still screaming ...).
With cat /usr/share/hassio/homeassistant/home-assistant.log | grep mow I have seen some differences:

2024-03-29 08:41:27.424 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration husqvarna_automower_ble which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-03-29 08:41:43.419 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Discovered device: <habluetooth.models.BluetoothServiceInfoBleak object at 0x7f09ea33bc40>
2024-03-29 08:41:43.420 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.config_flow] D8:B6:73:C2:BC:05 manufacturer data: {1062: b'\x02\x05\x00'}
2024-03-29 08:41:43.420 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-03-29 08:41:51.565 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Discovered device: <habluetooth.models.BluetoothServiceInfoBleak object at 0x7f0a164783c0>
2024-03-29 08:41:51.565 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.config_flow] D8:B6:73:C2:BC:05 manufacturer data: {1062: b'\x02\x05\x00'}
2024-03-29 08:41:51.566 INFO (MainThread) [automower_ble.mower] connected
2024-03-29 08:41:51.566 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-03-29 08:41:51.566 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 10): Unknown (write-without-response)
2024-03-29 08:41:52.103 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 13): Unknown (read,notify), Error: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)
2024-03-29 08:41:52.103 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 17): Unknown (read), Error: Not connected
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 55, in async_step_bluetooth
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 69, in async_step_confirm
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 257, in probe_gatts
2024-03-29 08:45:24.005 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-03-29 08:45:26.918 INFO (MainThread) [automower_ble.mower] connected
2024-03-29 08:45:26.918 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-03-29 08:45:26.918 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 10): Unknown (write-without-response)

Some comments related to time

08:40 > Host reboot
08:45 > Pairing attempt (PC with Chrome) browser > 305 exits from pairing mode after a while

All the messages between 08:40 and 08:45 are generated "spontaneously": i didn't start the pairing process at all.

This is the 20240329_home-assistant.log.txt: i made other attempts

As far as I can see, each time the paring begin (and never ends) there are these messages from automower_ble.mower:

2024-03-29 08:45:24.005 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-03-29 08:45:26.918 INFO (MainThread) [automower_ble.mower] connected
2024-03-29 08:45:26.918 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-03-29 08:45:26.918 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 10): Unknown (write-without-response)

Should I get most recent versions of the code?
Thanks

@alistair23
Copy link
Owner

You are getting weird errors like this

2024-03-29 08:41:52.103 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 13): Unknown (read,notify), Error: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)
2024-03-29 08:41:52.103 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 17): Unknown (read), Error: Not connected

Some sort of reliability issue there. It might take a few times, try reloading the integration a few times.

You also get this

2024-03-29 08:54:09.690 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 10): Unknown (write-without-response)
2024-03-29 08:57:25.942 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from WebKit 605.1.15 on Mac OS 10.15.7
Script error.
null
@:0:0

Which is weird

@GitWally
Copy link
Author

GitWally commented Apr 5, 2024

Hello @alistair23
sorry for the delay, but it took me a while to receive an ESP32: in the end I decided to go with a BT proxy.

For those who are thinking to use an internal antenna (like I did), what the Bluetooth Integration page says:

In many cases, a better approach than a directly connected adapter or card is to use a Bluetooth proxy using an ESP32 since Linux kernel updates have previously broken Bluetooth functionality and Bluetooth driver support Linux generally falls behind other operating systems for newer adapters. A Bluetooth proxy is particularly interesting to users who virtualize their instance, where the USB pass-through may cause additional problems. More information is available in the Remote Adapters section below or by visiting ESPhome’s Bluetooth proxy page.

For the sake of completeness, I have:

  1. created an ESP32 BT Proxy
  2. installed ESPHome Add On
  3. associated the new ESP BT Proxy to ESPHome
  4. disabled my BT Integration (USB Antenna)
  5. rebooted
  6. put Husqvarna 305 in paring mode (with low security)
  7. HA has detected a new device with Husqvarna Automower BLE Integration
  8. pressed "configure" ...

and there you go: my brand new device is here ...

immagine

Many thanks!

@GitWally GitWally closed this as completed Apr 5, 2024
@alistair23
Copy link
Owner

Awesome! I'm glad it's working.

If you want to it might help if you go to home-assistant/core#108326 and comment that this works for you. That might help it get merged for others

@al31c0
Copy link

al31c0 commented Apr 6, 2024

Hi guys, I'm Alessandro from Italy.

I found this project amazing and soon I'll be back home I'll test this integration to finally control my stupid Automover with HA, so thank you so much for your effort.

From what I understood you are trying to get the approval to became an Official Integration in HA. Following your repo here I tryed to figure out how to setup the hardware and software.

Is it possible to integrate with ESPHome or is better to use a Bluetooth dongle? My HA server is downstairs and I think is better to have a Bluetooth repeater at floor garden, even better outside.

Could you provide a step-by-step installation guide? I'll be happy to test and help you by writing the guide as soon as I understand better the process.

@GitWally
Copy link
Author

GitWally commented Apr 7, 2024

Hi guys, I'm Alessandro from Italy.

I found this project amazing and soon I'll be back home I'll test this integration to finally control my stupid Automover with HA, so thank you so much for your effort.

From what I understood you are trying to get the approval to became an Official Integration in HA. Following your repo here I tryed to figure out how to setup the hardware and software.

Is it possible to integrate with ESPHome or is better to use a Bluetooth dongle? My HA server is downstairs and I think is better to have a Bluetooth repeater at floor garden, even better outside.

Could you provide a step-by-step installation guide? I'll be happy to test and help you by writing the guide as soon as I understand better the process.

Hello Alessandro
In my experience USB BT Dongle didn't work, despite being one of the "approved".

Follow my steps of my last message and it should work:

  1. create an ESP32 BT Proxy
  2. install ESPHome Add On
  3. associate the new ESP BT Proxy to ESPHome
  4. disable any BT Integration (USB Antenna) in case you have one
  5. reboot
  6. copy integration files (see this post https://github.com/alistair23/AutoMower-BLE/issues/1#issuecomment-2016393319)
  7. put Husqvarna 305 in paring mode (with low security)
  8. add the new integration
  9. provide Husqvarna mac address

Bye

@alistair23
Copy link
Owner

Documentation is available here: home-assistant/home-assistant.io#30921 (comment)

The PR includes details on setup and the PR comment contains details on setting up the component before it's merged. Feel free to file PRs against my fork for documentation updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants