From 5d9e462118769e455fff2efcb79fe5632d40d75f Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Thu, 25 Aug 2022 13:30:05 +0200 Subject: [PATCH] Add repair for deprecated MQTT yaml config (#77174) * Add repair for deprecated MQTT yaml config * Update homeassistant/components/mqtt/strings.json Co-authored-by: Erik Montnemery * Update homeassistant/components/mqtt/strings.json Co-authored-by: Martin Hjelmare * Add restart instruction * Update homeassistant/components/mqtt/strings.json Co-authored-by: Martin Hjelmare * Update English translation * update issue_registry imports * Update homeassistant/components/mqtt/manifest.json Co-authored-by: Martin Hjelmare Co-authored-by: Erik Montnemery Co-authored-by: Martin Hjelmare --- homeassistant/components/mqtt/mixins.py | 17 ++++++++++++++++- homeassistant/components/mqtt/strings.json | 6 ++++++ .../components/mqtt/translations/en.json | 8 +++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/mqtt/mixins.py b/homeassistant/components/mqtt/mixins.py index bb035198611..e4a24c0f5ad 100644 --- a/homeassistant/components/mqtt/mixins.py +++ b/homeassistant/components/mqtt/mixins.py @@ -28,7 +28,7 @@ from homeassistant.const import ( CONF_UNIQUE_ID, CONF_VALUE_TEMPLATE, ) -from homeassistant.core import Event, HomeAssistant, callback +from homeassistant.core import Event, HomeAssistant, async_get_hass, callback from homeassistant.helpers import ( config_validation as cv, device_registry as dr, @@ -48,6 +48,7 @@ from homeassistant.helpers.entity import ( async_generate_entity_id, ) from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue from homeassistant.helpers.json import json_loads from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType @@ -245,6 +246,20 @@ def warn_for_legacy_schema(domain: str) -> Callable: domain, ) warned.add(domain) + # Register a repair + async_create_issue( + async_get_hass(), + DOMAIN, + f"deprecated_yaml_{domain}", + breaks_in_ha_version="2022.12.0", # Warning first added in 2022.6.0 + is_fixable=False, + severity=IssueSeverity.WARNING, + translation_key="deprecated_yaml", + translation_placeholders={ + "more_info_url": f"https://www.home-assistant.io/integrations/{domain}.mqtt/#new_format", + "platform": domain, + }, + ) return config return validator diff --git a/homeassistant/components/mqtt/strings.json b/homeassistant/components/mqtt/strings.json index 155f9fcb4f2..e11f0a685e7 100644 --- a/homeassistant/components/mqtt/strings.json +++ b/homeassistant/components/mqtt/strings.json @@ -1,4 +1,10 @@ { + "issues": { + "deprecated_yaml": { + "title": "Your manually configured MQTT {platform}(s) needs attention", + "description": "Manually configured MQTT {platform}(s) found under platform key `{platform}`.\n\nPlease move the configuration to the `mqtt` integration key and restart Home Assistant to fix this issue. See the [documentation]({more_info_url}), for more information." + } + }, "config": { "step": { "broker": { diff --git a/homeassistant/components/mqtt/translations/en.json b/homeassistant/components/mqtt/translations/en.json index 23012946a71..724387dc923 100644 --- a/homeassistant/components/mqtt/translations/en.json +++ b/homeassistant/components/mqtt/translations/en.json @@ -1,5 +1,11 @@ { - "config": { + "issues": { + "deprecated_yaml": { + "title": "Your manually configured MQTT {platform}(s) needs attention", + "description": "Manually configured MQTT {platform}(s) found under platform key `{platform}`.\n\nPlease move the configuration to the `mqtt` integration key and restart Home Assistant to fix this issue. See the [documentation]({more_info_url}), for more information." + } + }, + "config": { "abort": { "already_configured": "Service is already configured", "single_instance_allowed": "Already configured. Only a single configuration possible."