Remove deprecated Radarr YAML config (#81210)

pull/82709/head
Robert Hillis 2022-11-24 15:14:26 -05:00 committed by GitHub
parent a63581b5c8
commit c30ce12c49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 149 deletions

View File

@ -6,12 +6,10 @@ from typing import Any, cast
from aiopyarr.models.host_configuration import PyArrHostConfiguration
from aiopyarr.radarr_client import RadarrClient
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
ATTR_SW_VERSION,
CONF_API_KEY,
CONF_PLATFORM,
CONF_URL,
CONF_VERIFY_SSL,
Platform,
@ -20,8 +18,6 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo, EntityDescription
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DEFAULT_NAME, DOMAIN
@ -37,26 +33,6 @@ from .coordinator import (
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Steam integration."""
if SENSOR_DOMAIN not in config:
return True
for entry in config[SENSOR_DOMAIN]:
if entry[CONF_PLATFORM] == DOMAIN:
async_create_issue(
hass,
DOMAIN,
"deprecated_yaml",
breaks_in_ha_version="2022.10.0",
is_fixable=False,
severity=IssueSeverity.WARNING,
translation_key="deprecated_yaml",
)
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Radarr from a config entry."""
host_configuration = PyArrHostConfiguration(

View File

@ -11,19 +11,12 @@ from aiopyarr.radarr_client import RadarrClient
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.const import (
CONF_API_KEY,
CONF_HOST,
CONF_PORT,
CONF_SSL,
CONF_URL,
CONF_VERIFY_SSL,
)
from homeassistant.const import CONF_API_KEY, CONF_URL, CONF_VERIFY_SSL
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DEFAULT_NAME, DEFAULT_URL, DOMAIN, LOGGER
from .const import DEFAULT_NAME, DEFAULT_URL, DOMAIN
class RadarrConfigFlow(ConfigFlow, domain=DOMAIN):
@ -106,28 +99,6 @@ class RadarrConfigFlow(ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_import(self, config: dict[str, Any]) -> FlowResult:
"""Import a config entry from configuration.yaml."""
for entry in self._async_current_entries():
if entry.data[CONF_API_KEY] == config[CONF_API_KEY]:
_part = config[CONF_API_KEY][0:4]
_msg = f"Radarr yaml config with partial key {_part} has been imported. Please remove it"
LOGGER.warning(_msg)
return self.async_abort(reason="already_configured")
proto = "https" if config[CONF_SSL] else "http"
host_port = f"{config[CONF_HOST]}:{config[CONF_PORT]}"
path = ""
if config["urlbase"].rstrip("/") not in ("", "/", "/api"):
path = config["urlbase"].rstrip("/")
return self.async_create_entry(
title=DEFAULT_NAME,
data={
CONF_URL: f"{proto}://{host_port}{path}",
CONF_API_KEY: config[CONF_API_KEY],
CONF_VERIFY_SSL: False,
},
)
async def validate_input(
hass: HomeAssistant, data: dict[str, Any]

View File

@ -8,30 +8,23 @@ from datetime import datetime, timezone
from typing import Any, Generic
from aiopyarr import Diskspace, RootFolder, SystemStatus
import voluptuous as vol
from homeassistant.components.sensor import (
PLATFORM_SCHEMA,
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
)
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_API_KEY,
CONF_HOST,
CONF_MONITORED_CONDITIONS,
CONF_PORT,
CONF_SSL,
DATA_BYTES,
DATA_GIGABYTES,
DATA_KILOBYTES,
DATA_MEGABYTES,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import RadarrEntity
@ -112,22 +105,6 @@ BYTE_SIZES = [
DATA_MEGABYTES,
DATA_GIGABYTES,
]
# Deprecated in Home Assistant 2022.10
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_API_KEY): cv.string,
vol.Optional("days", default=1): cv.string,
vol.Optional(CONF_HOST, default="localhost"): cv.string,
vol.Optional("include_paths", default=[]): cv.ensure_list,
vol.Optional(CONF_MONITORED_CONDITIONS, default=["movies"]): vol.All(
cv.ensure_list
),
vol.Optional(CONF_PORT, default=7878): cv.port,
vol.Optional(CONF_SSL, default=False): cv.boolean,
vol.Optional("unit", default=DATA_GIGABYTES): cv.string,
vol.Optional("urlbase", default=""): cv.string,
}
)
PARALLEL_UPDATES = 1
@ -139,10 +116,14 @@ async def async_setup_platform(
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Radarr platform."""
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=config
)
async_create_issue(
hass,
DOMAIN,
"removed_yaml",
breaks_in_ha_version="2022.12.0",
is_fixable=False,
severity=IssueSeverity.WARNING,
translation_key="removed_yaml",
)

View File

@ -36,9 +36,9 @@
}
},
"issues": {
"deprecated_yaml": {
"title": "The Radarr YAML configuration is being removed",
"description": "Configuring Radarr using YAML is being removed.\n\nYour existing YAML configuration has been imported into the UI automatically.\n\nRemove the Radarr YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue."
"removed_yaml": {
"title": "The Radarr YAML configuration has been removed",
"description": "Configuring Radarr 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."
}
}
}

View File

@ -27,9 +27,9 @@
}
},
"issues": {
"deprecated_yaml": {
"description": "Configuring Radarr using YAML is being removed.\n\nYour existing YAML configuration has been imported into the UI automatically.\n\nRemove the Radarr YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue.",
"title": "The Radarr YAML configuration is being removed"
"removed_yaml": {
"title": "The Radarr YAML configuration has been removed",
"description": "Configuring Radarr 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."
}
},
"options": {

View File

@ -7,10 +7,6 @@ from aiohttp.client_exceptions import ClientError
from homeassistant.components.radarr.const import DOMAIN
from homeassistant.const import (
CONF_API_KEY,
CONF_HOST,
CONF_MONITORED_CONDITIONS,
CONF_PORT,
CONF_SSL,
CONF_URL,
CONF_VERIFY_SSL,
CONTENT_TYPE_JSON,
@ -32,15 +28,6 @@ MOCK_USER_INPUT = {
CONF_VERIFY_SSL: False,
}
CONF_IMPORT_DATA = {
CONF_API_KEY: API_KEY,
CONF_HOST: "192.168.1.189",
CONF_MONITORED_CONDITIONS: ["Stream count"],
CONF_PORT: "7887",
"urlbase": "/test",
CONF_SSL: False,
}
CONF_DATA = {
CONF_URL: URL,
CONF_API_KEY: API_KEY,

View File

@ -1,18 +1,17 @@
"""Test Radarr config flow."""
from unittest.mock import AsyncMock, patch
from unittest.mock import patch
from aiopyarr import exceptions
from homeassistant import data_entry_flow
from homeassistant.components.radarr.const import DEFAULT_NAME, DOMAIN
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_REAUTH, SOURCE_USER
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
from homeassistant.const import CONF_API_KEY, CONF_SOURCE, CONF_URL, CONF_VERIFY_SSL
from homeassistant.core import HomeAssistant
from . import (
API_KEY,
CONF_DATA,
CONF_IMPORT_DATA,
MOCK_REAUTH_INPUT,
MOCK_USER_INPUT,
URL,
@ -23,52 +22,9 @@ from . import (
setup_integration,
)
from tests.common import MockConfigEntry
from tests.test_util.aiohttp import AiohttpClientMocker
def _patch_setup():
return patch("homeassistant.components.radarr.async_setup_entry")
async def test_flow_import(hass: HomeAssistant):
"""Test import step."""
with patch(
"homeassistant.components.radarr.config_flow.RadarrClient.async_get_system_status",
return_value=AsyncMock(),
), _patch_setup():
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data=CONF_IMPORT_DATA,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == DEFAULT_NAME
assert result["data"] == CONF_DATA | {
CONF_URL: "http://192.168.1.189:7887/test"
}
assert result["data"][CONF_URL] == "http://192.168.1.189:7887/test"
async def test_flow_import_already_configured(hass: HomeAssistant):
"""Test import step already configured."""
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_INPUT)
entry.add_to_hass(hass)
with patch(
"homeassistant.components.radarr.config_flow.RadarrClient.async_get_system_status",
return_value=AsyncMock(),
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data=CONF_IMPORT_DATA,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"
async def test_show_user_form(hass: HomeAssistant) -> None:
"""Test that the user set up form is served."""
result = await hass.config_entries.flow.async_init(