diff --git a/homeassistant/components/fritzbox/coordinator.py b/homeassistant/components/fritzbox/coordinator.py index 06454fa912a..54af8fbdacd 100644 --- a/homeassistant/components/fritzbox/coordinator.py +++ b/homeassistant/components/fritzbox/coordinator.py @@ -82,9 +82,9 @@ class FritzboxDataUpdateCoordinator(DataUpdateCoordinator[FritzboxCoordinatorDat def _update_fritz_devices(self) -> FritzboxCoordinatorData: """Update all fritzbox device data.""" try: - self.fritz.update_devices() + self.fritz.update_devices(ignore_removed=False) if self.has_templates: - self.fritz.update_templates() + self.fritz.update_templates(ignore_removed=False) except RequestConnectionError as ex: raise UpdateFailed from ex except HTTPError: @@ -93,9 +93,9 @@ class FritzboxDataUpdateCoordinator(DataUpdateCoordinator[FritzboxCoordinatorDat self.fritz.login() except LoginError as ex: raise ConfigEntryAuthFailed from ex - self.fritz.update_devices() + self.fritz.update_devices(ignore_removed=False) if self.has_templates: - self.fritz.update_templates() + self.fritz.update_templates(ignore_removed=False) devices = self.fritz.get_devices() device_data = {} @@ -124,14 +124,18 @@ class FritzboxDataUpdateCoordinator(DataUpdateCoordinator[FritzboxCoordinatorDat self.new_devices = device_data.keys() - self.data.devices.keys() self.new_templates = template_data.keys() - self.data.templates.keys() - if ( - self.data.devices.keys() - device_data.keys() - or self.data.templates.keys() - template_data.keys() - ): - self.cleanup_removed_devices(list(device_data) + list(template_data)) - return FritzboxCoordinatorData(devices=device_data, templates=template_data) async def _async_update_data(self) -> FritzboxCoordinatorData: """Fetch all device data.""" - return await self.hass.async_add_executor_job(self._update_fritz_devices) + new_data = await self.hass.async_add_executor_job(self._update_fritz_devices) + + if ( + self.data.devices.keys() - new_data.devices.keys() + or self.data.templates.keys() - new_data.templates.keys() + ): + self.cleanup_removed_devices( + list(new_data.devices) + list(new_data.templates) + ) + + return new_data diff --git a/homeassistant/components/fritzbox/manifest.json b/homeassistant/components/fritzbox/manifest.json index 5d41f8c12dc..de2e9e0200a 100644 --- a/homeassistant/components/fritzbox/manifest.json +++ b/homeassistant/components/fritzbox/manifest.json @@ -8,7 +8,7 @@ "iot_class": "local_polling", "loggers": ["pyfritzhome"], "quality_scale": "gold", - "requirements": ["pyfritzhome==0.6.10"], + "requirements": ["pyfritzhome==0.6.11"], "ssdp": [ { "st": "urn:schemas-upnp-org:device:fritzbox:1" diff --git a/requirements_all.txt b/requirements_all.txt index a5d370fce8b..240606435ba 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1836,7 +1836,7 @@ pyforked-daapd==0.1.14 pyfreedompro==1.1.0 # homeassistant.components.fritzbox -pyfritzhome==0.6.10 +pyfritzhome==0.6.11 # homeassistant.components.ifttt pyfttt==0.3 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 35c005fe4d3..51161b1afd3 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1432,7 +1432,7 @@ pyforked-daapd==0.1.14 pyfreedompro==1.1.0 # homeassistant.components.fritzbox -pyfritzhome==0.6.10 +pyfritzhome==0.6.11 # homeassistant.components.ifttt pyfttt==0.3