From d73329298269dd79d1422269ebbef114e564b085 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 21 Jan 2021 12:51:08 -0600 Subject: [PATCH] Remove YAML support from hunterdouglas_powerview (#45376) --- .../hunterdouglas_powerview/__init__.py | 34 ++----------------- .../hunterdouglas_powerview/config_flow.py | 6 +--- .../test_config_flow.py | 31 ----------------- 3 files changed, 3 insertions(+), 68 deletions(-) diff --git a/homeassistant/components/hunterdouglas_powerview/__init__.py b/homeassistant/components/hunterdouglas_powerview/__init__.py index c87097dc7af..7555146ba8e 100644 --- a/homeassistant/components/hunterdouglas_powerview/__init__.py +++ b/homeassistant/components/hunterdouglas_powerview/__init__.py @@ -11,9 +11,8 @@ from aiopvapi.scenes import Scenes from aiopvapi.shades import Shades from aiopvapi.userdata import UserData import async_timeout -import voluptuous as vol -from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry +from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady @@ -58,25 +57,7 @@ from .const import ( PARALLEL_UPDATES = 1 - -DEVICE_SCHEMA = vol.Schema( - {DOMAIN: vol.Schema({vol.Required(CONF_HOST): cv.string})}, extra=vol.ALLOW_EXTRA -) - - -def _has_all_unique_hosts(value): - """Validate that each hub configured has a unique host.""" - hosts = [device[CONF_HOST] for device in value] - schema = vol.Schema(vol.Unique()) - schema(hosts) - return value - - -CONFIG_SCHEMA = vol.Schema( - {DOMAIN: vol.All(cv.ensure_list, [DEVICE_SCHEMA], _has_all_unique_hosts)}, - extra=vol.ALLOW_EXTRA, -) - +CONFIG_SCHEMA = cv.deprecated(DOMAIN) PLATFORMS = ["cover", "scene", "sensor"] _LOGGER = logging.getLogger(__name__) @@ -85,17 +66,6 @@ _LOGGER = logging.getLogger(__name__) async def async_setup(hass: HomeAssistant, hass_config: dict): """Set up the Hunter Douglas PowerView component.""" hass.data.setdefault(DOMAIN, {}) - - if DOMAIN not in hass_config: - return True - - for conf in hass_config[DOMAIN]: - hass.async_create_task( - hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=conf - ) - ) - return True diff --git a/homeassistant/components/hunterdouglas_powerview/config_flow.py b/homeassistant/components/hunterdouglas_powerview/config_flow.py index 2bbdcfea3a6..34ae94e4b88 100644 --- a/homeassistant/components/hunterdouglas_powerview/config_flow.py +++ b/homeassistant/components/hunterdouglas_powerview/config_flow.py @@ -79,10 +79,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): step_id="user", data_schema=DATA_SCHEMA, errors=errors ) - async def async_step_import(self, user_input=None): - """Handle the initial step.""" - return await self.async_step_user(user_input) - async def async_step_homekit(self, homekit_info): """Handle HomeKit discovery.""" @@ -126,7 +122,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): def _host_already_configured(self, host): """See if we already have a hub with the host address configured.""" existing_hosts = { - entry.data[CONF_HOST] + entry.data.get(CONF_HOST) for entry in self._async_current_entries() if CONF_HOST in entry.data } diff --git a/tests/components/hunterdouglas_powerview/test_config_flow.py b/tests/components/hunterdouglas_powerview/test_config_flow.py index dbcb5d719c9..b5b9ee84f27 100644 --- a/tests/components/hunterdouglas_powerview/test_config_flow.py +++ b/tests/components/hunterdouglas_powerview/test_config_flow.py @@ -69,37 +69,6 @@ async def test_user_form(hass): assert result4["type"] == "abort" -async def test_form_import(hass): - """Test we get the form with import source.""" - await setup.async_setup_component(hass, "persistent_notification", {}) - - mock_powerview_userdata = _get_mock_powerview_userdata() - with patch( - "homeassistant.components.hunterdouglas_powerview.UserData", - return_value=mock_powerview_userdata, - ), patch( - "homeassistant.components.hunterdouglas_powerview.async_setup", - return_value=True, - ) as mock_setup, patch( - "homeassistant.components.hunterdouglas_powerview.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.2.3.4"}, - ) - await hass.async_block_till_done() - - assert result["type"] == "create_entry" - assert result["title"] == "AlexanderHD" - assert result["data"] == { - "host": "1.2.3.4", - } - assert len(mock_setup.mock_calls) == 1 - assert len(mock_setup_entry.mock_calls) == 1 - - async def test_form_homekit(hass): """Test we get the form with homekit source.""" await setup.async_setup_component(hass, "persistent_notification", {})