From e0d8f0cc950509ee666cf0b8b3774f76bc76a397 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Wed, 10 Aug 2022 16:18:11 -0600 Subject: [PATCH] Add persistent repair items for deprecated Guardian services (#76312) Co-authored-by: Franck Nijhof --- homeassistant/components/guardian/__init__.py | 29 +++++++++++++++++-- .../components/guardian/manifest.json | 1 + .../components/guardian/strings.json | 13 +++++++++ .../components/guardian/translations/en.json | 13 +++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/guardian/__init__.py b/homeassistant/components/guardian/__init__.py index 58d70667cdf..909752b5b33 100644 --- a/homeassistant/components/guardian/__init__.py +++ b/homeassistant/components/guardian/__init__.py @@ -10,6 +10,7 @@ from aioguardian import Client from aioguardian.errors import GuardianError import voluptuous as vol +from homeassistant.components.repairs import IssueSeverity, async_create_issue from homeassistant.config_entries import ConfigEntry, ConfigEntryState from homeassistant.const import ( ATTR_DEVICE_ID, @@ -116,14 +117,34 @@ def async_log_deprecated_service_call( call: ServiceCall, alternate_service: str, alternate_target: str, + breaks_in_ha_version: str, ) -> None: """Log a warning about a deprecated service call.""" + deprecated_service = f"{call.domain}.{call.service}" + + async_create_issue( + hass, + DOMAIN, + f"deprecated_service_{deprecated_service}", + breaks_in_ha_version=breaks_in_ha_version, + is_fixable=True, + is_persistent=True, + severity=IssueSeverity.WARNING, + translation_key="deprecated_service", + translation_placeholders={ + "alternate_service": alternate_service, + "alternate_target": alternate_target, + "deprecated_service": deprecated_service, + }, + ) + LOGGER.warning( ( - 'The "%s" service is deprecated and will be removed in a future version; ' - 'use the "%s" service and pass it a target entity ID of "%s"' + 'The "%s" service is deprecated and will be removed in %s; use the "%s" ' + 'service and pass it a target entity ID of "%s"' ), - f"{call.domain}.{call.service}", + deprecated_service, + breaks_in_ha_version, alternate_service, alternate_target, ) @@ -235,6 +256,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: call, "button.press", f"button.guardian_valve_controller_{data.entry.data[CONF_UID]}_reboot", + "2022.10.0", ) await data.client.system.reboot() @@ -248,6 +270,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: call, "button.press", f"button.guardian_valve_controller_{data.entry.data[CONF_UID]}_reset_valve_diagnostics", + "2022.10.0", ) await data.client.valve.reset() diff --git a/homeassistant/components/guardian/manifest.json b/homeassistant/components/guardian/manifest.json index 7fab487563c..24dfbad13fe 100644 --- a/homeassistant/components/guardian/manifest.json +++ b/homeassistant/components/guardian/manifest.json @@ -3,6 +3,7 @@ "name": "Elexa Guardian", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/guardian", + "dependencies": ["repairs"], "requirements": ["aioguardian==2022.07.0"], "zeroconf": ["_api._udp.local."], "codeowners": ["@bachya"], diff --git a/homeassistant/components/guardian/strings.json b/homeassistant/components/guardian/strings.json index 4c60bfe4572..1665cf9f678 100644 --- a/homeassistant/components/guardian/strings.json +++ b/homeassistant/components/guardian/strings.json @@ -17,5 +17,18 @@ "already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]", "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]" } + }, + "issues": { + "deprecated_service": { + "title": "The {deprecated_service} service is being removed", + "fix_flow": { + "step": { + "confirm": { + "title": "The {deprecated_service} service is being removed", + "description": "Update any automations or scripts that use this service to instead use the `{alternate_service}` service with a target entity ID of `{alternate_target}`. Then, click SUBMIT below to mark this issue as resolved." + } + } + } + } } } diff --git a/homeassistant/components/guardian/translations/en.json b/homeassistant/components/guardian/translations/en.json index 310f550bcc1..ad6d0a4b7dc 100644 --- a/homeassistant/components/guardian/translations/en.json +++ b/homeassistant/components/guardian/translations/en.json @@ -17,5 +17,18 @@ "description": "Configure a local Elexa Guardian device." } } + }, + "issues": { + "deprecated_service": { + "fix_flow": { + "step": { + "confirm": { + "description": "Update any automations or scripts that use this service to instead use the `{alternate_service}` service with a target entity ID of `{alternate_target}`. Then, click SUBMIT below to mark this issue as resolved.", + "title": "The {deprecated_service} service is being removed" + } + } + }, + "title": "The {deprecated_service} service is being removed" + } } } \ No newline at end of file