-
Notifications
You must be signed in to change notification settings - Fork 16
Error adding new device (object has no attribute '_cli') #57
Copy link
Copy link
Open
Description
Per issue 46 on the hassio-ftms integration, there is an error from the python-pyftms library when connecting to some new devices:
Traceback (most recent call last):
File "src/dbus_fast/message_bus.py", line 819, in dbus_fast.message_bus.BaseMessageBus._process_message
File "/usr/local/lib/python3.14/site-packages/bleak/backends/bluezdbus/manager.py", line 1121, in _parse_msg
watcher.on_connected_changed(new_connected)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/bleak/backends/bluezdbus/client.py", line 173, in on_connected_changed
self._disconnected_callback()
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.14/site-packages/pyftms/client/client.py", line 226, in _on_disconnect
del self._cli
^^^^^^^^^
AttributeError: 'Treadmill' object has no attribute '_cli'
Which in the current version tracks to line 245, or this function:
def _on_disconnect(self, cli: BleakClient) -> None:
_LOGGER.debug("Client disconnected. Reset updaters states.")
del self._cli
self._updater.reset()
self._controller.reset()
if self._disconnect_cb:
self._disconnect_cb(self)And it seems to be a race condition with the self._cli attribute not being created by the _connect function. Adding a check for it seemed to resolve the issue and the integration worked:
if hasattr(self, "_cli"):
del self._cliBut I'm not sure this is the best approach - honestly, deleting attributes on the class always seems a bit icky to me so it seems like this part should be refactored.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels