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

Uncaught exception #4

Open
1 task done
clanterns11 opened this issue Jan 25, 2023 · 2 comments
Open
1 task done

Uncaught exception #4

clanterns11 opened this issue Jan 25, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@clanterns11
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Stack trace

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 96, in _async_wrap_bluetooth_operation
return await func(self, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 540, in write_gatt_char
await self._client.bluetooth_gatt_write(
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 667, in bluetooth_gatt_write
await self._send_bluetooth_message_await_response(
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 440, in _send_bluetooth_message_await_response
raise BluetoothGATTAPIError(BluetoothGATTError.from_pb(resp[0]))
aioesphomeapi.core.BluetoothGATTAPIError: Bluetooth GATT Error address=90:38:0C:61:82:42 handle=21 error=-1 description=Not connected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/pysnooz/commands.py", line 171, in _async_execute_wrapper
await self._async_execute(api)
File "/usr/local/lib/python3.10/site-packages/pysnooz/commands.py", line 261, in _async_execute
await api.async_set_power(self.command.on)
File "/usr/local/lib/python3.10/site-packages/pysnooz/api.py", line 86, in async_set_power
await self._async_write_command(CommandId.SET_POWER, b"\x01" if on else b"\x00")
File "/usr/local/lib/python3.10/site-packages/pysnooz/api.py", line 129, in _async_write_command
await self._client.write_gatt_char(
File "/usr/local/lib/python3.10/site-packages/bleak/init.py", line 593, in write_gatt_char
await self._backend.write_gatt_char(char_specifier, data, response)
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 79, in _async_wrap_bluetooth_connected_operation
await task
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 117, in _async_wrap_bluetooth_operation
self._async_ble_device_disconnected()
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 197, in _async_ble_device_disconnected
self._async_disconnected_cleanup()
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 192, in _async_disconnected_cleanup
self._unsubscribe_connection_state()
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 168, in _unsubscribe_connection_state
self._cancel_connection_state()
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 534, in unsub
self._connection.remove_message_callback(on_msg, msg_types)
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/connection.py", line 455, in remove_message_callback
self._message_handlers[msg_type].remove(on_message)
KeyError: <class 'api_pb2.BluetoothDeviceConnectionResponse'>

Environment

Home Assistant Component

Additional details

Home Assistant 2023.1.7
Supervisor 2022.12.1
Operating System 9.4
Frontend 20230110.0 - latest

Using ESPHome bluetooth proxy. Snooz stops working randomly unless I restart Home Assistant.

@clanterns11 clanterns11 added the bug Something isn't working label Jan 25, 2023
@AustinBrunkhorst
Copy link
Owner

Thanks for reporting this. It appears that there's a disconnection scenario that's not handled gracefully by pysnooz that's unique to bluetooth proxies. I haven't been available in the last month to work on this, but I'm hoping to get to this soon.

The fix should be straightforward - I think the first step is figuring out if this should be handled in esphome or this library, since currently the library is not aware of esphome or its implementation details.

@AustinBrunkhorst
Copy link
Owner

Following up on this issue. @clanterns11 can you verify this still occurs on the latest releases of ESPHome bluetooth proxies? If it does, please enable debug logs so we can isolate the issue.

# Home Assistant configuration.yaml
logger:
  default: info
  logs:
    homeassistant.components.snooz: debug
    pysnooz: debug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants