rytilahti / python-eq3bt

Python library and command-line tool for eQ-3 Smart Bluetooth thermostats
MIT License
115 stars 36 forks source link

FileNotFoundError: [Errno 2] No such file or directory #61

Open wojtulab opened 2 years ago

wojtulab commented 2 years ago

Hello, I can't resolve following issue:

bash-5.1# eq3cli --mac='5C:E5:0C:B0:EF:88'
Traceback (most recent call last):
  File "/usr/local/bin/eq3cli", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1635, in invoke
    rv = super().invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/eq3bt/eq3cli.py", line 47, in cli
    thermostat.update()
  File "/usr/local/lib/python3.10/site-packages/eq3bt/eq3btsmart.py", line 217, in update
    self._conn.make_request(PROP_WRITE_HANDLE, value)
  File "/usr/local/lib/python3.10/site-packages/eq3bt/bleakconnection.py", line 106, in make_request
    with self:
  File "/usr/local/lib/python3.10/site-packages/eq3bt/bleakconnection.py", line 51, in __enter__
    self._loop.run_until_complete(self._conn.connect())
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 107, in connect
    device = await BleakScannerBlueZDBus.find_device_by_address(
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/scanner.py", line 221, in find_device_by_address
    return await cls.find_device_by_filter(
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/scanner.py", line 250, in find_device_by_filter
    async with cls(detection_callback=apply_filter, **kwargs):
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/scanner.py", line 96, in __aenter__
    await self.start()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 128, in start
    manager = await get_global_bluez_manager()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 812, in get_global_bluez_manager
    await instance.async_init()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 294, in async_init
    bus = MessageBus(bus_type=BusType.SYSTEM)
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 122, in __init__
    super().__init__(bus_address, bus_type, ProxyObject)
  File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 85, in __init__
    self._setup_socket()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 575, in _setup_socket
    raise err
  File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 548, in _setup_socket
    self._sock.connect(filename)
FileNotFoundError: [Errno 2] No such file or directory
bash-5.1#

bash-5.1# pip install --upgrade python-eq3bt Requirement already satisfied: python-eq3bt in /usr/local/lib/python3.10/site-packages (0.2) Requirement already satisfied: bleak in /usr/local/lib/python3.10/site-packages (from python-eq3bt) (0.15.1) Requirement already satisfied: click in /usr/local/lib/python3.10/site-packages (from python-eq3bt) (8.1.3) Requirement already satisfied: construct in /usr/local/lib/python3.10/site-packages (from python-eq3bt) (2.10.56) Requirement already satisfied: typing-extensions>=4.2.0 in /usr/local/lib/python3.10/site-packages (from bleak->python-eq3bt) (4.3.0) Requirement already satisfied: dbus-next in /usr/local/lib/python3.10/site-packages (from bleak->python-eq3bt) (0.2.3)

TechHummel commented 2 years ago

Hi, you can try switching the backend --backend [bleak|bluepy|gattlib] (remember to also install the other backends via pip). If you are running your script in a container, remember to mount dbus.

wojtulab commented 2 years ago

Actually dbus is mounted .

bash-5.1# ls /var/run/dbus
system_bus_socket

With bleak --backend bleak I have another error:

bash-5.1# eq3cli --mac='5C:E5:0C:B0:EF:88' --backend bleak
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/eq3bt/bleakconnection.py", line 106, in make_request
    with self:
  File "/usr/local/lib/python3.10/site-packages/eq3bt/bleakconnection.py", line 65, in __enter__
    self._loop.run_until_complete(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 835, in start_notify
    raise BleakError(
bleak.exc.BleakError: Characteristic with UUID 1056 could not be found!

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/eq3cli", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1635, in invoke
    rv = super().invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/eq3bt/eq3cli.py", line 47, in cli
    thermostat.update()
  File "/usr/local/lib/python3.10/site-packages/eq3bt/eq3btsmart.py", line 217, in update
    self._conn.make_request(PROP_WRITE_HANDLE, value)
  File "/usr/local/lib/python3.10/site-packages/eq3bt/bleakconnection.py", line 123, in make_request
    raise BackendException("Exception on write using bleak") from ex
eq3bt.BackendException: Exception on write using bleak
ERROR:asyncio:Task was destroyed but it is pending!
task: <Task pending name='Task-4' coro=<BleakClientBlueZDBus._disconnect_monitor() running at /usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py:247> wait_for=<Future pending cb=[Task.task_wakeup()]>>
bash-5.1#

in bluetoothctl I can pair the device, current status:

[bluetooth]# info 5C:E5:0C:B0:EF:88
Device 5C:E5:0C:B0:EF:88(public)
        Name: CC-RT-BLE
        Alias: CC-RT-BLE
        Paired: yes
        Trusted: yes
        Blocked: no
        Connected: no
        LegacyPairing: no
TechHummel commented 2 years ago

This behaviour is odd. Bleak is used by default, so the error messages shouldn't be different - not sure why this happens.

wojtulab commented 2 years ago

Ok what do i do? What do you suggest?

wojtulab commented 2 years ago

?

TechHummel commented 2 years ago

Sorry, not sure what to do here!