Remove deprecated yaml config from honeywell (#62469)

This commit is contained in:
Robert Hillis 2021-12-21 04:53:07 -05:00 committed by GitHub
parent 3898dfd248
commit d1980e7351
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 82 deletions

View File

@ -5,9 +5,8 @@ import datetime
from typing import Any
import somecomfort
import voluptuous as vol
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate.const import (
ATTR_TARGET_TEMP_HIGH,
ATTR_TARGET_TEMP_LOW,
@ -31,25 +30,12 @@ from homeassistant.components.climate.const import (
SUPPORT_TARGET_TEMPERATURE,
SUPPORT_TARGET_TEMPERATURE_RANGE,
)
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.const import (
ATTR_TEMPERATURE,
CONF_PASSWORD,
CONF_REGION,
CONF_USERNAME,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
)
import homeassistant.helpers.config_validation as cv
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
from .const import (
_LOGGER,
CONF_COOL_AWAY_TEMPERATURE,
CONF_DEV_ID,
CONF_HEAT_AWAY_TEMPERATURE,
CONF_LOC_ID,
DEFAULT_COOL_AWAY_TEMPERATURE,
DEFAULT_HEAT_AWAY_TEMPERATURE,
DOMAIN,
)
@ -59,25 +45,6 @@ ATTR_PERMANENT_HOLD = "permanent_hold"
PRESET_HOLD = "Hold"
PLATFORM_SCHEMA = vol.All(
cv.deprecated(CONF_REGION),
PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(
CONF_COOL_AWAY_TEMPERATURE, default=DEFAULT_COOL_AWAY_TEMPERATURE
): vol.Coerce(int),
vol.Optional(
CONF_HEAT_AWAY_TEMPERATURE, default=DEFAULT_HEAT_AWAY_TEMPERATURE
): vol.Coerce(int),
vol.Optional(CONF_REGION): cv.string,
vol.Optional(CONF_DEV_ID): cv.string,
vol.Optional(CONF_LOC_ID): cv.string,
}
),
)
HVAC_MODE_TO_HW_MODE = {
"SwitchOffAllowed": {HVAC_MODE_OFF: "off"},
"SwitchAutoAllowed": {HVAC_MODE_HEAT_COOL: "auto"},
@ -127,26 +94,6 @@ async def async_setup_entry(hass, config, async_add_entities, discovery_info=Non
)
async def async_setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Honeywell climate platform.
Honeywell uses config flow for configuration now. If an entry exists in
configuration.yaml, the import flow will attempt to import it and create
a config entry.
"""
if config["platform"] == "honeywell":
_LOGGER.warning(
"Loading honeywell via platform config is deprecated; The configuration"
" has been migrated to a config entry and can be safely removed"
)
# No config entry exists and configuration.yaml config exists, trigger the import flow.
if not hass.config_entries.async_entries(DOMAIN):
await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=config
)
class HoneywellUSThermostat(ClimateEntity):
"""Representation of a Honeywell US Thermostat."""

View File

@ -5,7 +5,7 @@ from homeassistant import config_entries
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from . import get_somecomfort_client
from .const import CONF_COOL_AWAY_TEMPERATURE, CONF_HEAT_AWAY_TEMPERATURE, DOMAIN
from .const import DOMAIN
class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@ -42,14 +42,3 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
return client is not None
async def async_step_import(self, import_data):
"""Import entry from configuration.yaml."""
return await self.async_step_user(
{
CONF_USERNAME: import_data[CONF_USERNAME],
CONF_PASSWORD: import_data[CONF_PASSWORD],
CONF_COOL_AWAY_TEMPERATURE: import_data[CONF_COOL_AWAY_TEMPERATURE],
CONF_HEAT_AWAY_TEMPERATURE: import_data[CONF_HEAT_AWAY_TEMPERATURE],
}
)

View File

@ -3,8 +3,6 @@ import logging
DOMAIN = "honeywell"
DEFAULT_COOL_AWAY_TEMPERATURE = 88
DEFAULT_HEAT_AWAY_TEMPERATURE = 61
CONF_COOL_AWAY_TEMPERATURE = "away_cool_temperature"
CONF_HEAT_AWAY_TEMPERATURE = "away_heat_temperature"
CONF_DEV_ID = "thermostat"

View File

@ -5,7 +5,7 @@ import somecomfort
from homeassistant import data_entry_flow
from homeassistant.components.honeywell.const import DOMAIN
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
from homeassistant.config_entries import SOURCE_USER
from homeassistant.core import HomeAssistant
FAKE_CONFIG = {
@ -49,15 +49,3 @@ async def test_create_entry(hass: HomeAssistant) -> None:
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["data"] == FAKE_CONFIG
async def test_async_step_import(hass: HomeAssistant) -> None:
"""Test that the import step works."""
with patch(
"somecomfort.SomeComfort",
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=FAKE_CONFIG
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["data"] == FAKE_CONFIG