diff --git a/homeassistant/components/knx/climate.py b/homeassistant/components/knx/climate.py index 5690722ef2b..9820a8ff5e3 100644 --- a/homeassistant/components/knx/climate.py +++ b/homeassistant/components/knx/climate.py @@ -288,9 +288,3 @@ class KNXClimate(KnxEntity, ClimateEntity): await super().async_added_to_hass() if self._device.mode is not None: self._device.mode.register_device_updated_cb(self.after_update_callback) - - async def async_will_remove_from_hass(self) -> None: - """Disconnect device object when removed.""" - await super().async_will_remove_from_hass() - if self._device.mode is not None: - self._device.mode.unregister_device_updated_cb(self.after_update_callback) diff --git a/homeassistant/components/knx/knx_entity.py b/homeassistant/components/knx/knx_entity.py index 5f2e14d1466..fff7f9b9f4f 100644 --- a/homeassistant/components/knx/knx_entity.py +++ b/homeassistant/components/knx/knx_entity.py @@ -45,4 +45,5 @@ class KnxEntity(Entity): async def async_will_remove_from_hass(self) -> None: """Disconnect device object when removed.""" - self._device.unregister_device_updated_cb(self.after_update_callback) + # will also remove all callbacks + self._device.shutdown() diff --git a/homeassistant/components/knx/manifest.json b/homeassistant/components/knx/manifest.json index 604821ae275..0fdabcec9fb 100644 --- a/homeassistant/components/knx/manifest.json +++ b/homeassistant/components/knx/manifest.json @@ -3,7 +3,7 @@ "name": "KNX", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/knx", - "requirements": ["xknx==0.20.1"], + "requirements": ["xknx==0.20.2"], "codeowners": ["@Julius2342", "@farmio", "@marvin-w"], "quality_scale": "silver", "iot_class": "local_push", diff --git a/requirements_all.txt b/requirements_all.txt index f27030f4c97..3e86626bc51 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2438,7 +2438,7 @@ xbox-webapi==2.0.11 xboxapi==2.0.1 # homeassistant.components.knx -xknx==0.20.1 +xknx==0.20.2 # homeassistant.components.bluesound # homeassistant.components.fritz diff --git a/requirements_test_all.txt b/requirements_test_all.txt index d410601c378..3a2da5cf07a 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1578,7 +1578,7 @@ wolf_smartset==0.1.11 xbox-webapi==2.0.11 # homeassistant.components.knx -xknx==0.20.1 +xknx==0.20.2 # homeassistant.components.bluesound # homeassistant.components.fritz diff --git a/tests/components/knx/test_climate.py b/tests/components/knx/test_climate.py index c77e9c58398..50daa8b6951 100644 --- a/tests/components/knx/test_climate.py +++ b/tests/components/knx/test_climate.py @@ -158,9 +158,8 @@ async def test_climate_preset_mode(hass: HomeAssistant, knx: KNXTestKit): er.async_remove("climate.test") await hass.async_block_till_done() - assert len(knx.xknx.devices) == 2 - assert len(knx.xknx.devices[0].device_updated_cbs) == 1 - assert len(knx.xknx.devices[1].device_updated_cbs) == 1 + # If we remove the entity the underlying devices should disappear too + assert len(knx.xknx.devices) == 0 async def test_update_entity(hass: HomeAssistant, knx: KNXTestKit):