Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError: cannot access local variable 'addr' where it is not associated with a value #10

Open
tjorim opened this issue Jun 20, 2023 · 1 comment

Comments

@tjorim
Copy link

tjorim commented Jun 20, 2023

I just updated to version f6a7b74 and my Sonicare was discovered. However when configuring said toothbrush, I got the following error:

This error originated from a custom integration.

Logger: custom_components.sonicare_bletb.config_flow
Source: components/esphome/bluetooth/client.py:317
Integration: sonicare_bletb
First occurred: 06:05:08 (1 occurrences)
Last logged: 06:05:08

Unexpected error
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 570, in bluetooth_device_connect
    await event.wait()
  File "/usr/local/lib/python3.11/asyncio/locks.py", line 213, in wait
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 603, in bluetooth_device_connect
    unsub()
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 565, in unsub
    self._connection.remove_message_callback(on_msg, msg_types)
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/connection.py", line 535, in remove_message_callback
    self._message_handlers[msg_type].remove(on_message)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: <class 'api_pb2.BluetoothDeviceConnectionResponse'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/sonicare_bletb/config_flow.py", line 64, in async_step_user
    await sonicare_ble.initialise()
  File "/usr/local/lib/python3.11/site-packages/sonicare_bletb/sonicare_bletb.py", line 265, in initialise
    await self._ensure_connected()
  File "/usr/local/lib/python3.11/site-packages/sonicare_bletb/sonicare_bletb.py", line 314, in _ensure_connected
    client = await establish_connection(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bleak_retry_connector/__init__.py", line 344, in establish_connection
    await client.connect(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/wrappers.py", line 272, in connect
    connected = await super().connect(**kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bleak/__init__.py", line 531, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 102, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 317, in connect
    await self._client.bluetooth_device_connect(
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 606, in bluetooth_device_connect
    "%s: Bluetooth device connection canceled but already unsubscribed",
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'addr' where it is not associated with a value
@jampez77
Copy link

Can I ask, does this integration work at all for you?

For me it discovered the brush but it is always unavailable. Is this the case for you too?

I didn't catch the logs when it was discovered but I will try the setup again when I get time to see if I get anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants