home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.18k stars 30.21k forks source link

IKEA Idasen desk disconnects multiple times daily and doesn’t move smoothly using ESP32 Bluetooth Proxy #105053

Closed bstephens16 closed 9 months ago

bstephens16 commented 10 months ago

The problem

The ESP32 is about 5ft from the desk controller. It disconnects multiple times per day and struggles to move between sit and stand positions without stopping and starting randomly.

Pressing the ‘connect’ button helps the desk reconnect once it becomes unavailable (I set up an automation to do this automatically). Overall works well, would love to provide and data/test any fixes if I can be of assistance.

What version of Home Assistant Core has the issue?

core-2023.12.0b1

What was the last working version of Home Assistant Core?

core-2023.12.0b1

What type of installation are you running?

Home Assistant OS

Integration causing the issue

IKEA Idasen

Link to integration documentation on our website

https://rc.home-assistant.io/integrations/idasen_desk

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

1. 
Logger: idasen
Source: components/idasen_desk/__init__.py:60
First occurred: 3:22:13 AM (68 occurrences)
Last logged: 7:22:26 PM

[DB:CD:5B:AE:35:37] Failed to connect, retrying (1/3)...
[DB:CD:5B:AE:35:37] Failed to connect, retrying (2/3)...
[DB:CD:5B:AE:35:37] Failed to connect, retrying (3/3)...
[DB:CD:5B:AE:35:37] Connection failed

2.
Logger: idasen_ha.connection_manager
Source: runner.py:188
First occurred: 7:22:23 PM (1 occurrences)
Last logged: 7:22:23 PM

Connect failed

3.
Logger: idasen
Source: runner.py:188
First occurred: 8:39:04 AM (7 occurrences)
Last logged: 7:22:23 PM

[DB:CD:5B:AE:35:37] stopped moving because desk safety feature kicked in
[DB:CD:5B:AE:35:37] Failed to connect, retrying (1/3)...
[DB:CD:5B:AE:35:37] Failed to connect, retrying (2/3)...
[DB:CD:5B:AE:35:37] Failed to connect, retrying (3/3)...
[DB:CD:5B:AE:35:37] Connection failed

4.
Logger: idasen_ha.connection_manager
Source: components/idasen_desk/__init__.py:60
First occurred: 12:19:58 PM (5 occurrences)
Last logged: 7:21:51 PM

Connect failed

5.
Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:238
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 7:12:50 PM (1 occurrences)
Last logged: 7:12:50 PM

[139744008775360] Failed to move to specified position: Bluetooth error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 79, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 539, in read_gatt_char
    return await self._client.bluetooth_gatt_read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 753, in bluetooth_gatt_read
    return await self._bluetooth_gatt_read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 783, in _bluetooth_gatt_read
    resp = await self._send_bluetooth_message_await_response(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 467, in _send_bluetooth_message_await_response
    self._raise_for_ble_connection_change(address, resp, msg_types)
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 695, in _raise_for_ble_connection_change
    raise BluetoothConnectionDroppedError(
aioesphomeapi.core.BluetoothConnectionDroppedError: Peripheral DB:CD:5B:AE:35:37 changed connection status while waiting for BluetoothGATTReadResponse, BluetoothGATTErrorResponse: Insufficient authorization (8)

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/idasen_desk/cover.py", line 99, in async_set_cover_position
    await self._desk.move_to(int(kwargs[ATTR_POSITION]))
  File "/usr/local/lib/python3.11/site-packages/idasen_ha/__init__.py", line 88, in move_to
    await self._idasen_desk.move_to_target(height)
  File "/usr/local/lib/python3.11/site-packages/idasen/__init__.py", line 343, in move_to_target
    await self._move_task
  File "/usr/local/lib/python3.11/site-packages/idasen/__init__.py", line 305, in do_move
    height = await self.get_height()
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/idasen/__init__.py", line 379, in get_height
    return _bytes_to_meters(await self._client.read_gatt_char(_UUID_HEIGHT))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bleak/__init__.py", line 711, in read_gatt_char
    return await self._backend.read_gatt_char(char_specifier, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 89, in _async_wrap_bluetooth_operation
    raise BleakError(str(ex)) from ex
bleak.exc.BleakError: Peripheral DB:CD:5B:AE:35:37 changed connection status while waiting for BluetoothGATTReadResponse, BluetoothGATTErrorResponse: Insufficient authorization (8)

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 238, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/idasen_desk/cover.py", line 101, in async_set_cover_position
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Failed to move to specified position: Bluetooth error

6.
Logger: aioesphomeapi.connection
Source: runner.py:188
First occurred: 6:00:35 AM (20 occurrences)
Last logged: 6:53:37 PM

esp32-bluetooth-proxy-c35d74 @ 10.0.4.65: Connection error occurred: [Errno 104] Connection reset by peer
esp32-bluetooth-proxy-c35d74 @ 10.0.4.65: Connection error occurred: esp32-bluetooth-proxy-c35d74 @ 10.0.4.65: EOF received
esp32-bluetooth-proxy-e4a358 @ 10.0.4.67: Connection error occurred: [Errno 104] Connection reset by peer

7.

Additional information

No response

home-assistant[bot] commented 10 months ago

Hey there @abmantis, mind taking a look at this issue as it has been labeled with an integration (idasen_desk) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `idasen_desk` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign idasen_desk` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


idasen_desk documentation idasen_desk source (message by IssueLinks)

abmantis commented 10 months ago

I would guess that there are wifi connectivity issues, and that is why it also does not move smoothly.

I think these logs are also an indication of wifi issues:

esp32-bluetooth-proxy-c35d74 @ 10.0.4.65: Connection error occurred: [Errno 104] Connection reset by peer
esp32-bluetooth-proxy-c35d74 @ 10.0.4.65: Connection error occurred: esp32-bluetooth-proxy-c35d74 @ 10.0.4.65: EOF received
esp32-bluetooth-proxy-e4a358 @ 10.0.4.67: Connection error occurred: [Errno 104] Connection reset by peer
bstephens16 commented 10 months ago

I would guess that there are wifi connectivity issues, and that is why it also does not move smoothly.

I think these logs are also an indication of wifi issues:

esp32-bluetooth-proxy-c35d74 @ 10.0.4.65: Connection error occurred: [Errno 104] Connection reset by peer
esp32-bluetooth-proxy-c35d74 @ 10.0.4.65: Connection error occurred: esp32-bluetooth-proxy-c35d74 @ 10.0.4.65: EOF received
esp32-bluetooth-proxy-e4a358 @ 10.0.4.67: Connection error occurred: [Errno 104] Connection reset by peer

Is there a way I could test this? I have 3 eero mesh routers, both ESP32's are less than 10 feet from their closest router and none of my other devices have wifi issues.

abmantis commented 10 months ago

Check the RSSI of the device, also ping it constantly and check if packages are dropped.

bstephens16 commented 9 months ago

Check the RSSI of the device, also ping it constantly and check if packages are dropped.

Thank you, I moved the device physically to a new location about 7ft from its original place and the connectivity improved significantly. Much more smooth operation and barely disconnecting 1-2x per day, vs the 10x per day previously.

abmantis commented 9 months ago

Thanks for the feedback!