mirror of
https://github.com/home-assistant/core
synced 2024-09-06 10:29:55 +02:00
Remove YAML support from hunterdouglas_powerview (#45376)
This commit is contained in:
parent
db83aea1df
commit
d733292982
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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", {})
|
||||
|
Loading…
Reference in New Issue
Block a user