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
90 stars 26 forks source link

Gardena support #3

Closed jkaberg closed 6 months ago

jkaberg commented 7 months ago

Love the work you've put in here.

I did notice the supported models.py which obviously is very Husqvarna centric. But i was wondering how Gardena mowers can be supported. I'm fairly certain Gardena uses the same libraries for BLE communication as Husqvarna (by decompilingthe Gardena Android app), and I assume McMurdoch aswell without looking.

alistair23 commented 7 months ago

Just from the look of the Gardena mowers they seem to be pretty much the same mowers.

If you want to know for sure you will need to sniff the BLE traffic and then see if the decoding matches. Otherwise you can just try running the scripts and see what happens

idominiki commented 7 months ago

I just tested the connection with my Gardena Minimo.

That is the output after entering the MAC Address. image

How can I support, on bringing support for Gardena mowers?

alistair23 commented 7 months ago

If you share the full HA log I might be able to shed some light on what is happening

andyb2000 commented 7 months ago

Hi there, I'm going to add a "me too" to this one. I have the Flymo Easilife go 500 which is manufactured by Husqvarna and is rebadged. Inside the hardware is all Husq components, control boards, etc. Looking at the BLE conversation it's the same as this project so it should work.

I've set it all up and tried a trial connection and got this: (Installed via clone and adding as custom_component) My HA is: Core 2024.4.2 Supervisor 2024.04.0 Operating System 12.2 Frontend 20240404.1

2024-04-12 10:50:35.302 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-12 10:50:36.333 INFO (MainThread) [automower_ble.mower] connected
2024-04-12 10:50:36.333 DEBUG (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-12 10:50:36.333 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-12 10:51:54.855 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 13): Unknown (read,notify), Error: 
2024-04-12 10:51:54.855 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 10): Unknown (write-without-response)
2024-04-12 10:51:54.856 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 106, in async_step_user
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 70, in async_step_confirm
    (manufacture, device_type, model) = await Mower(
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 257, in probe_gatts

Or raw logs from HA:

2024-04-12 10:50:35.302 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-12 10:50:36.333 INFO (MainThread) [automower_ble.mower] connected
2024-04-12 10:50:36.333 DEBUG (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-12 10:50:36.333 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-12 10:51:54.855 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 13): Unknown (read,notify), Error: 
2024-04-12 10:51:54.855 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 10): Unknown (write-without-response)
2024-04-12 10:51:54.856 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 17): Unknown (read), Error: Not connected
2024-04-12 10:51:54.856 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 88, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 71, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 356, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 402, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 506, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 106, in async_step_user
    return await self.async_step_confirm()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 70, in async_step_confirm
    (manufacture, device_type, model) = await Mower(
                                        ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 257, in probe_gatts
    device_type = await client.read_gatt_char(char)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 711, in read_gatt_char
    return await self._backend.read_gatt_char(char_specifier, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/backends/bluezdbus/client.py", line 681, in read_gatt_char
    raise BleakError("Not connected")
bleak.exc.BleakError: Not connected

Is this just a pairing error do you think initially? I tried several times (power off mower, power on, enter PIN and carry out the add integration in the first 3 minutes) and the mower looks like it's sat waiting/paired and indeed in the initial comms it shows "connected" so I think it paired.

Using the ble_scanner.py script:

python3 ble_scanner.py 
Scanning for 15.0 seconds, please wait...
Husqvarna device(s) found!

Address: 60:98:66:83:69:C5
        Name: EasiLife GO 500
        Signal Strength: -87 dBm (closer to 0 is stronger)
alistair23 commented 7 months ago

The error is BleakError: Not connected, so maybe the mower is disconnecting?

andyb2000 commented 6 months ago

Thanks Alistair, yes I think it's not authenticating/pairing. I went through a few attempts and I suspect the app/script needs to authenticate which was I think what you'd suggested in another thread. The pin is a 4 digit (translated into physical buttons but essentially it's a 4-digit pin)

See these logs after a few more attempts (factory reset the mower and deleted from the existing app on my phone to force it to pair)

2024-04-12 17:22:04.650 WARNING (MainThread) [custom_components.localtuya.common] [bfe...h6l] Failed to connect to 192.168.55.202: [Errno 113] Connect call failed ('192.168.55.202', 6668)
2024-04-12 17:22:04.867 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-12 17:22:05.211 INFO (MainThread) [automower_ble.mower] connected
2024-04-12 17:22:05.212 DEBUG (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-12 17:22:05.312 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'EasiLife GO 500')
2024-04-12 17:22:05.524 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-12 17:22:05.620 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-12 17:22:05.620 DEBUG (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-12 17:22:05.620 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-12 17:22:05.621 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-12 17:22:05.735 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Error: Bluetooth GATT Error address=60:98:66:83:69:C5 handle=14 error=5 description=Insufficient authentication
2024-04-12 17:22:05.824 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

There was another discussion on this - https://community.home-assistant.io/t/gardena-bluetooth-lawn-mower/400399/31 And another i'm trying to locate more information but I suspect sending the pin code should let it authenticate.

andyb2000 commented 6 months ago

I've tried a few other times and I think I've now got it paired (Entering the pin code on the mower seems to allow it to pair without authentication on the bluetooth BLE side) and the integration added, but it's showing "Failed to set up" and logs showing issues, could this be due to different command sets potentially:

2024-04-14 11:55:32.892 INFO (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Found device: Husqvarna Automower
2024-04-14 11:55:32.895 DEBUG (MainThread) [custom_components.husqvarna_automower_ble] connecting to 60:98:66:83:69:C5 with channel ID 210078362
2024-04-14 11:55:32.895 INFO (MainThread) [automower_ble.mower] starting scan...
2024-04-14 11:55:32.895 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 11:55:33.202 INFO (MainThread) [automower_ble.mower] connected
2024-04-14 11:55:33.202 INFO (MainThread) [automower_ble.mower] pairing device...
2024-04-14 11:55:33.704 INFO (MainThread) [automower_ble.mower] paired
2024-04-14 11:55:33.705 INFO (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-14 11:55:33.812 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'EasiLife GO 500')
2024-04-14 11:55:33.911 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-14 11:55:34.013 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-14 11:55:34.013 INFO (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-14 11:55:34.013 INFO (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-14 11:55:34.013 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-14 11:55:34.120 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Value: bytearray(b'')
2024-04-14 11:55:34.226 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-04-14 11:55:39.258 INFO (MainThread) [automower_ble.mower] Writing: b'02fd160000000000002e149a8a850c000000004d61696e00fc03'
2024-04-14 11:55:39.259 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 11:55:39.449 INFO (MainThread) [automower_ble.mower] Received: b'02fd0d00000000000063159a8a850c2f03'
2024-04-14 11:55:39.449 DEBUG (MainThread) [automower_ble.mower] Waiting for 17 bytes
2024-04-14 11:55:39.449 INFO (MainThread) [automower_ble.mower] Final response: b'02fd0d00000000000063159a8a850c2f03'
2024-04-14 11:55:39.449 INFO (MainThread) [automower_ble.mower] Writing: b'02fd0a009a8a850c000208012803'
2024-04-14 11:55:39.450 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 11:55:39.547 INFO (MainThread) [automower_ble.mower] Received: b'02fd0b009a8a850c003f0901011403'
2024-04-14 11:55:39.548 DEBUG (MainThread) [automower_ble.mower] Waiting for 15 bytes
2024-04-14 11:55:39.548 INFO (MainThread) [automower_ble.mower] Final response: b'02fd0b009a8a850c003f0901011403'
2024-04-14 11:55:39.548 DEBUG (MainThread) [custom_components.husqvarna_automower_ble] connected and paired
2024-04-14 11:55:39.548 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00af5a1209000000b703'
2024-04-14 11:55:39.549 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 11:55:39.649 INFO (MainThread) [automower_ble.mower] Received: b'02fd13009a8a850c016b01af5a1209000002001e'
2024-04-14 11:55:39.649 INFO (MainThread) [automower_ble.mower] Received: b'051b03'
2024-04-14 11:55:39.650 DEBUG (MainThread) [automower_ble.mower] Waiting for 23 bytes
2024-04-14 11:55:39.650 INFO (MainThread) [automower_ble.mower] Final response: b'02fd13009a8a850c016b01af5a1209000002001e051b03'
2024-04-14 11:55:39.650 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Husqvarna Automower for husqvarna_automower_ble
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/husqvarna_automower_ble/__init__.py", line 43, in async_setup_entry
    model = await mower.get_model()
            ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 272, in get_model
    return self.response.decode_response_device_type(response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/automower_ble/response.py", line 78, in decode_response_device_type
    return MowerModels[(data[19], data[20])]
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
KeyError: (30, 5)

What would I need to do to determine why it's having issues with the response? From what I can see others have been trying this and have the command set, etc. (https://github.com/tgillbe/flymo2mqtt/issues/1) but I don't understand enough to see if this matches the code you've done!

Thank you

alistair23 commented 6 months ago

Awesome! It's great to see you got it paired.

The issue you are seeing now if that the reply from the mower doesn't specify a valid Husqvarna Mower. That's not surprising as you aren't using a Husqvarna mower. The fix should be as simple as adding your model to: https://github.com/alistair23/AutoMower-BLE/blob/main/automower_ble/models.py#L42

andyb2000 commented 6 months ago

Aha! Makes sense. As a temporary test I modified /usr/local/lib/python3.12/site-packages/automower_ble/models.py and added in ((30, 5), "EasilifeGo500"),

Restarted HOME assistant, and yep it added this time! image

Which is great. Status looks correct as when I took that screenshot I'd set it to mow. It still looks like some commands keep missing/skipping, I've told it to go home a few times, or pause or any control and it ignores me. Battery level is going down so that's being pulled correctly.

So I'd guess it's the sending commands (It seems to stick on the lines:

2024-04-14 13:39:53.650 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] checkSafety
2024-04-14 13:39:53.650 DEBUG (MainThread) [custom_components.husqvarna_automower_ble] Finished fetching Husqvarna Automower BLE Data Update Coordinator data in 0.307 seconds (success: True)
2024-04-14 13:39:53.650 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] AutomowerLawnMower: _handle_coordinator_update
2024-04-14 13:39:53.651 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] BatterySensor: _handle_coordinator_update

So possibly when it's grabbing the battery sensor, the next query is hanging and not replying/responding as expected.

Then after a while it stops completely which I suspect is what other people mentioned in the other ble/automower forums where the device seems to stop broadcasting it's BLE MAC, but somehow when you launch the app on the phone it wakes it back up and it starts responding again (some type of broadcast? I don't know enough about BLE!) So it then never reconnects as shown below. If I power the mower off. Back on and reload the integration it reconnects and starts to show data again. This time it went home and it correctly logged that it was charging/docked (see paste right at bottom of page)

(You'll see me sending the Pause/return to base commands which it seems to write but doesn't respond to)

2024-04-14 13:39:59.942 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] Pausing mower
2024-04-14 13:39:59.942 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea1105000000ec03'
2024-04-14 13:39:59.944 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:00.090 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101afea110500050000db'
2024-04-14 13:40:00.090 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:00.090 DEBUG (MainThread) [automower_ble.mower] Waiting for 21 bytes
2024-04-14 13:40:00.090 INFO (MainThread) [automower_ble.mower] Final response: b'02fd11009a8a850c011101afea110500050000db03'
2024-04-14 13:40:01.170 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] Pausing mower
2024-04-14 13:40:01.170 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea1105000000ec03'
2024-04-14 13:40:01.172 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:01.331 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101afea110500050000db'
2024-04-14 13:40:01.332 DEBUG (MainThread) [automower_ble.mower] Waiting for 21 bytes
2024-04-14 13:40:01.332 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:01.332 INFO (MainThread) [automower_ble.mower] Final response: b'02fd11009a8a850c011101afea110500050000db03'
2024-04-14 13:40:01.438 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] Pausing mower
2024-04-14 13:40:01.438 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea1105000000ec03'
2024-04-14 13:40:01.440 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:01.532 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101afea110500050000db'
2024-04-14 13:40:01.532 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:01.532 DEBUG (MainThread) [automower_ble.mower] Waiting for 21 bytes
2024-04-14 13:40:01.533 INFO (MainThread) [automower_ble.mower] Final response: b'02fd11009a8a850c011101afea110500050000db03'
2024-04-14 13:40:01.643 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] Pausing mower
2024-04-14 13:40:01.643 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea1105000000ec03'
2024-04-14 13:40:01.645 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:01.735 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101afea110500050000db'
2024-04-14 13:40:01.735 DEBUG (MainThread) [automower_ble.mower] Waiting for 21 bytes
2024-04-14 13:40:01.737 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:01.738 INFO (MainThread) [automower_ble.mower] Final response: b'02fd11009a8a850c011101afea110500050000db03'
2024-04-14 13:40:01.840 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] Pausing mower
2024-04-14 13:40:01.841 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea1105000000ec03'
2024-04-14 13:40:01.843 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:01.932 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101afea110500050000db'
2024-04-14 13:40:01.932 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:01.932 DEBUG (MainThread) [automower_ble.mower] Waiting for 21 bytes
2024-04-14 13:40:01.932 INFO (MainThread) [automower_ble.mower] Final response: b'02fd11009a8a850c011101afea110500050000db03'
2024-04-14 13:40:02.567 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] Starting mower
2024-04-14 13:40:02.567 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea11040000006303'
2024-04-14 13:40:02.569 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:02.747 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] Starting mower
2024-04-14 13:40:02.747 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea11040000006303'
2024-04-14 13:40:02.749 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:02.761 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101afea11040005000016'
2024-04-14 13:40:02.761 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:02.762 DEBUG (MainThread) [automower_ble.mower] Waiting for 21 bytes
2024-04-14 13:40:02.762 INFO (MainThread) [automower_ble.mower] Final response: b'02fd11009a8a850c011101afea1104000500001603'
2024-04-14 13:40:02.854 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101afea11040005000016'
2024-04-14 13:40:02.854 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:02.854 DEBUG (MainThread) [automower_ble.mower] Waiting for 21 bytes
2024-04-14 13:40:02.854 INFO (MainThread) [automower_ble.mower] Final response: b'02fd11009a8a850c011101afea1104000500001603'
2024-04-14 13:40:02.954 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] Starting mower
2024-04-14 13:40:02.954 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea11040000006303'
2024-04-14 13:40:02.956 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:03.066 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101afea11040005000016'
2024-04-14 13:40:03.066 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:03.066 DEBUG (MainThread) [automower_ble.mower] Waiting for 21 bytes
2024-04-14 13:40:03.066 INFO (MainThread) [automower_ble.mower] Final response: b'02fd11009a8a850c011101afea1104000500001603'
2024-04-14 13:40:03.150 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] Starting mower
2024-04-14 13:40:03.150 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea11040000006303'
2024-04-14 13:40:03.153 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:03.263 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101afea11040005000016'
2024-04-14 13:40:03.263 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:03.263 DEBUG (MainThread) [automower_ble.mower] Waiting for 21 bytes
2024-04-14 13:40:03.263 INFO (MainThread) [automower_ble.mower] Final response: b'02fd11009a8a850c011101afea1104000500001603'
2024-04-14 13:40:03.659 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] Polling device
2024-04-14 13:40:03.659 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00af0a1014000000bf03'
2024-04-14 13:40:03.660 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:03.780 INFO (MainThread) [automower_ble.mower] Received: b'02fd12009a8a850c015601af0a10140000010025'
2024-04-14 13:40:03.780 INFO (MainThread) [automower_ble.mower] Received: b'6303'
2024-04-14 13:40:03.781 DEBUG (MainThread) [automower_ble.mower] Waiting for 22 bytes
2024-04-14 13:40:03.781 INFO (MainThread) [automower_ble.mower] Final response: b'02fd12009a8a850c015601af0a101400000100256303'
2024-04-14 13:40:03.781 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] 37
2024-04-14 13:40:03.781 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea1103000000e503'
2024-04-14 13:40:03.782 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:03.893 INFO (MainThread) [automower_ble.mower] Received: b'02fd12009a8a850c015601afea11030000010003'
2024-04-14 13:40:03.893 INFO (MainThread) [automower_ble.mower] Received: b'0d03'
2024-04-14 13:40:03.893 DEBUG (MainThread) [automower_ble.mower] Waiting for 22 bytes
2024-04-14 13:40:03.894 INFO (MainThread) [automower_ble.mower] Final response: b'02fd12009a8a850c015601afea110300000100030d03'
2024-04-14 13:40:03.894 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] mowing
2024-04-14 13:40:03.894 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea11020000006a03'
2024-04-14 13:40:03.895 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:03.978 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] Start docking
2024-04-14 13:40:03.978 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00af321205000000c703'
2024-04-14 13:40:03.980 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:03.985 INFO (MainThread) [automower_ble.mower] Received: b'02fd12009a8a850c015601afea110200'
2024-04-14 13:40:03.986 DEBUG (MainThread) [automower_ble.mower] Waiting for 22 bytes
2024-04-14 13:40:03.987 INFO (MainThread) [automower_ble.mower] Received: b'000100060503'
2024-04-14 13:40:03.987 DEBUG (MainThread) [automower_ble.mower] Waiting for 4 bytes
2024-04-14 13:40:04.088 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101af32120500050000d8'
2024-04-14 13:40:04.088 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:04.145 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] Start docking
2024-04-14 13:40:04.145 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00af321205000000c703'
2024-04-14 13:40:04.147 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:04.286 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101af32120500050000d8'
2024-04-14 13:40:04.286 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:04.330 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] Start docking
2024-04-14 13:40:04.331 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00af321205000000c703'
2024-04-14 13:40:04.333 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:04.441 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101af32120500050000d8'
2024-04-14 13:40:04.442 DEBUG (MainThread) [automower_ble.mower] Waiting for 21 bytes
2024-04-14 13:40:04.442 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:08.989 ERROR (MainThread) [automower_ble.mower] Unable to get full response from device: '60:98:66:83:69:C5', currently haveb'000100060503'
2024-04-14 13:40:08.989 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00af321205000000c703'
2024-04-14 13:40:08.991 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:09.103 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101af32120500050000d8'
2024-04-14 13:40:09.103 DEBUG (MainThread) [automower_ble.mower] Waiting for 21 bytes
2024-04-14 13:40:09.106 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:09.107 INFO (MainThread) [automower_ble.mower] Final response: b'02fd11009a8a850c011101af32120500050000d803'
2024-04-14 13:40:09.444 ERROR (MainThread) [automower_ble.mower] Unable to get full response from device: '60:98:66:83:69:C5', currently haveb'02fd12009a8a850c015601afea11020002fd11009a8a850c011101af32120500050000d80302fd11009a8a850c011101af32120500050000d80303'
2024-04-14 13:40:09.444 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea11020000006a03'
2024-04-14 13:40:09.445 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:09.617 INFO (MainThread) [automower_ble.mower] Received: b'02fd12009a8a850c015601afea11020000010006'
2024-04-14 13:40:09.617 DEBUG (MainThread) [automower_ble.mower] Waiting for 22 bytes
2024-04-14 13:40:09.618 INFO (MainThread) [automower_ble.mower] Received: b'0503'
2024-04-14 13:40:14.619 ERROR (MainThread) [automower_ble.mower] Unable to get full response from device: '60:98:66:83:69:C5', currently haveb'02fd12009a8a850c015601afea11020000010006'
2024-04-14 13:40:14.619 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00af321205000000c703'
2024-04-14 13:40:14.621 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:14.621 ERROR (MainThread) [automower_ble.mower] Unable to get full response from device: '60:98:66:83:69:C5', currently haveb'02fd11009a8a850c011101af32120500050000d80503'
2024-04-14 13:40:14.622 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00af321205000000c703'
2024-04-14 13:40:14.622 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:40:14.827 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101af32120500050000d8'
2024-04-14 13:40:14.827 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:14.827 DEBUG (MainThread) [automower_ble.mower] Waiting for 21 bytes
2024-04-14 13:40:14.827 INFO (MainThread) [automower_ble.mower] Final response: b'02fd11009a8a850c011101af32120500050000d803'
2024-04-14 13:40:14.827 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] None
2024-04-14 13:40:14.828 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] Trying to reconnect
2024-04-14 13:40:14.828 INFO (MainThread) [automower_ble.mower] starting scan...
2024-04-14 13:40:14.828 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 13:40:14.828 ERROR (MainThread) [custom_components.husqvarna_automower_ble.coordinator] Error getting data from device
2024-04-14 13:40:14.828 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] Trying to reconnect
2024-04-14 13:40:14.828 INFO (MainThread) [automower_ble.mower] starting scan...
2024-04-14 13:40:14.828 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 13:40:14.829 ERROR (MainThread) [custom_components.husqvarna_automower_ble] Unexpected error fetching Husqvarna Automower BLE Data Update Coordinator data: No backend with an available connection slot that can reach address 60:98:66:83:69:C5 was found
Traceback (most recent call last):
  File "/config/custom_components/husqvarna_automower_ble/coordinator.py", line 97, in _async_update_data
    await self._async_find_device()
  File "/config/custom_components/husqvarna_automower_ble/coordinator.py", line 69, in _async_find_device
    if not await self.mower.connect(device):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 138, in connect
    await self.client.connect()
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 275, in connect
    wrapped_backend = self._async_get_best_available_backend_and_device(manager)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 384, in _async_get_best_available_backend_and_device
    raise BleakError(
bleak.exc.BleakError: No backend with an available connection slot that can reach address 60:98:66:83:69:C5 was found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 315, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/husqvarna_automower_ble/coordinator.py", line 102, in _async_update_data
    await self._async_find_device()
  File "/config/custom_components/husqvarna_automower_ble/coordinator.py", line 69, in _async_find_device
    if not await self.mower.connect(device):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 138, in connect
    await self.client.connect()
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 275, in connect
    wrapped_backend = self._async_get_best_available_backend_and_device(manager)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 384, in _async_get_best_available_backend_and_device
    raise BleakError(
bleak.exc.BleakError: No backend with an available connection slot that can reach address 60:98:66:83:69:C5 was found
2024-04-14 13:40:14.845 DEBUG (MainThread) [custom_components.husqvarna_automower_ble] Finished fetching Husqvarna Automower BLE Data Update Coordinator data in 11.186 seconds (success: False)
2024-04-14 13:40:14.845 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] AutomowerLawnMower: _handle_coordinator_update
2024-04-14 13:40:14.846 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] BatterySensor: _handle_coordinator_update
2024-04-14 13:40:14.928 INFO (MainThread) [automower_ble.mower] Received: b'02fd11009a8a850c011101af32120500050000d8'
2024-04-14 13:40:14.929 INFO (MainThread) [automower_ble.mower] Received: b'03'
2024-04-14 13:40:14.929 DEBUG (MainThread) [automower_ble.mower] Waiting for 21 bytes
2024-04-14 13:40:14.929 INFO (MainThread) [automower_ble.mower] Final response: b'02fd11009a8a850c011101af32120500050000d803'
2024-04-14 13:40:24.622 ERROR (MainThread) [automower_ble.mower] Unable to get response from device: '60:98:66:83:69:C5'
2024-04-14 13:40:24.622 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00af321205000000c703'
2024-04-14 13:40:24.623 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140234773788992] 'NoneType' object has no attribute 'write_gatt_char'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2543, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 971, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1043, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/husqvarna_automower_ble/lawn_mower.py", line 142, in async_dock
    await self.coordinator.mower.mower_park()
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 345, in mower_park
    response = await self._request_response(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 100, in _request_response
    await self._write_data(request_data)
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 55, in _write_data
    await self.client.write_gatt_char(self.write_char, chunk, response=False)
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 776, in write_gatt_char
    await self._backend.write_gatt_char(characteristic, data, response)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'write_gatt_char'
2024-04-14 13:40:24.852 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] Polling device
2024-04-14 13:40:24.852 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] Trying to reconnect
2024-04-14 13:40:24.852 INFO (MainThread) [automower_ble.mower] starting scan...
2024-04-14 13:40:24.853 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 13:40:24.853 ERROR (MainThread) [custom_components.husqvarna_automower_ble] Unexpected error fetching Husqvarna Automower BLE Data Update Coordinator data: No backend with an available connection slot that can reach address 60:98:66:83:69:C5 was found
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 315, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/husqvarna_automower_ble/coordinator.py", line 79, in _async_update_data
    await self._async_find_device()
  File "/config/custom_components/husqvarna_automower_ble/coordinator.py", line 69, in _async_find_device
    if not await self.mower.connect(device):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 138, in connect
    await self.client.connect()
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 275, in connect
    wrapped_backend = self._async_get_best_available_backend_and_device(manager)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 384, in _async_get_best_available_backend_and_device
    raise BleakError(
bleak.exc.BleakError: No backend with an available connection slot that can reach address 60:98:66:83:69:C5 was found
2024-04-14 13:40:24.858 DEBUG (MainThread) [custom_components.husqvarna_automower_ble] Finished fetching Husqvarna Automower BLE Data Update Coordinator data in 0.006 seconds (success: False)
2024-04-14 13:41:24.993 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] Polling device
2024-04-14 13:41:24.994 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] Trying to reconnect
2024-04-14 13:41:24.994 INFO (MainThread) [automower_ble.mower] starting scan...
2024-04-14 13:41:24.994 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 13:41:24.994 ERROR (MainThread) [custom_components.husqvarna_automower_ble] Unexpected error fetching Husqvarna Automower BLE Data Update Coordinator data: No backend with an available connection slot that can reach address 60:98:66:83:69:C5 was found
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 315, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/husqvarna_automower_ble/coordinator.py", line 79, in _async_update_data
    await self._async_find_device()
  File "/config/custom_components/husqvarna_automower_ble/coordinator.py", line 69, in _async_find_device
    if not await self.mower.connect(device):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 138, in connect
    await self.client.connect()
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 275, in connect
    wrapped_backend = self._async_get_best_available_backend_and_device(manager)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 384, in _async_get_best_available_backend_and_device
    raise BleakError(
bleak.exc.BleakError: No backend with an available connection slot that can reach address 60:98:66:83:69:C5 was found
2024-04-14 13:41:24.999 DEBUG (MainThread) [custom_components.husqvarna_automower_ble] Finished fetching Husqvarna Automower BLE Data Update Coordinator data in 0.006 seconds (success: False)
2024-04-14 13:42:24.993 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] Polling device
2024-04-14 13:42:24.994 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] Trying to reconnect
2024-04-14 13:42:24.994 ERROR (MainThread) [custom_components.husqvarna_automower_ble.coordinator] Can't find device
2024-04-14 13:42:24.994 DEBUG (MainThread) [custom_components.husqvarna_automower_ble] Finished fetching Husqvarna Automower BLE Data Update Coordinator data in 0.001 seconds (success: False)
2024-04-14 13:57:19.081 INFO (MainThread) [automower_ble.mower] Final response: b'02fd12009a8a850c015601af0a10140000010030c103'
2024-04-14 13:57:19.081 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] 48
2024-04-14 13:57:19.081 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea1103000000e503'
2024-04-14 13:57:19.082 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:57:19.192 INFO (MainThread) [automower_ble.mower] Received: b'02fd12009a8a850c015601afea11030000010001'
2024-04-14 13:57:19.193 DEBUG (MainThread) [automower_ble.mower] Waiting for 22 bytes
2024-04-14 13:57:19.194 INFO (MainThread) [automower_ble.mower] Received: b'b103'
2024-04-14 13:57:19.194 INFO (MainThread) [automower_ble.mower] Final response: b'02fd12009a8a850c015601afea11030000010001b103'
2024-04-14 13:57:19.195 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] charging
2024-04-14 13:57:19.195 INFO (MainThread) [automower_ble.mower] Writing: b'02fd10009a8a850c012c00afea11020000006a03'
2024-04-14 13:57:19.197 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 13:57:19.294 INFO (MainThread) [automower_ble.mower] Received: b'02fd12009a8a850c015601afea11020000010006'
2024-04-14 13:57:19.294 DEBUG (MainThread) [automower_ble.mower] Waiting for 22 bytes
2024-04-14 13:57:19.296 INFO (MainThread) [automower_ble.mower] Received: b'0503'
2024-04-14 13:57:19.296 INFO (MainThread) [automower_ble.mower] Final response: b'02fd12009a8a850c015601afea110200000100060503'
2024-04-14 13:57:19.296 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.coordinator] checkSafety
2024-04-14 13:57:19.297 DEBUG (MainThread) [custom_components.husqvarna_automower_ble] Finished fetching Husqvarna Automower BLE Data Update Coordinator data in 0.334 seconds (success: True)
2024-04-14 13:57:19.297 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] AutomowerLawnMower: _handle_coordinator_update
2024-04-14 13:57:19.297 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.lawn_mower] BatterySensor: _handle_coordinator_update
andyb2000 commented 6 months ago

Extra update (Sorry! just want to provide info to others also). It's now done a charge cycle, then went back out to continue mowing and is still connected/sending states back.

So that's around an hour it's maintained connection. My guess (Not sure if other Husqvarna models do this) is that if the BLE drops or is left idle for a certain amount of time, the mower stops it's BLE connection/broadcasts and sleeps that component. Somehow the app seems to be able to wake that up (Possibly similar to sleep mode on esp32 in that it periodically wakes, checks for commands then sleeps, so you've got a narrow window to grab it). I'll try and test this out by reducing the BLE scan interval, let it timeout by interrupting the connection and see if a shorter interval lets it see the unit going through this cycle.

On the command sending, I'm unsure on what to try, the command appears to send via writing, it then replies with Received, but the mower doesn't act on it which suggests incorrect command do you think? I'm not sure if these commands here: https://github.com/tgillbe/flymo2mqtt/blob/master/src/mower/packets.py are the same/similar to the Husqvarna model you have, it may allow you to also expand the data you get from yours as those command sets seem to give a lot more status, configuration, etc from the mower.

berlund commented 6 months ago

@andyb2000 great you got some progress. I'm trying to get a Gardena mower working. So at what point do you enter the pin at the mower, when adding the integration?

nsiicm0 commented 6 months ago

@andyb2000 great you got some progress. I'm trying to get a Gardena mower working. So at what point do you enter the pin at the mower, when adding the integration?

wondering the same here. I think I am now at a similar „pre-authenticating“ stage:


2024-04-13 07:17:40.216 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-04-14 21:11:34.649 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Discovered device: <habluetooth.models.BluetoothServiceInfoBleak object at 0x7f18e87d6f40>
2024-04-14 21:11:34.650 DEBUG (MainThread) [custom_components.husqvarna_automower_ble.config_flow] E4:52:1E:B2:2E:56 manufacturer data: {1062: b'\x02\x05\x00\x04\x06\n\x1d\x04'}
2024-04-14 21:11:34.650 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 21:11:38.758 INFO (MainThread) [automower_ble.mower] connected
2024-04-14 21:11:38.758 DEBUG (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-14 21:11:38.843 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Alberto')
2024-04-14 21:11:39.040 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-14 21:11:39.152 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-14 21:11:39.152 DEBUG (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-14 21:11:39.152 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-14 21:11:39.152 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-14 21:11:39.258 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Error: Bluetooth GATT Error address=E4:52:1E:B2:2E:56 handle=14 error=5 description=Insufficient authentication
2024-04-14 21:11:39.351 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-04-14 21:11:39.505 INFO (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Found device: Husqvarna Automower�����������
2024-04-14 21:13:02.573 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 21:13:10.635 INFO (MainThread) [automower_ble.mower] connected
2024-04-14 21:13:10.635 DEBUG (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-14 21:13:10.790 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Alberto')
2024-04-14 21:13:11.003 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-14 21:13:11.104 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-14 21:13:11.104 DEBUG (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-14 21:13:11.104 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-14 21:13:11.104 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-14 21:13:11.207 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Error: Bluetooth GATT Error address=E4:52:1E:B2:2E:56 handle=14 error=5 description=Insufficient authentication
2024-04-14 21:13:11.306 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-04-14 21:13:11.508 INFO (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Found device: Husqvarna Automower�����������
2024-04-14 21:13:14.326 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 21:13:16.272 INFO (MainThread) [automower_ble.mower] connected
2024-04-14 21:13:16.272 DEBUG (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-14 21:13:16.422 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Alberto')
2024-04-14 21:13:16.639 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-14 21:13:16.780 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-14 21:13:16.781 DEBUG (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-14 21:13:16.781 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-14 21:13:16.781 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-14 21:13:16.942 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Error: Bluetooth GATT Error address=E4:52:1E:B2:2E:56 handle=14 error=5 description=Insufficient authentication
2024-04-14 21:13:17.043 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-04-14 21:13:17.243 INFO (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Found device: Husqvarna Automower�����������
2024-04-14 21:13:21.637 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 21:13:22.272 INFO (MainThread) [automower_ble.mower] connected
2024-04-14 21:13:22.273 DEBUG (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-14 21:13:22.362 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Alberto')
2024-04-14 21:13:22.587 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-14 21:13:22.691 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-14 21:13:22.691 DEBUG (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-14 21:13:22.691 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-14 21:13:22.691 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-14 21:13:22.775 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Error: Bluetooth GATT Error address=E4:52:1E:B2:2E:56 handle=14 error=5 description=Insufficient authentication
2024-04-14 21:13:22.887 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-04-14 21:13:23.024 INFO (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Found device: Husqvarna Automower�����������
2024-04-14 21:13:23.026 DEBUG (MainThread) [custom_components.husqvarna_automower_ble] connecting to E4:52:1E:B2:2E:56 with channel ID 4293618035
2024-04-14 21:13:23.026 INFO (MainThread) [automower_ble.mower] starting scan...
2024-04-14 21:13:23.026 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 21:13:24.124 INFO (MainThread) [automower_ble.mower] connected
2024-04-14 21:13:24.124 INFO (MainThread) [automower_ble.mower] pairing device...
2024-04-14 21:13:24.718 INFO (MainThread) [automower_ble.mower] paired
2024-04-14 21:13:24.718 INFO (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-14 21:13:24.936 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Alberto')
2024-04-14 21:13:25.024 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Error: Bluetooth GATT Error address=E4:52:1E:B2:2E:56 handle=5 error=133 description=Error
2024-04-14 21:13:25.024 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Error: atom-bluetooth-proxy-30de78 [E8:6B:EA:30:DE:78]: Alberto - E4:52:1E:B2:2E:56 is not connected
2024-04-14 21:13:25.024 INFO (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-14 21:13:25.024 INFO (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-14 21:13:25.024 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-14 21:13:25.024 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Error: atom-bluetooth-proxy-30de78 [E8:6B:EA:30:DE:78]: Alberto - E4:52:1E:B2:2E:56 is not connected
2024-04-14 21:13:25.025 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Error: atom-bluetooth-proxy-30de78 [E8:6B:EA:30:DE:78]: Alberto - E4:52:1E:B2:2E:56 is not connected
2024-04-14 21:13:25.025 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Husqvarna Automower����������� for husqvarna_automower_ble
  File "/config/custom_components/husqvarna_automower_ble/__init__.py", line 39, in async_setup_entry
    if not await mower.connect(device):
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 184, in connect
2024-04-14 21:25:08.100 DEBUG (MainThread) [custom_components.husqvarna_automower_ble] connecting to E4:52:1E:B2:2E:56 with channel ID 4293618035
2024-04-14 21:25:08.100 INFO (MainThread) [automower_ble.mower] starting scan...
2024-04-14 21:25:08.100 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 21:25:10.986 INFO (MainThread) [automower_ble.mower] connected
2024-04-14 21:25:10.986 INFO (MainThread) [automower_ble.mower] pairing device...
2024-04-14 21:25:11.188 INFO (MainThread) [automower_ble.mower] paired
2024-04-14 21:25:11.188 INFO (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-14 21:25:11.291 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Alberto')
2024-04-14 21:25:11.384 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-14 21:25:11.486 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-14 21:25:11.486 INFO (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-14 21:25:11.486 INFO (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-14 21:25:11.486 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-14 21:25:11.690 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Value: bytearray(b'')
2024-04-14 21:25:11.801 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-04-14 21:25:16.840 INFO (MainThread) [automower_ble.mower] Writing: b'02fd160000000000002e147369ebff000000004d61696e001f03'
2024-04-14 21:25:16.841 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 21:25:26.843 ERROR (MainThread) [automower_ble.mower] Unable to get response from device: 'E4:52:1E:B2:2E:56'
2024-04-14 21:25:26.844 INFO (MainThread) [automower_ble.mower] disconnecting...
2024-04-14 21:25:27.052 INFO (MainThread) [automower_ble.mower] disconnected
2024-04-14 21:25:27.052 INFO (MainThread) [automower_ble.mower] Writing: b'02fd160000000000002e147369ebff000000004d61696e001f03'
2024-04-14 21:25:27.052 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Husqvarna Automower����������� for husqvarna_automower_ble
  File "/config/custom_components/husqvarna_automower_ble/__init__.py", line 39, in async_setup_entry
    if not await mower.connect(device):
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 189, in connect
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 100, in _request_response
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 55, in _write_data
2024-04-14 21:25:32.440 ERROR (MainThread) [automower_ble.mower] could not find device with address 'e4:52:1E:B2:2E:56'
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 106, in async_step_user
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 70, in async_step_confirm
2024-04-14 21:25:38.932 ERROR (MainThread) [automower_ble.mower] could not find device with address 'e4:52:1E:B2:2E:56'
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 106, in async_step_user
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 70, in async_step_confirm
2024-04-14 21:25:39.764 ERROR (MainThread) [automower_ble.mower] could not find device with address 'e4:52:1E:B2:2E:56'
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 106, in async_step_user
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 70, in async_step_confirm
2024-04-14 21:27:55.589 ERROR (MainThread) [automower_ble.mower] could not find device with address 'e4:52:1E:B2:2E:56'
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 106, in async_step_user
  File "/config/custom_components/husqvarna_automower_ble/config_flow.py", line 70, in async_step_confirm
2024-04-14 21:28:03.858 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 21:28:12.637 INFO (MainThread) [automower_ble.mower] connected
2024-04-14 21:28:12.637 DEBUG (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-14 21:28:12.775 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Alberto')
2024-04-14 21:28:13.043 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-14 21:28:13.169 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-14 21:28:13.169 DEBUG (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-14 21:28:13.169 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-14 21:28:13.169 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-14 21:28:13.247 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Error: Bluetooth GATT Error address=E4:52:1E:B2:2E:56 handle=14 error=15 description=Insufficient encryption
2024-04-14 21:28:13.381 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-04-14 21:28:13.572 INFO (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Found device: Husqvarna Automower�����������
2024-04-14 21:28:15.937 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 21:29:42.839 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 21:29:47.763 INFO (MainThread) [automower_ble.mower] connected
2024-04-14 21:29:47.763 DEBUG (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-14 21:29:47.881 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Alberto')
2024-04-14 21:29:48.070 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-14 21:29:48.194 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-14 21:29:48.194 DEBUG (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-14 21:29:48.194 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-14 21:29:48.194 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-14 21:29:48.276 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Error: Bluetooth GATT Error address=E4:52:1E:B2:2E:56 handle=14 error=15 description=Insufficient encryption
2024-04-14 21:29:48.407 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-04-14 21:29:48.589 INFO (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Found device: Husqvarna Automower�����������
2024-04-14 21:29:50.344 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 21:29:53.601 INFO (MainThread) [automower_ble.mower] connected
2024-04-14 21:29:53.601 DEBUG (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-14 21:29:53.713 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Alberto')
2024-04-14 21:29:53.920 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-14 21:29:54.016 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-14 21:29:54.016 DEBUG (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-14 21:29:54.016 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-14 21:29:54.016 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-14 21:29:54.113 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Error: Bluetooth GATT Error address=E4:52:1E:B2:2E:56 handle=14 error=15 description=Insufficient encryption
2024-04-14 21:29:54.220 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-04-14 21:29:54.423 INFO (MainThread) [custom_components.husqvarna_automower_ble.config_flow] Found device: Husqvarna Automower�����������
2024-04-14 21:29:54.423 INFO (MainThread) [automower_ble.mower] starting scan...
2024-04-14 21:29:54.423 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 21:29:55.033 INFO (MainThread) [automower_ble.mower] connected
2024-04-14 21:29:55.034 INFO (MainThread) [automower_ble.mower] pairing device...
2024-04-14 21:29:55.239 INFO (MainThread) [automower_ble.mower] paired
2024-04-14 21:29:55.239 INFO (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-14 21:29:55.368 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Alberto')
2024-04-14 21:29:55.546 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-14 21:29:55.656 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-14 21:29:55.656 INFO (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-14 21:29:55.656 INFO (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-14 21:29:55.656 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-14 21:29:55.751 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Value: bytearray(b'')
2024-04-14 21:29:55.860 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-04-14 21:30:00.901 INFO (MainThread) [automower_ble.mower] Writing: b'02fd160000000000002e1478a1278d000000004d61696e007503'
2024-04-14 21:30:00.902 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 21:30:10.903 ERROR (MainThread) [automower_ble.mower] Unable to get response from device: 'E4:52:1E:B2:2E:56'
2024-04-14 21:30:10.904 INFO (MainThread) [automower_ble.mower] Writing: b'02fd160000000000002e1478a1278d000000004d61696e007503'
2024-04-14 21:30:10.904 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Husqvarna Automower����������� for husqvarna_automower_ble
  File "/config/custom_components/husqvarna_automower_ble/__init__.py", line 39, in async_setup_entry
    if not await mower.connect(device):
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 189, in connect
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 100, in _request_response
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 55, in _write_data
2024-04-14 21:31:42.424 INFO (MainThread) [automower_ble.mower] starting scan...
2024-04-14 21:31:42.424 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 21:32:12.428 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Husqvarna Automower����������� for husqvarna_automower_ble
  File "/config/custom_components/husqvarna_automower_ble/__init__.py", line 39, in async_setup_entry
    if not await mower.connect(device):
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 138, in connect
2024-04-14 21:38:14.843 INFO (MainThread) [automower_ble.mower] starting scan...
2024-04-14 21:38:14.843 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 21:38:16.695 INFO (MainThread) [automower_ble.mower] connected
2024-04-14 21:38:16.695 INFO (MainThread) [automower_ble.mower] pairing device...
2024-04-14 21:38:16.923 INFO (MainThread) [automower_ble.mower] paired
2024-04-14 21:38:16.923 INFO (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-14 21:38:17.009 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Alberto')
2024-04-14 21:38:17.111 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-14 21:38:17.256 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-14 21:38:17.256 INFO (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-14 21:38:17.256 INFO (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-14 21:38:17.256 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-14 21:38:17.412 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Value: bytearray(b'')
2024-04-14 21:38:17.536 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-04-14 21:38:22.563 INFO (MainThread) [automower_ble.mower] Writing: b'02fd160000000000002e1478a1278d000000004d61696e007503'
2024-04-14 21:38:22.564 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 21:38:32.566 ERROR (MainThread) [automower_ble.mower] Unable to get response from device: 'E4:52:1E:B2:2E:56'
2024-04-14 21:38:32.567 INFO (MainThread) [automower_ble.mower] disconnecting...
2024-04-14 21:38:32.718 INFO (MainThread) [automower_ble.mower] disconnected
2024-04-14 21:38:32.718 INFO (MainThread) [automower_ble.mower] Writing: b'02fd160000000000002e1478a1278d000000004d61696e007503'
2024-04-14 21:38:32.718 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Husqvarna Automower����������� for husqvarna_automower_ble
  File "/config/custom_components/husqvarna_automower_ble/__init__.py", line 39, in async_setup_entry
    if not await mower.connect(device):
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 189, in connect
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 100, in _request_response
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 55, in _write_data
2024-04-14 22:09:13.060 DEBUG (MainThread) [custom_components.husqvarna_automower_ble] connecting to E4:52:1E:B2:2E:56 with channel ID 2368184696
2024-04-14 22:09:13.060 INFO (MainThread) [automower_ble.mower] starting scan...
2024-04-14 22:09:13.060 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-14 22:09:14.982 INFO (MainThread) [automower_ble.mower] connected
2024-04-14 22:09:14.982 INFO (MainThread) [automower_ble.mower] pairing device...
2024-04-14 22:09:15.212 INFO (MainThread) [automower_ble.mower] paired
2024-04-14 22:09:15.212 INFO (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-14 22:09:15.275 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Alberto')
2024-04-14 22:09:15.381 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-14 22:09:15.471 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-14 22:09:15.472 INFO (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-14 22:09:15.472 INFO (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-14 22:09:15.472 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-14 22:09:15.573 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Value: bytearray(b'')
2024-04-14 22:09:15.675 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-04-14 22:09:20.723 INFO (MainThread) [automower_ble.mower] Writing: b'02fd160000000000002e1478a1278d000000004d61696e007503'
2024-04-14 22:09:20.724 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-04-14 22:09:30.725 ERROR (MainThread) [automower_ble.mower] Unable to get response from device: 'E4:52:1E:B2:2E:56'
2024-04-14 22:09:30.725 INFO (MainThread) [automower_ble.mower] disconnecting...
2024-04-14 22:09:30.784 INFO (MainThread) [automower_ble.mower] disconnected
2024-04-14 22:09:30.784 INFO (MainThread) [automower_ble.mower] Writing: b'02fd160000000000002e1478a1278d000000004d61696e007503'
2024-04-14 22:09:30.784 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Husqvarna Automower����������� for husqvarna_automower_ble
  File "/config/custom_components/husqvarna_automower_ble/__init__.py", line 39, in async_setup_entry
    if not await mower.connect(device):
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 189, in connect
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 100, in _request_response
  File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 55, in _write_data

It looks like the integration is constantly trying to „authenticate“, but times out eventually I guess.

alistair23 commented 6 months ago

So that's around an hour it's maintained connection. My guess (Not sure if other Husqvarna models do this) is that if the BLE drops or is left idle for a certain amount of time, the mower stops it's BLE connection/broadcasts and sleeps that component. Somehow the app seems to be able to wake that up (Possibly similar to sleep mode on esp32 in that it periodically wakes, checks for commands then sleeps, so you've got a narrow window to grab it). I'll try and test this out by reducing the BLE scan interval, let it timeout by interrupting the connection and see if a shorter interval lets it see the unit going through this cycle.

Yeah, the BLE is not super reliable unfortunately.

On the command sending, I'm unsure on what to try, the command appears to send via writing, it then replies with Received, but the mower doesn't act on it which suggests incorrect command do you think?

A quick look at the logs shows that the command is being sent and received. A note that HA takes a while to update the status as "returning to the dock" is still classified as Mowing by HA (there are not enough states in HA, if my PR ever gets accepted I plan to improve this).

You might have different commands to me. Your best bet to check that is to sniff the BLE traffic from the official app and compare that against what I am sending

andyb2000 commented 6 months ago

Hi @berlund and @nsiicm0 yes it took a few goes to get it to correctly pair, this is the sequence I used:

You might need to repeat this, I did about 3 times before it worked. In between attempts, power the mower off and wait a few minutes.

I need to test also if you need to reset the mower to factory defaults to destroy any existing bluetooth pairings. I did but I'm not convinced this is needed since the mower re-enters BLE broadcast at first power on (for 3 minutes) so see how you get on.

andyb2000 commented 6 months ago

So that's around an hour it's maintained connection. My guess (Not sure if other Husqvarna models do this) is that if the BLE drops or is left idle for a certain amount of time, the mower stops it's BLE connection/broadcasts and sleeps that component. Somehow the app seems to be able to wake that up (Possibly similar to sleep mode on esp32 in that it periodically wakes, checks for commands then sleeps, so you've got a narrow window to grab it). I'll try and test this out by reducing the BLE scan interval, let it timeout by interrupting the connection and see if a shorter interval lets it see the unit going through this cycle.

Yeah, the BLE is not super reliable unfortunately.

On the command sending, I'm unsure on what to try, the command appears to send via writing, it then replies with Received, but the mower doesn't act on it which suggests incorrect command do you think?

A quick look at the logs shows that the command is being sent and received. A note that HA takes a while to update the status as "returning to the dock" is still classified as Mowing by HA (there are not enough states in HA, if my PR ever gets accepted I plan to improve this).

You might have different commands to me. Your best bet to check that is to sniff the BLE traffic from the official app and compare that against what I am sending

Thanks @alistair23 yes it's getting close! I did notice the issue with it taking time to reflect the actual status but that's not a big issue! It'd be great to get more status/sensors showing so I might fork and play around with a few of those to see what I can get out of mine.

I'll get a test setup, using a spare android device on a custom rom, is there a good ble sniffer you can recommend I can use? is nRF Logger sufficient? (It might also shed some light onto how to 'wake up' the connection after it's dropped)

nsiicm0 commented 6 months ago

Hi @berlund and @nsiicm0 yes it took a few goes to get it to correctly pair, this is the sequence I used:

  • Firstly, delete the mower from your existing app/phone as it tries to pair immediately with that.
  • Long-hold power button on the mower (out of the docking station) and wait until it powers off (no led's showing)
  • In Home assistant, go into Integrations and click ADD, find the custom add_on and click on it so it's showing the MAC entry dialogue box. Paste your MAC address in ready but DO NOT click submit yet!
  • Hold the power button on the mower and when it powers on the LEDs will be on solid (waiting for pin). If you're watching your home-assistant.log file you'll see it was discovered almost straight away. Type the 4-digit into the mower and then click SUBMIT on home-assistant. It should process and accept.

You might need to repeat this, I did about 3 times before it worked. In between attempts, power the mower off and wait a few minutes.

I need to test also if you need to reset the mower to factory defaults to destroy any existing bluetooth pairings. I did but I'm not convinced this is needed since the mower re-enters BLE broadcast at first power on (for 3 minutes) so see how you get on.

brilliant. Thank you so much! Will try it today or tomorrow and report back.

andyb2000 commented 6 months ago

I ran the official apk app whilst logging debug data using nrf connect, so this is the transaction log for adding the product fresh to the android app (i.e. the authentication) and then it's logging data and then I press go home to charger (which it does just before disconnect). Not sure if this means anything @alistair23 or if you can point me to what to decode in the nrf connect log. I'll then do the same whilst pressing MOW START and MOW PAUSE, return to base, etc, to get a log of commands/data.

Log 2024-04-15 14_00_48.txt

alistair23 commented 6 months ago

Great!

That all looks sane. I have steps for decoding with Wireshark. For that you need to collect the data with Wireshark though

There is a lot of "chatter" between the app and the mower which you don't actually need. If you can find the time when you hit start, pause or any command you can hopefully find the exact packet that is used

nsiicm0 commented 6 months ago

Hi @berlund and @nsiicm0 yes it took a few goes to get it to correctly pair, this is the sequence I used:

  • Firstly, delete the mower from your existing app/phone as it tries to pair immediately with that.
  • Long-hold power button on the mower (out of the docking station) and wait until it powers off (no led's showing)
  • In Home assistant, go into Integrations and click ADD, find the custom add_on and click on it so it's showing the MAC entry dialogue box. Paste your MAC address in ready but DO NOT click submit yet!
  • Hold the power button on the mower and when it powers on the LEDs will be on solid (waiting for pin). If you're watching your home-assistant.log file you'll see it was discovered almost straight away. Type the 4-digit into the mower and then click SUBMIT on home-assistant. It should process and accept.

You might need to repeat this, I did about 3 times before it worked. In between attempts, power the mower off and wait a few minutes.

I need to test also if you need to reset the mower to factory defaults to destroy any existing bluetooth pairings. I did but I'm not convinced this is needed since the mower re-enters BLE broadcast at first power on (for 3 minutes) so see how you get on.

image

I managed to pair it first try with your instructions. Even without factory resetting. I guess the trick was to unpair it from my phone. Also, I patched the component init.py with the following diff (Alberto being the name of my mower). Initially it failed with the look up of (29,4).


diff --git a/homeassistant/components/husqvarna_automower_ble/__init__.py b/homeassistant/components/husqvarna_a
utomower_ble/__init__.py
index 2d87dcbcc8..7f074971a1 100644
--- a/homeassistant/components/husqvarna_automower_ble/__init__.py
+++ b/homeassistant/components/husqvarna_automower_ble/__init__.py
@@ -39,8 +39,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
     if not await mower.connect(device):
         return False
     LOGGER.debug("connected and paired")
-
-    model = await mower.get_model()
+    try:
+        model = await mower.get_model()
+    except KeyError:
+        model = "Alberto"
     LOGGER.info("Connected to Automower: %s", model)

     device_info = DeviceInfo(
andyb2000 commented 6 months ago

Hi @berlund and @nsiicm0 yes it took a few goes to get it to correctly pair, this is the sequence I used:

  • Firstly, delete the mower from your existing app/phone as it tries to pair immediately with that.
  • Long-hold power button on the mower (out of the docking station) and wait until it powers off (no led's showing)
  • In Home assistant, go into Integrations and click ADD, find the custom add_on and click on it so it's showing the MAC entry dialogue box. Paste your MAC address in ready but DO NOT click submit yet!
  • Hold the power button on the mower and when it powers on the LEDs will be on solid (waiting for pin). If you're watching your home-assistant.log file you'll see it was discovered almost straight away. Type the 4-digit into the mower and then click SUBMIT on home-assistant. It should process and accept.

You might need to repeat this, I did about 3 times before it worked. In between attempts, power the mower off and wait a few minutes.

I need to test also if you need to reset the mower to factory defaults to destroy any existing bluetooth pairings. I did but I'm not convinced this is needed since the mower re-enters BLE broadcast at first power on (for 3 minutes) so see how you get on.

image

I managed to pair it first try with your instructions. Even without factory resetting. I guess the trick was to unpair it from my phone. Also, I patched the component init.py with the following diff (Alberto being the name of my mower). Initially it failed with the look up of (29,4).


diff --git a/homeassistant/components/husqvarna_automower_ble/__init__.py b/homeassistant/components/husqvarna_a
utomower_ble/__init__.py
index 2d87dcbcc8..7f074971a1 100644
--- a/homeassistant/components/husqvarna_automower_ble/__init__.py
+++ b/homeassistant/components/husqvarna_automower_ble/__init__.py
@@ -39,8 +39,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
     if not await mower.connect(device):
         return False
     LOGGER.debug("connected and paired")
-
-    model = await mower.get_model()
+    try:
+        model = await mower.get_model()
+    except KeyError:
+        model = "Alberto"
     LOGGER.info("Connected to Automower: %s", model)

     device_info = DeviceInfo(

It's a hack which works!

This change is how to fix fully:

As a temporary test I modified /usr/local/lib/python3.12/site-packages/automower_ble/models.py and added in
((30, 5), "EasilifeGo500"),

As that adds it to the models array. Hopefully if we can solve it I can submit as pr back to get it added.

I've found a few issues keeping the connection so I'm working on debugging how to reconnect after a connection drop as the app does this but so far I cannot figure this out.

jkaberg commented 6 months ago

Just a side note/question; it's not possible to fetch the model/device information via Bluetooth when connected/connecting? Instead of maintaining an list

andyb2000 commented 6 months ago

Just a side note/question; it's not possible to fetch the model/device information via Bluetooth when connected/connecting? Instead of maintaining an list

Typically you'd not want to do that, at the moment it's a specific/known set of models that work with this integration/library. Opening it up to allow any model/device would in turn cause lots of support requests, complaints that the integration doesn't work, etc. This way it's kept under control to known working models and support can be added (as we're trying to do for the Easilife go 500 now) as required.

On that, I've now got wireshark/ble captures of the conversation between my android testing handset and the mower, so I'm going to use the decoding @alistair23 advised for the wireshark dump and try to recognise the start mowing command, etc.

andyb2000 commented 6 months ago

Hi @alistair23 I wonder if you can help make sure I'm reading the tcpdump/wireshark correctly. Please see attached two trial dump files (test1.log is wireshark format test2.txt is raw/text export).

Do these look correct, if so is the payload "02fd1000ef99494501e200afea1103000000e503" in this instance? How do you then decode that command? test1.log test2.txt

thank you!

peternijssen commented 6 months ago

I have a Gardena Sileno City and the ble_scanner.py script is capable of discovering it. I got something different then a MAC address, but based on documentation this is common on OSX and Bleak knows how to handle it.

python3 ble_scanner.py Scanning for 15.0 seconds, please wait... Husqvarna device(s) found!

Address: 63400449-4F39-04E4-E549-3451727C0931 Name: Lawnmower Signal Strength: -74 dBm (closer to 0 is stronger)

Trying to connect:

python3 ./mower.py --address 63400449-4F39-04E4-E549-3451727C0931 2024-04-18 20:41:13,040 main INFO: starting scan... 2024-04-18 20:41:13,040 main INFO: connecting to device... 2024-04-18 20:41:15,627 main INFO: connected 2024-04-18 20:41:15,627 main INFO: pairing device...

Results in an error:

NotImplementedError: Pairing is not available in Core Bluetooth.

Sounds like an OSX issue. Not sure. Haven't dived deeper into it yet. Will do so after next week.

erikmol commented 6 months ago

Hi @alistair23 I wonder if you can help make sure I'm reading the tcpdump/wireshark correctly. Please see attached two trial dump files (test1.log is wireshark format test2.txt is raw/text export).

Yes it's read correctly, but these are only requests? It would be useful to capture response as well. I wrote a small script to decode the data, just make sure to pip install btsnoop. The not decoded packages are the channel id setup and handshake. parsed_data.txt parselog.py.txt

andyb2000 commented 6 months ago

Hi @alistair23 I wonder if you can help make sure I'm reading the tcpdump/wireshark correctly. Please see attached two trial dump files (test1.log is wireshark format test2.txt is raw/text export).

Yes it's read correctly, but these are only requests? It would be useful to capture response as well. I wrote a small script to decode the data, just make sure to pip install btsnoop. The not decoded packages are the channel id setup and handshake. parsed_data.txt parselog.py.txt

sorry yes was just the send. I've got a full 'conversation' now from the app to my mower. Unfortunately I don't have ble/hci snoop hardware so i'm using the android BLE debugging log from my test phone so can't run the script direct but will convert it to parse my output.

I've attached a full log so you can see what I'm working with from my mower. btsnoop_hci.log

erikmol commented 6 months ago

sorry yes was just the send. I've got a full 'conversation' now from the app to my mower. Unfortunately I don't have ble/hci snoop hardware so i'm using the android BLE debugging log from my test phone so can't run the script direct but will convert it to parse my output.

The script was just parsing your log file so this works great. I think it would be very useful for other users (other apps, brands) if you could provide some details on how to obtain these logs.

I've attached a full log so you can see what I'm working with from my mower. btsnoop_hci.log

btsnoop_hci_parsed.txt and some script update to handle both types of communication: parselog2.py.txt

andyb2000 commented 6 months ago

great news, thank you erik. Parsed is making sense so I can now grab/test and check the commands we're getting here. They look similar!

btw parselog2.py.txt has a bug in it with the printf for the int.from_bytes which I fixed in my local copy so it writes out the correct. I'll test this tomorrow and get the commands (I'll also write a few steps on how to do this with a stock android phone to get the data)

alistair23 commented 6 months ago

Great!

Remember there is support for decoding commands in Wireshark, see https://github.com/alistair23/AutoMower-BLE/blob/main/Wireshark-decoding.md

All documentation and script improvements are welcome as PRs :)

jkaberg commented 6 months ago

Hi @berlund and @nsiicm0 yes it took a few goes to get it to correctly pair, this is the sequence I used:

  • Firstly, delete the mower from your existing app/phone as it tries to pair immediately with that.
  • Long-hold power button on the mower (out of the docking station) and wait until it powers off (no led's showing)
  • In Home assistant, go into Integrations and click ADD, find the custom add_on and click on it so it's showing the MAC entry dialogue box. Paste your MAC address in ready but DO NOT click submit yet!
  • Hold the power button on the mower and when it powers on the LEDs will be on solid (waiting for pin). If you're watching your home-assistant.log file you'll see it was discovered almost straight away. Type the 4-digit into the mower and then click SUBMIT on home-assistant. It should process and accept.

You might need to repeat this, I did about 3 times before it worked. In between attempts, power the mower off and wait a few minutes. I need to test also if you need to reset the mower to factory defaults to destroy any existing bluetooth pairings. I did but I'm not convinced this is needed since the mower re-enters BLE broadcast at first power on (for 3 minutes) so see how you get on.

image

I managed to pair it first try with your instructions. Even without factory resetting. I guess the trick was to unpair it from my phone. Also, I patched the component init.py with the following diff (Alberto being the name of my mower). Initially it failed with the look up of (29,4).


diff --git a/homeassistant/components/husqvarna_automower_ble/__init__.py b/homeassistant/components/husqvarna_a
utomower_ble/__init__.py
index 2d87dcbcc8..7f074971a1 100644
--- a/homeassistant/components/husqvarna_automower_ble/__init__.py
+++ b/homeassistant/components/husqvarna_automower_ble/__init__.py
@@ -39,8 +39,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
     if not await mower.connect(device):
         return False
     LOGGER.debug("connected and paired")
-
-    model = await mower.get_model()
+    try:
+        model = await mower.get_model()
+    except KeyError:
+        model = "Alberto"
     LOGGER.info("Connected to Automower: %s", model)

     device_info = DeviceInfo(

Perhaps we could implement this "fix" to display the device as "untested", eg model = "Untested" - would you accept an PR for that @alistair23 ?

My reasoning being is that if an device is not detected that would raise an issue, but if its detected as "untested" it immediately tells the user that the model is untested - however now the user has the option to test the device via existing commands and if not working they'll probably raise an issue as well.

alistair23 commented 6 months ago

Yeah, that seems like a good idea. Have some sort of fallback option so people can at least see what happens

djungelola commented 6 months ago

FYI Just got my Gardena Sileno minimo 500 integrated and working. Used this method: try: model = await mower.get_model() except KeyError: model = "minimo" LOGGER.info("Connected to Automower: %s", model)

Battery and status is updated nice, will report any issues i encounter.

berlund commented 6 months ago

Sounds good! Is your mower pin protected? Had no luck with my minimo 250 so far. On 25 Apr 2024, at 16:37, djungelola @.***> wrote: FYI Just got my Gardena Sileno minimo 500 integrated and working. Used this method: try:

model = await mower.get_model()

except KeyError:

model = "minimo"

Battery and status is updated nice, will report any issues i encounter.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

djungelola commented 6 months ago

Sounds good! Is your mower pin protected? Had no luck with my minimo 250 so far. On 25 Apr 2024, at 16:37, djungelola @.> wrote: FYI Just got my Gardena Sileno minimo 500 integrated and working. Used this method: try: model = await mower.get_model() except KeyError: model = "minimo" Battery and status is updated nice, will report any issues i encounter. —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.>

Yes, it has password. If i remember correct i had to enter the pin before starting the integration.

peternijssen commented 6 months ago

Tried the excellent instructions of @andyb2000 but unable to connect my Gardena Sileno City. I mostly get the authentication error like others here, but sometimes I get through halfway, leading to an integration without entities.

The bluetooth symbol is active on the mower and I also see this error a lot:

bleak.exc.BleakError: No backend with an available connection slot that can reach address A4:34:F1:7A:15:42 was found

Also stumbled on this one later today:

2024-04-26 19:00:52.287 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-04-26 19:00:53.668 INFO (MainThread) [automower_ble.mower] connected
2024-04-26 19:00:53.668 DEBUG (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-04-26 19:00:54.469 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'P0.1')
2024-04-26 19:00:54.990 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-04-26 19:00:55.191 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-04-26 19:00:55.191 DEBUG (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-04-26 19:00:55.191 DEBUG (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-04-26 19:00:55.191 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-04-26 19:00:55.295 ERROR (MainThread) [automower_ble.mower]   [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Error: Bluetooth GATT Error address=A4:34:F1:7A:15:42 handle=14 error=15 description=Insufficient encryption
2024-04-26 19:00:55.499 DEBUG (MainThread) [automower_ble.mower]   [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

Happy to help out somehow to get more Gardena devices covered, just need a pointer in the right direction :)

idominiki commented 6 months ago

After applying the model fix and followed setup instructions, I stopped here while adding my Minimo 250 Bildschirmfoto 2024-04-27 um 13 31 03

peternijssen commented 6 months ago

Tried the excellent instructions of @andyb2000 but unable to connect my Gardena Sileno City. I mostly get the authentication error like others here, but sometimes I get through halfway, leading to an integration without entities.

While I had the integration added without entities and with an error, while mowing I reloaded the integration and now I have the status and the battery in HA. Might be coincidence, but wanted to share in any case.

djungelola commented 6 months ago

Been running 1.33 for a couple of days now together with the latest HA code as custom component, a huge difference in stability! The only thing right now is that my minimo sensors gets "unavailible" from time to time (always come back) when the mower is docked and waiting for start time. When mowing or charging i dont see this. Still waiting to be able to send command like start, stop, park. But not a problem as long as the schedule works fine :-)

Br Ola

alistair23 commented 6 months ago

Been running 1.33 for a couple of days now together with the latest HA code as custom component, a huge difference in stability!

Awesome!

The only thing right now is that my minimo sensors gets "unavailible" from time to time (always come back) when the mower is docked and waiting for start time. When mowing or charging i dont see this.

That sounds like the connection is dropping. What do the logs say? I do see issues with unreliable connections, I'm not really sure what to do though.

Still waiting to be able to send command like start, stop, park. But not a problem as long as the schedule works fine :-)

The next thing will be to update the HA component to use the new re-factor. So any help with that would be great. Then we can fix any missing commands after that

jkaberg commented 6 months ago

sensors gets "unavailible" from time to time (always come back) when the mower is docked and waiting for start time. When mowing or charging i dont see this.

isn't this simply an issue of mower idling (and thus not broadcasting anything)? does the mower display this behavior when using phone?

peternijssen commented 6 months ago

In regards to start and park; That currently works fine with my Gardena (sileno city) mower. The only thing is that when I starts, it automatically sets the mode to "park/schedule" which means I have to keep a schedule in the mower itself. I did though made a small change in the custom_component in HA by adding the pin hardcoded in the new Model() code.

In regards to the disconnects; I notice the same. Tried the default bluetooth proxy setting as well as the setting shared here: https://github.com/alistair23/AutoMower-BLE/issues/6. Both work fine without disconnects for the very first hour(s) and then after a while they start to randomly drop from time to time.

Happens mostly between 10 and 20 minutes, but sometimes sooner. The connection is reinstated mostly between 1 and 2 minutes.

I had like an hour that the device could not be found, but mostly the logs contain different errors:

2024-04-30 13:31:19.217 ERROR (MainThread) [custom_components.husqvarna_automower_ble] Unexpected error fetching Husqvarna Automower BLE Data Update Coordinator data: No backend with an available connection slot that can reach address A4:34:F1:7A:15:42 was found
2024-04-30 13:32:20.440 ERROR (MainThread) [custom_components.husqvarna_automower_ble] Unexpected error fetching Husqvarna Automower BLE Data Update Coordinator data: Peripheral A4:34:F1:7A:15:42 changed connection status while waiting for BluetoothDevicePairingResponse: Insufficient authorization (8)
2024-04-30 13:40:43.420 ERROR (MainThread) [automower_ble.mower] Unable to get response from device: 'A4:34:F1:7A:15:42'
2024-04-30 13:40:43.421 ERROR (MainThread) [custom_components.husqvarna_automower_ble.coordinator] Error getting data from device
2024-04-30 13:40:53.564 ERROR (MainThread) [custom_components.husqvarna_automower_ble] Unexpected error fetching Husqvarna Automower BLE Data Update Coordinator data: [Errno 104] Connection reset by peer
djungelola commented 6 months ago

During the night my minimo behaves like this when docked. Not really a big problem, but doesnt look very nice :-)

image

djungelola commented 6 months ago

sensors gets "unavailible" from time to time (always come back) when the mower is docked and waiting for start time. When mowing or charging i dont see this.

isn't this simply an issue of mower idling (and thus not broadcasting anything)? does the mower display this behavior when using phone?

Might be, never had the app opened up for such a long time :-)

alistair23 commented 6 months ago

Don't include a ble_client in the ESPHome config. I originally had that, but it's a bug and can cause stability problems.

One other thing to try is adding this to your ESPHome config, it pulls in a new PR that might fix some issues

external_components:
  - source: github://pr#6596
    components: [ bluetooth_proxy, esp32_ble_client ]
The-Paran0id-Andr0id commented 6 months ago

Hi there,

please excuse my stupid question. Can someone please explain this step in more detail with the installation of the custom add_on, please? I tried in HACS and in the Add ons by adding the custom repository without success. I have to go in Settings > Integrations > Add ... and then?

"In Home assistant, go into Integrations and click ADD, find the custom add_on and..."

Thanks for your help and your work on this solution. Great idea!!

djungelola commented 6 months ago

Hi there,

please excuse my stupid question. Can someone please explain this step in more detail with the installation of the custom add_on, please? I tried in HACS and in the Add ons by adding the custom repository without success. I have to go in Settings > Integrations > Add ... and then?

"In Home assistant, go into Integrations and click ADD, find the custom add_on and..."

Thanks for your help and your work on this solution. Great idea!!

See instructions here: https://github.com/alistair23/AutoMower-BLE/issues/5#issuecomment-2041392659

Pimmeke1989 commented 6 months ago

I've taken a morning to try to add my Gardena Sileno City 470, but unfortunately I'm not getting it to stay paired, as it seams.

2024-05-02 12:31:59.173 DEBUG (MainThread) [custom_components.husqvarna_automower_ble] connecting to 74:46:B3:43:F7:4D with channel ID 3494508022
2024-05-02 12:31:59.173 INFO (MainThread) [automower_ble.mower] starting scan...
2024-05-02 12:31:59.173 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-05-02 12:31:59.753 INFO (MainThread) [automower_ble.mower] connected
2024-05-02 12:31:59.753 INFO (MainThread) [automower_ble.mower] pairing device...
2024-05-02 12:32:00.172 INFO (MainThread) [automower_ble.mower] paired
2024-05-02 12:32:00.172 INFO (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-05-02 12:32:00.468 DEBUG (MainThread) [automower_ble.mower] [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Mowie')
2024-05-02 12:32:00.582 DEBUG (MainThread) [automower_ble.mower] [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-05-02 12:32:00.779 DEBUG (MainThread) [automower_ble.mower] [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-05-02 12:32:00.780 INFO (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-05-02 12:32:00.780 INFO (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-05-02 12:32:00.780 DEBUG (MainThread) [automower_ble.mower] [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-05-02 12:32:00.908 DEBUG (MainThread) [automower_ble.mower] [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Value: bytearray(b'')
2024-05-02 12:32:01.079 DEBUG (MainThread) [automower_ble.mower] [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-05-02 12:32:06.098 INFO (MainThread) [automower_ble.mower] Writing: b'02fd160000000000002e14f6f549d0000000004d61696e002103'
2024-05-02 12:32:06.099 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-05-02 12:32:16.100 ERROR (MainThread) [automower_ble.mower] Unable to get response from device: '74:46:B3:43:F7:4D'
2024-05-02 12:32:16.101 INFO (MainThread) [automower_ble.mower] disconnecting...
2024-05-02 12:32:16.186 INFO (MainThread) [automower_ble.mower] disconnected
2024-05-02 12:32:16.186 INFO (MainThread) [automower_ble.mower] Writing: b'02fd160000000000002e14f6f549d0000000004d61696e002103'
2024-05-02 12:32:16.186 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Husqvarna Automower for husqvarna_automower_ble
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 575, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/husqvarna_automower_ble/__init__.py", line 39, in async_setup_entry
if not await mower.connect(device):
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 191, in connect
response = await self._request_response(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 102, in _request_response
await self._write_data(request_data)
File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 57, in _write_data
await self.client.write_gatt_char(self.write_char, chunk, response=False)
File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 776, in write_gatt_char
await self._backend.write_gatt_char(characteristic, data, response)
File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 77, in _async_wrap_bluetooth_operation
return await func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 594, in write_gatt_char
self._raise_if_not_connected()
File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 724, in _raise_if_not_connected
raise BleakError(f"{self._description} is not connected")
bleak.exc.BleakError: beer-temp [C0:49:EF:FA:19:CC]: Mowie - 74:46:B3:43:F7:4D is not connected

I've added the Mower Model trick bij adding "Mowie" to the init.py, but this doesn't change anything. The bluetooth icon on the mower does goes on for a few seconds. The Security Level on the mower is on Low, but with a PIN. I've added the mower the first time after rebooting it, and after a few tries I got rid of the Authentication Error. @peternijssen, I see that you were also trying to get the Gardena Mower to work, have you done something to get it working? I'm not very deep into coding, but if somebody can point me in the right direction I can debug my mower so that more people can enjoy this!

djungelola commented 6 months ago

I've taken a morning to try to add my Gardena Sileno City 470, but unfortunately I'm not getting it to stay paired, as it seams.

2024-05-02 12:31:59.173 DEBUG (MainThread) [custom_components.husqvarna_automower_ble] connecting to 74:46:B3:43:F7:4D with channel ID 3494508022
2024-05-02 12:31:59.173 INFO (MainThread) [automower_ble.mower] starting scan...
2024-05-02 12:31:59.173 INFO (MainThread) [automower_ble.mower] connecting to device...
2024-05-02 12:31:59.753 INFO (MainThread) [automower_ble.mower] connected
2024-05-02 12:31:59.753 INFO (MainThread) [automower_ble.mower] pairing device...
2024-05-02 12:32:00.172 INFO (MainThread) [automower_ble.mower] paired
2024-05-02 12:32:00.172 INFO (MainThread) [automower_ble.mower] [Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 1): Generic Access Profile
2024-05-02 12:32:00.468 DEBUG (MainThread) [automower_ble.mower] [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 3): Device Name (read), Value: bytearray(b'Mowie')
2024-05-02 12:32:00.582 DEBUG (MainThread) [automower_ble.mower] [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 5): Appearance (read), Value: bytearray(b'\x00\x00')
2024-05-02 12:32:00.779 DEBUG (MainThread) [automower_ble.mower] [Characteristic] 00002a04-0000-1000-8000-00805f9b34fb (Handle: 7): Peripheral Preferred Connection Parameters (read), Value: bytearray(b'P\x00\xa0\x00\x00\x00\xe8\x03')
2024-05-02 12:32:00.780 INFO (MainThread) [automower_ble.mower] [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile
2024-05-02 12:32:00.780 INFO (MainThread) [automower_ble.mower] [Service] 98bd0001-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 9): Husqvarna
2024-05-02 12:32:00.780 DEBUG (MainThread) [automower_ble.mower] [Characteristic] 98bd0002-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 11): Unknown (write-without-response)
2024-05-02 12:32:00.908 DEBUG (MainThread) [automower_ble.mower] [Characteristic] 98bd0003-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 14): Unknown (read,notify), Value: bytearray(b'')
2024-05-02 12:32:01.079 DEBUG (MainThread) [automower_ble.mower] [Characteristic] 98bd0004-0b0e-421a-84e5-ddbf75dc6de4 (Handle: 18): Unknown (read), Value: bytearray(b'Automower\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-05-02 12:32:06.098 INFO (MainThread) [automower_ble.mower] Writing: b'02fd160000000000002e14f6f549d0000000004d61696e002103'
2024-05-02 12:32:06.099 DEBUG (MainThread) [automower_ble.mower] Finished writing
2024-05-02 12:32:16.100 ERROR (MainThread) [automower_ble.mower] Unable to get response from device: '74:46:B3:43:F7:4D'
2024-05-02 12:32:16.101 INFO (MainThread) [automower_ble.mower] disconnecting...
2024-05-02 12:32:16.186 INFO (MainThread) [automower_ble.mower] disconnected
2024-05-02 12:32:16.186 INFO (MainThread) [automower_ble.mower] Writing: b'02fd160000000000002e14f6f549d0000000004d61696e002103'
2024-05-02 12:32:16.186 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Husqvarna Automower for husqvarna_automower_ble
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 575, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/husqvarna_automower_ble/__init__.py", line 39, in async_setup_entry
if not await mower.connect(device):
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 191, in connect
response = await self._request_response(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 102, in _request_response
await self._write_data(request_data)
File "/usr/local/lib/python3.12/site-packages/automower_ble/mower.py", line 57, in _write_data
await self.client.write_gatt_char(self.write_char, chunk, response=False)
File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 776, in write_gatt_char
await self._backend.write_gatt_char(characteristic, data, response)
File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 77, in _async_wrap_bluetooth_operation
return await func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 594, in write_gatt_char
self._raise_if_not_connected()
File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 724, in _raise_if_not_connected
raise BleakError(f"{self._description} is not connected")
bleak.exc.BleakError: beer-temp [C0:49:EF:FA:19:CC]: Mowie - 74:46:B3:43:F7:4D is not connected

I've added the Mower Model trick bij adding "Mowie" to the init.py, but this doesn't change anything. The bluetooth icon on the mower does goes on for a few seconds. The Security Level on the mower is on Low, but with a PIN. I've added the mower the first time after rebooting it, and after a few tries I got rid of the Authentication Error. @peternijssen, I see that you were also trying to get the Gardena Mower to work, have you done something to get it working? I'm not very deep into coding, but if somebody can point me in the right direction I can debug my mower so that more people can enjoy this!

Reload the integration in HA usually does the trick, especially if the mower is docked and fully charged.

peternijssen commented 6 months ago

I've also hardcoded the pincode in the await Mower(...) methods (2x) within the Home Assistant component. Not sure if that made a difference. Furthermore I've just tried dozens of times 😅

In regards to connectivity drop outs, it seems like when it's mowing, it doesn't appear to get unavailable. Almost an hour without drop out reports while otherwise it does often.

Scherm­afbeelding 2024-05-04 om 16 02 34
The-Paran0id-Andr0id commented 6 months ago

Hi there, please excuse my stupid question. Can someone please explain this step in more detail with the installation of the custom add_on, please? I tried in HACS and in the Add ons by adding the custom repository without success. I have to go in Settings > Integrations > Add ... and then? "In Home assistant, go into Integrations and click ADD, find the custom add_on and..." Thanks for your help and your work on this solution. Great idea!!

See instructions here: #5 (comment)

Thank you. Can you please also give me a hint on how to install the integration in HA? I have copied the 'automower_ble' directory to '/homeassistant/custom_components', but cannot find it under Settings/Integration to add it. What else do I need to do?