Remove platform yaml radiotherm (#90284)

This commit is contained in:
G Johansson 2023-03-25 23:43:44 +01:00 committed by GitHub
parent 89d00ac733
commit 7f6406127e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 131 deletions

View file

@ -1,17 +1,14 @@
"""Support for Radio Thermostat wifi-enabled home thermostats."""
from __future__ import annotations
import logging
from typing import Any
import radiotherm
import voluptuous as vol
from homeassistant.components.climate import (
FAN_AUTO,
FAN_OFF,
FAN_ON,
PLATFORM_SCHEMA,
PRESET_AWAY,
PRESET_HOME,
ClimateEntity,
@ -19,25 +16,15 @@ from homeassistant.components.climate import (
HVACAction,
HVACMode,
)
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import (
ATTR_TEMPERATURE,
CONF_HOST,
PRECISION_HALVES,
UnitOfTemperature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, PRECISION_HALVES, UnitOfTemperature
from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv
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 DOMAIN
from .coordinator import RadioThermUpdateCoordinator
from .entity import RadioThermostatEntity
_LOGGER = logging.getLogger(__name__)
ATTR_FAN_ACTION = "fan_action"
PRESET_HOLIDAY = "holiday"
@ -102,14 +89,6 @@ def round_temp(temperature):
return round(temperature * 2.0) / 2.0
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Optional(CONF_HOST): vol.All(cv.ensure_list, [cv.string]),
vol.Optional(CONF_HOLD_TEMP, default=False): cv.boolean,
}
)
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
@ -120,51 +99,6 @@ async def async_setup_entry(
async_add_entities([RadioThermostat(coordinator)])
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Radio Thermostat."""
async_create_issue(
hass,
DOMAIN,
"deprecated_yaml",
breaks_in_ha_version="2022.9.0",
is_fixable=False,
severity=IssueSeverity.WARNING,
translation_key="deprecated_yaml",
)
_LOGGER.warning(
"Configuration of the Radio Thermostat climate platform in YAML is deprecated"
" and will be removed in Home Assistant 2022.9; Your existing configuration has"
" been imported into the UI automatically and can be safely removed from your"
" configuration.yaml file"
)
hosts: list[str] = []
if CONF_HOST in config:
hosts = config[CONF_HOST]
else:
hosts.append(
await hass.async_add_executor_job(radiotherm.discover.discover_address)
)
if not hosts:
_LOGGER.error("No Radiotherm Thermostats detected")
return
for host in hosts:
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={CONF_HOST: host},
)
)
class RadioThermostat(RadioThermostatEntity, ClimateEntity):
"""Representation of a Radio Thermostat."""

View file

@ -83,25 +83,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
description_placeholders=placeholders,
)
async def async_step_import(self, import_info: dict[str, Any]) -> FlowResult:
"""Import from yaml."""
host = import_info[CONF_HOST]
self._async_abort_entries_match({CONF_HOST: host})
_LOGGER.debug("Importing entry for host: %s", host)
try:
init_data = await validate_connection(self.hass, host)
except CannotConnect as ex:
_LOGGER.debug("Importing failed for %s", host, exc_info=ex)
return self.async_abort(reason="cannot_connect")
await self.async_set_unique_id(init_data.mac, raise_on_progress=False)
self._abort_if_unique_id_configured(
updates={CONF_HOST: host}, reload_on_update=False
)
return self.async_create_entry(
title=init_data.name,
data={CONF_HOST: import_info[CONF_HOST]},
)
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:

View file

@ -19,12 +19,6 @@
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
}
},
"issues": {
"deprecated_yaml": {
"title": "The Radio Thermostat YAML configuration is being removed",
"description": "Configuring the Radio Thermostat climate platform using YAML is being removed in Home Assistant 2022.9.\n\nYour existing configuration has been imported into the UI automatically. Remove the YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue."
}
},
"options": {
"step": {
"init": {

View file

@ -1,5 +1,5 @@
"""Test the Radio Thermostat config flow."""
import socket
from unittest.mock import MagicMock, patch
from radiotherm import CommonThermostat
@ -98,43 +98,6 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
assert result2["errors"] == {CONF_HOST: "cannot_connect"}
async def test_import(hass: HomeAssistant) -> None:
"""Test we get can import from yaml."""
with patch(
"homeassistant.components.radiotherm.data.radiotherm.get_thermostat",
return_value=_mock_radiotherm(),
), patch(
"homeassistant.components.radiotherm.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data={CONF_HOST: "1.2.3.4"},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["title"] == "My Name"
assert result["data"] == {CONF_HOST: "1.2.3.4"}
assert len(mock_setup_entry.mock_calls) == 1
async def test_import_cannot_connect(hass: HomeAssistant) -> None:
"""Test we abort if we cannot connect on import from yaml."""
with patch(
"homeassistant.components.radiotherm.data.radiotherm.get_thermostat",
side_effect=socket.timeout,
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data={CONF_HOST: "1.2.3.4"},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
async def test_dhcp_can_confirm(hass: HomeAssistant) -> None:
"""Test DHCP discovery flow can confirm right away."""