From 5d5b6bef55f871c0a073d3b4452ca6a7a2d54b75 Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Sun, 19 Dec 2021 11:55:27 -0500 Subject: [PATCH] Remove deprecated yaml config from opengarage (#61961) --- .../components/opengarage/config_flow.py | 13 +--- homeassistant/components/opengarage/cover.py | 52 +-------------- .../components/opengarage/test_config_flow.py | 66 ------------------- 3 files changed, 3 insertions(+), 128 deletions(-) diff --git a/homeassistant/components/opengarage/config_flow.py b/homeassistant/components/opengarage/config_flow.py index 6ddc186cb9c..c1b0ff7105e 100644 --- a/homeassistant/components/opengarage/config_flow.py +++ b/homeassistant/components/opengarage/config_flow.py @@ -9,7 +9,7 @@ import opengarage import voluptuous as vol from homeassistant import config_entries -from homeassistant.const import CONF_HOST, CONF_PORT, CONF_SSL, CONF_VERIFY_SSL +from homeassistant.const import CONF_HOST, CONF_PORT, CONF_VERIFY_SSL from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError @@ -58,17 +58,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): VERSION = 1 - async def async_step_import(self, import_info): - """Set the config entry up from yaml.""" - - user_input = { - CONF_DEVICE_KEY: import_info[CONF_DEVICE_KEY], - CONF_HOST: f"{'https' if import_info.get(CONF_SSL, False) else 'http'}://{import_info[CONF_HOST]}", - CONF_PORT: import_info.get(CONF_PORT, DEFAULT_PORT), - CONF_VERIFY_SSL: import_info.get(CONF_VERIFY_SSL, False), - } - return await self.async_step_user(user_input) - async def async_step_user( self, user_input: dict[str, Any] | None = None ) -> FlowResult: diff --git a/homeassistant/components/opengarage/cover.py b/homeassistant/components/opengarage/cover.py index 204ed093a9d..22a1d24c90b 100644 --- a/homeassistant/components/opengarage/cover.py +++ b/homeassistant/components/opengarage/cover.py @@ -1,70 +1,22 @@ """Platform for the opengarage.io cover component.""" import logging -import voluptuous as vol - -from homeassistant import config_entries from homeassistant.components.cover import ( - PLATFORM_SCHEMA, SUPPORT_CLOSE, SUPPORT_OPEN, CoverDeviceClass, CoverEntity, ) -from homeassistant.const import ( - CONF_COVERS, - CONF_HOST, - CONF_NAME, - CONF_PORT, - CONF_SSL, - CONF_VERIFY_SSL, - STATE_CLOSED, - STATE_CLOSING, - STATE_OPEN, - STATE_OPENING, -) +from homeassistant.const import STATE_CLOSED, STATE_CLOSING, STATE_OPEN, STATE_OPENING from homeassistant.core import callback -import homeassistant.helpers.config_validation as cv -from .const import CONF_DEVICE_KEY, DEFAULT_PORT, DOMAIN +from .const import DOMAIN from .entity import OpenGarageEntity _LOGGER = logging.getLogger(__name__) STATES_MAP = {0: STATE_CLOSED, 1: STATE_OPEN} -COVER_SCHEMA = vol.Schema( - { - vol.Required(CONF_DEVICE_KEY): cv.string, - vol.Required(CONF_HOST): cv.string, - vol.Optional(CONF_NAME): cv.string, - vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port, - vol.Optional(CONF_SSL, default=False): cv.boolean, - vol.Optional(CONF_VERIFY_SSL, default=True): cv.boolean, - } -) - -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - {vol.Required(CONF_COVERS): cv.schema_with_slug_keys(COVER_SCHEMA)} -) - - -async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): - """Set up the OpenGarage covers.""" - _LOGGER.warning( - "Open Garage YAML configuration is deprecated, " - "it has been imported into the UI automatically and can be safely removed" - ) - devices = config.get(CONF_COVERS) - for device_config in devices.values(): - hass.async_create_task( - hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data=device_config, - ) - ) - async def async_setup_entry(hass, entry, async_add_entities): """Set up the OpenGarage covers.""" diff --git a/tests/components/opengarage/test_config_flow.py b/tests/components/opengarage/test_config_flow.py index d421fb6a129..5406c40b3aa 100644 --- a/tests/components/opengarage/test_config_flow.py +++ b/tests/components/opengarage/test_config_flow.py @@ -134,69 +134,3 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None: assert result["type"] == RESULT_TYPE_ABORT assert result["reason"] == "already_configured" - - -async def test_step_import(hass: HomeAssistant) -> None: - """Test when import configuring from yaml.""" - with patch( - "opengarage.OpenGarage.update_state", - return_value={"name": "Name of the device", "mac": "unique"}, - ), patch( - "homeassistant.components.opengarage.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={ - "host": "1.1.1.1", - "device_key": "AfsasdnfkjDD", - "port": 1234, - "verify_ssl": False, - "ssl": False, - }, - ) - await hass.async_block_till_done() - - assert result["type"] == RESULT_TYPE_CREATE_ENTRY - assert result["title"] == "Name of the device" - assert result["data"] == { - "host": "http://1.1.1.1", - "device_key": "AfsasdnfkjDD", - "port": 1234, - "verify_ssl": False, - } - assert len(mock_setup_entry.mock_calls) == 1 - - -async def test_step_import_ssl(hass: HomeAssistant) -> None: - """Test when import configuring from yaml.""" - with patch( - "opengarage.OpenGarage.update_state", - return_value={"name": "Name of the device", "mac": "unique"}, - ), patch( - "homeassistant.components.opengarage.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={ - "host": "1.1.1.1", - "device_key": "AfsasdnfkjDD", - "port": 1234, - "verify_ssl": False, - "ssl": True, - }, - ) - await hass.async_block_till_done() - - assert result["type"] == RESULT_TYPE_CREATE_ENTRY - assert result["title"] == "Name of the device" - assert result["data"] == { - "host": "https://1.1.1.1", - "device_key": "AfsasdnfkjDD", - "port": 1234, - "verify_ssl": False, - } - assert len(mock_setup_entry.mock_calls) == 1