elupus / gardena-bluetooth

Gardena Bluetooth Python Module
MIT License
10 stars 3 forks source link

TimeoutError / asyncio.exceptions.CancelledError #5

Closed emanuelst closed 1 year ago

emanuelst commented 1 year ago

Hi, thanks for the integration!

I tried to set it up using home assistant (core) and immediately get to a note that says "No devices found on the network". So I tried to connect using this module directly.

Using python3 -m gardena_bluetooth scan I find a device with a Husqvarna service. I then tried to connect using python3 -m gardena_bluetooth connect, this leads to the asyncio.exceptions.CancelledError exception.

Is there something else I could try? I tried factory resetting a few times. Connecting using the official Gardena Bluetooth app works and I also did a firmware update to Firmware 1.7.23.29 today.

Exception ``` Connecting to: xx:xx:xx:xx:xx:xx Traceback (most recent call last): File "/srv/homeassistant/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 204, in connect reply = await self._bus.call( ^^^^^^^^^^^^^^^^^^^^^ File "/srv/homeassistant/lib/python3.11/site-packages/dbus_fast/aio/message_bus.py", line 370, in call await future asyncio.exceptions.CancelledError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/srv/homeassistant/lib/python3.11/site-packages/gardena_bluetooth/__main__.py", line 71, in main() File "/srv/homeassistant/lib/python3.11/site-packages/asyncclick/core.py", line 1157, in __call__ return anyio.run(self._main, main, args, kwargs, **opts) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/homeassistant/lib/python3.11/site-packages/anyio/_core/_eventloop.py", line 70, in run return asynclib.run(func, *args, **backend_options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/homeassistant/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 292, in run return native_run(wrapper(), debug=debug) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/srv/homeassistant/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper return await func(*args) ^^^^^^^^^^^^^^^^^ File "/srv/homeassistant/lib/python3.11/site-packages/asyncclick/core.py", line 1160, in _main return await main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/homeassistant/lib/python3.11/site-packages/asyncclick/core.py", line 1076, in main rv = await self.invoke(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/srv/homeassistant/lib/python3.11/site-packages/asyncclick/core.py", line 1687, in invoke return await _process_result(await sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/homeassistant/lib/python3.11/site-packages/asyncclick/core.py", line 1434, in invoke return await ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/homeassistant/lib/python3.11/site-packages/asyncclick/core.py", line 780, in invoke rv = await rv ^^^^^^^^ File "/srv/homeassistant/lib/python3.11/site-packages/gardena_bluetooth/__main__.py", line 44, in connect async with BleakClient(address, timeout=20) as client: File "/srv/homeassistant/lib/python3.11/site-packages/bleak/__init__.py", line 491, in __aenter__ await self.connect() File "/srv/homeassistant/lib/python3.11/site-packages/bleak/__init__.py", line 531, in connect return await self._backend.connect(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/homeassistant/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 141, in connect async with async_timeout(timeout): File "/usr/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__ raise TimeoutError from exc_val TimeoutError ```

Edit:

Sorry about the missing info – it's a Gardena Water Control Bluetooth and I'm trying to connect directly from a raspberry pi 4 running ubuntu.

I have a few bluetooth sensors integrated already with home assistant which work kinda well which made me wonder. Thanks for the quick answer, I'll try out a few more connections. But it should not be necessary to connect first using the python script, correct? It "should" work directly from home assistant? Thanks!

elupus commented 1 year ago

What device is this? Also how is bluetooth setup? Bluetooth controller drivers on linux are know to be rather hit and miss.

If you have any esp32 lying around you could try using it as a bluetooth gateway.

If you have a mac, you can try from it too.

elupus commented 1 year ago

Should work directly from HA.

emanuelst commented 1 year ago

Hi,

Thank you for your help! I set up an esp32 as ESPHome Bluetooth Proxy and was instantly able to connect. Weird that the raspberry bluetooth didn't work for this device, but with the esp32 it's working now so I'm closing this.

Thank you!