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
74.01k stars 31.05k forks source link

[Bug] Matter devices often do not get removed #127055

Open Silther opened 1 month ago

Silther commented 1 month ago

The problem

I am using a SwitchBot Hub 2 connected to Home Assistant via Matter. It works as a Matter Hub exposing non Matter devices like a thermometer as a Matter devices. But It looks like Home Assistant Matter integration only detects new Matter devices (created via Switchbot Hub) but does not remove old Matter devices which are no longer exposed through the Switchbot Hub.

What version of Home Assistant Core has the issue?

core-2024.9.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Matter Integration

Link to integration documentation on our website

No response

Diagnostics information

Matter integration: config_entry-matter-01J852JQFX5R3FK1Q5JRTQE489.json

button which didn't get removed: matter-01J852JQFX5R3FK1Q5JRTQE489-GenericSwitch-c99dbe4aec69b18ccf5ca843f005baff.json

button readded via switchbot app (now it shows 2 times, the old version is not working): matter-01J852JQFX5R3FK1Q5JRTQE489-GenericSwitch-7e10a81025d1dc3496ce365003bac83c.json

Example YAML snippet

No response

Anything in the logs that might be useful for us?

When trying to delete non existing matter device:

---------------------------------------------------

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/connection.py:307
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 22:20:30 (2 occurrences)
Last logged: 22:36:58

[547422190848] Error handling message: Failed to remove device entry, rejected by integration (home_assistant_error) Silvan Weiß from 192.168.178.51 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0)
[547300092672] Error handling message: Failed to remove device entry, rejected by integration (home_assistant_error) Silvan Weiß from 192.168.178.51 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0)

---

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:761
integration: Sensor (documentation, issues)
First occurred: 22:19:20 (1 occurrences)
Last logged: 22:19:20

Platform matter does not generate unique IDs. ID 4B07A481B80D3205-0000000000000001-17-18-SwitchCurrentPosition-59-1 already exists - ignoring sensor.genericswitch_current_switch_position_3

---

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:245
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 22:21:20 (2 occurrences)
Last logged: 22:21:22

[547422190848] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 996, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1068, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/matter/switch.py", line 40, in async_turn_on
    await self.matter_client.send_device_command(
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/client.py", line 454, in send_device_command
    return await self.send_command(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/client.py", line 583, in send_command
    return await future
           ^^^^^^^^^^^^
matter_server.common.errors.UnknownError: InteractionModelError: UnsupportedEndpoint (0x7f)

Additional information

No response

home-assistant[bot] commented 1 month ago

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

Code owner commands Code owners of `matter` 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 matter` 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)


matter documentation matter source (message by IssueLinks)

marcelveldt commented 4 weeks ago

This works correctly in multiple bridges I have tested so this could perhaps be a switchbot issue or some race condition. We'll have to look at this after 2024.11 has landed (as that fixed a couple of related things in the code already)