From 88729715be3d72bcd1860b2e1a03a6083379f732 Mon Sep 17 00:00:00 2001 From: chemelli74 Date: Mon, 3 Jan 2022 20:08:45 +0000 Subject: [PATCH 1/4] Revert "Improve availability for Shelly Valve" This reverts commit d8cbd81b456820153522e6d86bbd00c4a4a31129. --- homeassistant/components/shelly/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/shelly/climate.py b/homeassistant/components/shelly/climate.py index cd2a5c247d5b0..9d3148fc4141b 100644 --- a/homeassistant/components/shelly/climate.py +++ b/homeassistant/components/shelly/climate.py @@ -187,7 +187,7 @@ def available(self) -> bool: """Device availability.""" if self.device_block is not None: return not cast(bool, self.device_block.valveError) - return self.wrapper.last_update_success + return True @property def hvac_mode(self) -> str: From ab5f9d42e2f514aba4a24ad58cb489ddffda7c9d Mon Sep 17 00:00:00 2001 From: chemelli74 Date: Sat, 8 Jan 2022 18:34:23 +0000 Subject: [PATCH 2/4] Add cleanup button --- homeassistant/components/fritz/button.py | 7 +++++++ homeassistant/components/fritz/common.py | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/fritz/button.py b/homeassistant/components/fritz/button.py index 2ec1b2dba3360..3ca54de95775e 100644 --- a/homeassistant/components/fritz/button.py +++ b/homeassistant/components/fritz/button.py @@ -58,6 +58,13 @@ class FritzButtonDescription(ButtonEntityDescription, FritzButtonDescriptionMixi entity_category=ENTITY_CATEGORY_CONFIG, press_action=lambda avm_device: avm_device.async_trigger_reconnect(), ), + FritzButtonDescription( + key="cleanup", + name="Cleanup", + icon="mdi:broom", + entity_category=ENTITY_CATEGORY_CONFIG, + press_action=lambda avm_device: avm_device.async_trigger_cleanup(), + ), ] diff --git a/homeassistant/components/fritz/common.py b/homeassistant/components/fritz/common.py index d70118c9c439f..3afbf0c361d39 100644 --- a/homeassistant/components/fritz/common.py +++ b/homeassistant/components/fritz/common.py @@ -385,13 +385,20 @@ async def async_trigger_reconnect(self) -> None: """Trigger device reconnect.""" await self.hass.async_add_executor_job(self.connection.reconnect) - async def async_trigger_cleanup(self, config_entry: ConfigEntry) -> None: + async def async_trigger_cleanup( + self, config_entry: ConfigEntry | None = None + ) -> None: """Trigger device trackers cleanup.""" device_hosts_list = await self.hass.async_add_executor_job( self.fritz_hosts.get_hosts_info ) entity_reg: er.EntityRegistry = er.async_get(self.hass) + if config_entry is None: + if self.config_entry is None: + return + config_entry = self.config_entry + ha_entity_reg_list: list[er.RegistryEntry] = er.async_entries_for_config_entry( entity_reg, config_entry.entry_id ) From 725a6b2ea068a33491ed49ee0f504912fc6784f9 Mon Sep 17 00:00:00 2001 From: chemelli74 Date: Sat, 8 Jan 2022 18:36:18 +0000 Subject: [PATCH 3/4] Wrong commit --- homeassistant/components/shelly/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/shelly/climate.py b/homeassistant/components/shelly/climate.py index 9d3148fc4141b..cd2a5c247d5b0 100644 --- a/homeassistant/components/shelly/climate.py +++ b/homeassistant/components/shelly/climate.py @@ -187,7 +187,7 @@ def available(self) -> bool: """Device availability.""" if self.device_block is not None: return not cast(bool, self.device_block.valveError) - return True + return self.wrapper.last_update_success @property def hvac_mode(self) -> str: From 3bbe9fc6eb33cd3633d8e68194292579b836a7d0 Mon Sep 17 00:00:00 2001 From: chemelli74 Date: Sat, 8 Jan 2022 18:37:48 +0000 Subject: [PATCH 4/4] Add service deprecation warning --- homeassistant/components/fritz/common.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/fritz/common.py b/homeassistant/components/fritz/common.py index 3afbf0c361d39..fdab1739ec976 100644 --- a/homeassistant/components/fritz/common.py +++ b/homeassistant/components/fritz/common.py @@ -478,6 +478,9 @@ async def service_fritzbox( return if service_call.service == SERVICE_CLEANUP: + _LOGGER.warning( + 'Service "fritz.cleanup" is deprecated, please use the corresponding button entity instead' + ) await self.async_trigger_cleanup(config_entry) return