agustinamu / hassio-addons

Hassio Addons
Apache License 2.0
1 stars 0 forks source link

python 3.11 #8

Open fragolinux opened 7 months ago

fragolinux commented 7 months ago

hi, it seems there are a lot of issues with python 3.11, maybe better stick to a previous version? I read somewhere the even the package used, pybluez, is not maintained anymore...

2023-11-25 17:25:10 ERROR: [Vson_6003#060030393D3EE_60030393d3ee] connection problem, attempts=2
2023-11-25 17:25:14 INFO: Connected to 60:03:03:93:D3:EE
2023-11-25 17:25:15 INFO: [Vson_6003#060030393D3EE_60030393d3ee] send state=SensorState(temperature=21.5, tvoc=0.057, hcho=0.008, co2=584)
2023-11-25 17:25:35 INFO: [Vson_6003#060030393D3EE_60030393d3ee] send state=SensorState(temperature=21.5, tvoc=0.048, hcho=0.006, co2=582)
2023-11-25 17:25:55 INFO: [Vson_6003#060030393D3EE_60030393d3ee] send state=SensorState(temperature=21.5, tvoc=0.048, hcho=0.006, co2=582)
2023-11-25 17:25:58 WARNING: Restarting bluetoothd...
2023-11-25 17:25:58 ERROR: <Task finished name='Task-387' coro=<Ble2Mqtt.scan_devices_task() done, defined at /usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py:194> exception=FileNotFoundError(2, 'No such file or directory')> stopped unexpectedly
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 200, in scan_devices_task
    await restart_bluetooth(self._hci_adapter)
  File "/usr/lib/python3.11/site-packages/ble2mqtt/exceptions.py", line 52, in restart_bluetooth
    proc = await aio.create_subprocess_exec(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/subprocess.py", line 223, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 1694, in subprocess_exec
    transport = await self._make_subprocess_transport(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/unix_events.py", line 207, in _make_subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "/usr/lib/python3.11/asyncio/unix_events.py", line 818, in _start
    self._proc = subprocess.Popen(
                 ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1950, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'hciconfig'
2023-11-25 17:26:00 ERROR: Connection lost. Will retry in 10 seconds.
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 302, in _connect_mqtt_forever
    await self._run_device_tasks(mqtt_connection.disconnect_reason)
  File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 273, in _run_device_tasks
    await handle_returned_tasks(*finished)
  File "/usr/lib/python3.11/site-packages/ble2mqtt/tasks.py", line 79, in handle_returned_tasks
    await task_for_raise
  File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 200, in scan_devices_task
    await restart_bluetooth(self._hci_adapter)
  File "/usr/lib/python3.11/site-packages/ble2mqtt/exceptions.py", line 52, in restart_bluetooth
    proc = await aio.create_subprocess_exec(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/subprocess.py", line 223, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 1694, in subprocess_exec
    transport = await self._make_subprocess_transport(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/unix_events.py", line 207, in _make_subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "/usr/lib/python3.11/asyncio/unix_events.py", line 818, in _start
    self._proc = subprocess.Popen(
                 ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1950, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'hciconfig'
2023-11-25 17:26:11 INFO: Connected to core-mosquitto
2023-11-25 17:26:17 INFO: Connected to 60:03:03:93:D3:EE
2023-11-25 17:26:17 ERROR: Vson_6003#060030393D3EE_60030393d3ee raise an error in handle_queue, ignore it
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/ble2mqtt/protocols/base.py", line 86, in _handle_cmd_queue
    await self.process_command(command)
  File "/usr/lib/python3.11/site-packages/ble2mqtt/protocols/wp6003.py", line 82, in process_command
    ble_notification = await self.ble_get_notification(command.timeout)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ble2mqtt/protocols/base.py", line 52, in ble_get_notification
    raise ConnectionError(
ConnectionError: Vson_6003#060030393D3EE_60030393d3ee cannot fetch response, device is offline
2023-11-25 17:26:17 ERROR: [Vson_6003#060030393D3EE_60030393d3ee] connection problem, attempts=1
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/ble2mqtt/manager.py", line 447, in manage_device
    await device.get_device_data()
  File "/usr/lib/python3.11/site-packages/ble2mqtt/devices/vson_air_wp6003.py", line 108, in get_device_data
    await self.send_reset()
  File "/usr/lib/python3.11/site-packages/ble2mqtt/protocols/wp6003.py", line 39, in send_reset
    await self.send_command(bytes([CMD_RESET]), True, timeout=3)
  File "/usr/lib/python3.11/site-packages/ble2mqtt/protocols/wp6003.py", line 67, in send_command
    return await aio.wait_for(command.answer, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/tasks.py", line 489, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ble2mqtt/protocols/base.py", line 86, in _handle_cmd_queue
    await self.process_command(command)
  File "/usr/lib/python3.11/site-packages/ble2mqtt/protocols/wp6003.py", line 82, in process_command
    ble_notification = await self.ble_get_notification(command.timeout)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ble2mqtt/protocols/base.py", line 52, in ble_get_notification
    raise ConnectionError(
ConnectionError: Vson_6003#060030393D3EE_60030393d3ee cannot fetch response, device is offline
2023-11-25 17:26:25 INFO: Connected to 60:03:03:93:D3:EE
2023-11-25 17:26:25 INFO: [Vson_6003#060030393D3EE_60030393d3ee] send state=SensorState(temperature=21.5, tvoc=0.048, hcho=0.006, co2=582)
agustinamu commented 7 months ago

Hello @fragolinux

First of all, thank you very much for the issue. I have been looking for information about the problem with pybluez and Python 3.11 and trying to replicate your problem. Regarding the pybluez problem, I have not found much information, only difficulties in installing it on Windows (url) . I have also not been able to reproduce your error. I have tried it on an RPI4 and a virtual i386 machine.

Reviewing the log you provide, I see that it may be due to a problem that tries to restart the Bluetooth using the hciconfig command that is not installed (as I have been able to test). I think it can be solved by installing the bluez-deprecated package.

But I think the origin of the problem may be due to a recommendation given by @devbis in his repository:

ATTENTION: Make sure bluez is not running (or not intalled) on your host.

info

Please let me know if these changes solve your problem. Best regards.

fragolinux commented 7 months ago

Hi, I've haos x86 installed on an Intel nuc, so no way I can install bluez or anything else, if it's not already there...

I've some integrations active, like bthome and Bluetooth, of course, could be that? But I need them, unless an extended BT integration does everything...

devbis commented 7 months ago

Hi! Thanks for using ble2mqtt. As for docker documentation, it was written by users and I have never run ble2mqtt in docker, so I can say anything about stability.

No such file or directory: 'hciconfig'

Means that it tries to restart bluetooth adapter due to errors and failed to find hciconfig program. Originally, it was designed to work on a barebone linux with hcitools/bluez installed. I can handle missing hciconfig, but in this case it will not be able to resolve hardware errors that may occur.