alistair23 / AutoMower-BLE

This is an unofficial reverse engineered Husqvarna Automower Connect BLE library. This allows connecting and controlling an Automower without any accounts, cloud or network connection.
GNU General Public License v3.0
87 stars 25 forks source link

Thank you! #1

Closed AlessandroTischer closed 7 months ago

AlessandroTischer commented 10 months ago

Thanks for your work. I'm not sure if this can help, since it's more about the uart communication rather than the Bluetooth one, but I founded some resources some time ago, and they might be handy.

https://community.home-assistant.io/t/esphome-for-husqvarna-gardena/481903/1

GitWally commented 7 months ago

Can you open the log, find line 217, in probe_gatts and then provide all of the lines around it?

Hello @alistair23 I'm afraid those lines are gone: they were generated in the morning (saturday 2024-03-23 between 08:48 and 08:50), when I was still running on PY3.9.

Then I have installed PY3.12 and log has changed. Since the log was referring to a different PY version, I assumed it was required. Now my first row in home-assistant.log dates as 2024-03-24 17:05 and the only reference to "mow" are these:

xxxx@xxxx:cat home-assistant.log | grep mow
2024-03-25 09:41:13.306 WARNING (SyncWorker_1) [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 09:41:35.361 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Discovered device: <habluetooth.models.BluetoothServiceInfoBleak object at 0x7fc27fc95fc0>
2024-03-25 09:41:35.362 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-25 09:41:35.362 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-03-25 09:44:05.810 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-03-25 09:44:31.750 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-03-25 10:00:51.951 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-03-25 10:02:08.765 INFO (MainThread) [automower_ble.mower] connecting to device...
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 105, in async_step_user
  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
2024-03-25 10:03:26.011 INFO (MainThread) [automower_ble.mower] connecting to device...
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 105, in async_step_user
  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
2024-03-25 10:03:27.396 INFO (MainThread) [automower_ble.mower] connecting to device...
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 105, in async_step_user
  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
2024-03-25 10:03:28.323 INFO (MainThread) [automower_ble.mower] connecting to device...
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 105, in async_step_user
  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

Anyhow I have

  1. restarted HA
  2. set 305 in pairing mode
  3. tried to pair using HA App on iPad > see logs between 09:41 and 09:44
  4. tried to pair using HA App on Android > see logs around 10:00
  5. tried to pair using Chrome from PC > see logs after 10:02

In my opinion they seem to be different.

This is the full 2024-03-25_home-assistant.log.txt from the re-start.

Many thanks

alistair23 commented 7 months ago

The full log provides a lot more information

Unable to install package PyBluez==0.22
...
gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fno-semantic-interposition -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -DTHREAD_STACK_SIZE=0x100000 -fPIC -I./port3 -I/usr/local/include/python3.12 -c bluez/btmodule.c -o build/temp.linux-x86_64-cpython-312/bluez/btmodule.o
      error: command 'gcc' failed: No such file or directory
      [end of output]

Which seems strange, that might be worth fixing.

Your HA instance does see the mower, as I see these lines

2024-03-25 09:41:35.361 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Discovered device: <habluetooth.models.BluetoothServiceInfoBleak object at 0x7fc27fc95fc0>
2024-03-25 09:41:35.362 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.config_flow] D8:B6:73:C2:BC:05 manufacturer data: {1062: b'\x05\x04$TO\r'}

But the connection fails with

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

Then you just get these messages

No backend with an available connection slot that can reach address D8:B6:73:C2:BC:05 was found

You might want to force a scan or discovery from the Bluetooth adapter before reloading the integration.

alistair23 commented 7 months ago

This issue is getting a bit out of hand.

I'm going to close this issue. If you are still having problems just open an separate issue. That way things are a little easier to track and manage

GitWally commented 7 months ago

I do agree: i will fix PyBluez first of all. Thanks again