Anrijs / Aranet4-Python

Aranet4, Aranet2 and Aranet Radiation Python client
MIT License
219 stars 19 forks source link

asyncio.exceptions.CancelledError #23

Open EarthK opened 2 years ago

EarthK commented 2 years ago

I have Raspberry Pi 4 Model B Rev 1.1 (Linux earth-ha 5.15.61-v7l+ #1579 SMP Fri Aug 26 11:13:03 BST 2022 armv7l GNU/Linux) and Aranet4 (firmware v0.4.10).

After I connected Aranet4 for the first time, everything was fine. With the command sudo aranetctl EF:C1:88:E1:31:D0 I got the actual data, but after a little while the following error appeared:

earth@earth-ha:~ $ sudo aranetctl EF:C1:88:E1:31:D0 Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/bleak/backends/bluezdbus/client.py", line 171, in connect reply = await self._bus.call( File "/usr/local/lib/python3.9/dist-packages/dbus_fast/aio/message_bus.py", line 337, in call await future asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/bin/aranetctl", line 33, in sys.exit(load_entry_point('aranet4==2.0.5', 'console_scripts', 'aranetctl')()) File "/usr/local/lib/python3.9/dist-packages/aranet4/aranetctl.py", line 236, in entry_point main(argv=sys.argv[1:]) File "/usr/local/lib/python3.9/dist-packages/aranet4/aranetctl.py", line 228, in main current = client.get_current_readings(args.device_mac) File "/usr/local/lib/python3.9/dist-packages/aranet4/client.py", line 451, in get_current_readings return asyncio.run(_current_reading(mac_address)) File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete return future.result() File "/usr/local/lib/python3.9/dist-packages/aranet4/client.py", line 441, in _current_reading await monitor.connect() File "/usr/local/lib/python3.9/dist-packages/aranet4/client.py", line 230, in connect await self.device.connect() File "/usr/local/lib/python3.9/dist-packages/bleak/init.py", line 392, in connect return await self._backend.connect(**kwargs) File "/usr/local/lib/python3.9/dist-packages/bleak/backends/bluezdbus/client.py", line 171, in connect reply = await self._bus.call( File "/usr/local/lib/python3.9/dist-packages/async_timeout/init.py", line 129, in aexit self._do_exit(exc_type) File "/usr/local/lib/python3.9/dist-packages/async_timeout/init.py", line 212, in _do_exit raise asyncio.TimeoutError asyncio.exceptions.TimeoutError

[bluetooth]# list Controller DC:A6:32:66:43:DF earth-ha [default] [bluetooth]# paired-devices Device EF:C1:88:E1:31:D0 Aranet4 00407

I can also see data coming from the Aranet device: [CHG] Device EF:C1:88:E1:31:D0 RSSI: -83

When the device is deleted in bluetoothctl and paired again, it is possible to receive data once again. Then the said error appears again.

Additionally and unrelatedly, when I got the data from Aranet, I found that the firmware version does not match what is shown on the phone.

earth@earth-ha:~ $ sudo aranetctl EF:C1:88:E1:31:D0


Connected: Aranet4 00407 | v0.3.1 Updated 12 s ago. Intervals: 120 s 5040 total log_size

CO2: 812 ppm Temperature: 21.3 °C Humidity: 56 % Pressure: 1009.7 hPa Battery: 76 % Status Display: GREEN

jonorthwash commented 1 year ago

I'm having this same issue. I have to remove the device and repair every time I run aranetctl; otherwise I get asyncio.exceptions.CancelledError just as @EarthK shared.