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.81k stars 30.51k forks source link

Changing entity ID causes error upon reload of KNX integration #103116

Closed DarkWarden85 closed 2 months ago

DarkWarden85 commented 12 months ago

The problem

Hello,

If I change an entity ID belonging to the KNX integration and then reload the KNX integration, I always get an error message in the logs:

Logger: homeassistant.config_entries
Source: config_entries.py:565
First occurred: 11:35:02 (1 occurrences)
Last logged: 11:35:02

Error unloading entry Automatic for date
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 565, in async_unload
    result = await component.async_unload_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/date/__init__.py", line 62, in async_unload_entry
    return await component.async_unload_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in async_unload_entry
    await platform.async_reset()
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 766, in async_reset
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1078, in async_remove
    self._call_on_remove_callbacks()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1040, in _call_on_remove_callbacks
    self._on_remove.pop()()
  File "/usr/local/lib/python3.11/site-packages/xknx/devices/device.py", line 56, in shutdown
    self.xknx.devices.remove(self)
  File "/usr/local/lib/python3.11/site-packages/xknx/devices/devices.py", line 75, in remove
    self.__devices.remove(device)
ValueError: list.remove(x): x not in list

Furthermore, the KNX-Integration then becomes unavailable and I have to restart Home Assistant in order for it to work again. After that, the entity ID is changed and everything works again as expected. This seems to happen for every domain and is not specific to KNX date, I just picked it as an example for this issue description.

image

Do I have to follow a strict procedure when trying to change entity IDs or is this a bug?

What version of Home Assistant Core has the issue?

core-2023.10.5

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

KNX

Link to integration documentation on our website

https://www.home-assistant.io/integrations/knx/

Diagnostics information

config_entry-knx-ad3d2c8db44408b4e68f29f9fd46be3d.json.txt

Example YAML snippet

knx:
  date:
    - name: "Temps - Date"
      address: "1/0/100"
      sync_state: false

Anything in the logs that might be useful for us?

Logger: homeassistant.config_entries
Source: config_entries.py:565
First occurred: 11:35:02 (1 occurrences)
Last logged: 11:35:02

Error unloading entry Automatic for date
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 565, in async_unload
    result = await component.async_unload_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/date/__init__.py", line 62, in async_unload_entry
    return await component.async_unload_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in async_unload_entry
    await platform.async_reset()
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 766, in async_reset
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1078, in async_remove
    self._call_on_remove_callbacks()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1040, in _call_on_remove_callbacks
    self._on_remove.pop()()
  File "/usr/local/lib/python3.11/site-packages/xknx/devices/device.py", line 56, in shutdown
    self.xknx.devices.remove(self)
  File "/usr/local/lib/python3.11/site-packages/xknx/devices/devices.py", line 75, in remove
    self.__devices.remove(device)
ValueError: list.remove(x): x not in list

Additional information

No response

home-assistant[bot] commented 12 months ago

Hey there @julius2342, @farmio, @marvin-w, mind taking a look at this issue as it has been labeled with an integration (knx) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `knx` 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 knx` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


knx documentation knx source (message by IssueLinks)

farmio commented 12 months ago

Hi 👋! Thanks for reporting. I'd say it is a bug. This will require some investigation. Related to https://github.com/home-assistant/core/issues/82158

Meanwhile restarting HA should resolve any issues caused by this as long as no entity ids get changed.

DarkWarden85 commented 12 months ago

Hi @farmio,

Thanks for looking into it. I can add that the bug is 100% reproducible, at least on my setup.

issue-triage-workflows[bot] commented 9 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

DarkWarden85 commented 9 months ago

The bug is still present in HA OS version 2024.1.5

issue-triage-workflows[bot] commented 6 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

DarkWarden85 commented 6 months ago

The issue is still present in HA 2024.4.4, so please don't close it.

issue-triage-workflows[bot] commented 3 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

DarkWarden85 commented 3 months ago

Still present in Home assistant 2024.7.3, so please don't close it.