omblepy icon indicating copy to clipboard operation
omblepy copied to clipboard

HEM-7600T: works only when bluetoothctl is running

Open shalak opened this issue 5 months ago • 4 comments

When I tried pairing and connecting to HEM-7600T, I kept getting the following error:

# python omblepy.py -d HEM-7600T --mac XX:XX:XX:XX:XX:XX --loggerDebug
2024-02-14 16:51:26,089 - omblepy - INFO - Attempt to import module for device hem-7600t
2024-02-14 16:51:26,134 - omblepy - INFO - Attempt connecting to XX:XX:XX:XX:XX:XX.
2024-02-14 16:51:32,465 - omblepy - INFO - unpair and disconnect
Traceback (most recent call last):
  File "/srv/services/omble/omblepy/omblepy.py", line 364, in main
    await bleClient.pair(protection_level = 2)
  File "/srv/services/omble/venv-omble/lib/python3.11/site-packages/bleak/__init__.py", line 629, in pair
    return await self._backend.pair(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/services/omble/venv-omble/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 473, in pair
    assert_reply(reply)
  File "/srv/services/omble/venv-omble/lib/python3.11/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.AuthenticationFailed] Authentication Failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/services/omble/omblepy/omblepy.py", line 389, in <module>
    asyncio.run(main())
  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/services/omble/omblepy/omblepy.py", line 387, in main
    await bleClient.disconnect()
  File "/srv/services/omble/venv-omble/lib/python3.11/site-packages/bleak/__init__.py", line 614, in disconnect
    return await self._backend.disconnect()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/services/omble/venv-omble/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 420, in disconnect
    assert self._bus is None
           ^^^^^^^^^^^^^^^^^
AssertionError

In the meantime, journalctl -u bluetooth.service showed:

lut 14 16:51:17 hostname bluetoothd[3979]: src/device.c:new_auth() No agent available for request type 2
lut 14 16:51:17 hostname bluetoothd[3979]: device_confirm_passkey: Operation not permitted

However, whenever I start bluetoothctl in other console windows (and keep it running), it does suceed to pair/sync, the user1.csv contains correct data and journalctl stays silent.

But still, it ends with an AssertionError:

# python omblepy.py -d HEM-7600T --mac XX:XX:XX:XX:XX:XX
2024-02-14 16:56:14,429 - omblepy - INFO - Attempt to import module for device hem-7600t
2024-02-14 16:56:14,468 - omblepy - INFO - Attempt connecting to XX:XX:XX:XX:XX:XX.
2024-02-14 16:56:21,527 - omblepy - INFO - communication started
2024-02-14 16:56:22,436 - omblepy - INFO - start reading data, this can take a while, use debug flag to see progress
2024-02-14 16:56:29,049 - omblepy - INFO - communication finished
2024-02-14 16:56:29,056 - omblepy - INFO - writing data to user1.csv
2024-02-14 16:56:29,062 - omblepy - INFO - unpair and disconnect
Traceback (most recent call last):
  File "/srv/services/omble/omblepy/omblepy.py", line 389, in <module>
    asyncio.run(main())
  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/services/omble/omblepy/omblepy.py", line 387, in main
    await bleClient.disconnect()
  File "/srv/services/omble/venv-omble/lib/python3.11/site-packages/bleak/__init__.py", line 614, in disconnect
    return await self._backend.disconnect()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/services/omble/venv-omble/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 420, in disconnect
    assert self._bus is None
           ^^^^^^^^^^^^^^^^^
AssertionError

I'm on Ubuntu 23.04 & bluetoothctl: 5.66, commit 1f43fefc835f5b40033b0df1d39525060bb8c096.

Is there anything I can do to fix this?

shalak avatar Feb 14 '24 17:02 shalak