From c7ddc595ed7243be20e18b6f1b40dba5ea3e3fac Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 26 Jul 2022 01:09:59 +0200 Subject: [PATCH] Add issue to repairs for removed Spotify YAML configuration (#75736) * Add issue to repairs for removed Spotify YAML configuration * Tweak message --- homeassistant/components/spotify/__init__.py | 18 ++++++++++++++++++ homeassistant/components/spotify/manifest.json | 2 +- homeassistant/components/spotify/strings.json | 6 ++++++ .../components/spotify/translations/en.json | 6 ++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/spotify/__init__.py b/homeassistant/components/spotify/__init__.py index 7ee4e9649a5..83841a1780e 100644 --- a/homeassistant/components/spotify/__init__.py +++ b/homeassistant/components/spotify/__init__.py @@ -9,6 +9,7 @@ import aiohttp import requests from spotipy import Spotify, SpotifyException +from homeassistant.components.repairs import IssueSeverity, async_create_issue from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant @@ -18,6 +19,7 @@ from homeassistant.helpers.config_entry_oauth2_flow import ( OAuth2Session, async_get_config_entry_implementation, ) +from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from .browse_media import async_browse_media @@ -51,6 +53,22 @@ class HomeAssistantSpotifyData: session: OAuth2Session +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: + """Set up the Spotify integration.""" + if DOMAIN in config: + async_create_issue( + hass, + DOMAIN, + "removed_yaml", + breaks_in_ha_version="2022.8.0", + is_fixable=False, + severity=IssueSeverity.WARNING, + translation_key="removed_yaml", + ) + + return True + + async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Spotify from a config entry.""" implementation = await async_get_config_entry_implementation(hass, entry) diff --git a/homeassistant/components/spotify/manifest.json b/homeassistant/components/spotify/manifest.json index 2940700d230..0556cad26b7 100644 --- a/homeassistant/components/spotify/manifest.json +++ b/homeassistant/components/spotify/manifest.json @@ -4,7 +4,7 @@ "documentation": "https://www.home-assistant.io/integrations/spotify", "requirements": ["spotipy==2.20.0"], "zeroconf": ["_spotify-connect._tcp.local."], - "dependencies": ["application_credentials"], + "dependencies": ["application_credentials", "repairs"], "codeowners": ["@frenck"], "config_flow": true, "quality_scale": "silver", diff --git a/homeassistant/components/spotify/strings.json b/homeassistant/components/spotify/strings.json index caec5b8a288..4405bd21310 100644 --- a/homeassistant/components/spotify/strings.json +++ b/homeassistant/components/spotify/strings.json @@ -21,5 +21,11 @@ "info": { "api_endpoint_reachable": "Spotify API endpoint reachable" } + }, + "issues": { + "removed_yaml": { + "title": "The Spotify YAML configuration has been removed", + "description": "Configuring Spotify using YAML has been removed.\n\nYour existing YAML configuration is not used by Home Assistant.\n\nRemove the YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue." + } } } diff --git a/homeassistant/components/spotify/translations/en.json b/homeassistant/components/spotify/translations/en.json index 7136e5a8e71..0ccebc9833b 100644 --- a/homeassistant/components/spotify/translations/en.json +++ b/homeassistant/components/spotify/translations/en.json @@ -19,6 +19,12 @@ } } }, + "issues": { + "removed_yaml": { + "description": "Configuring Spotify using YAML has been removed.\n\nYour existing YAML configuration is not used by Home Assistant.\n\nRemove the YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue.", + "title": "The Spotify YAML configuration has been removed" + } + }, "system_health": { "info": { "api_endpoint_reachable": "Spotify API endpoint reachable"