Remove deprecated YAML configuration from VeSync (#52358)

This commit is contained in:
Franck Nijhof 2021-06-30 22:29:44 +02:00 committed by GitHub
parent 635cf59909
commit 04e631ed1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 54 deletions

View File

@ -2,9 +2,7 @@
import logging
from pyvesync import VeSync
import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_send
@ -25,42 +23,7 @@ PLATFORMS = ["switch", "fan", "light"]
_LOGGER = logging.getLogger(__name__)
CONFIG_SCHEMA = vol.Schema(
vol.All(
cv.deprecated(DOMAIN),
{
DOMAIN: vol.Schema(
{
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
}
)
},
),
extra=vol.ALLOW_EXTRA,
)
async def async_setup(hass, config):
"""Set up the VeSync component."""
conf = config.get(DOMAIN)
if conf is None:
return True
if not hass.config_entries.async_entries(DOMAIN):
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={
CONF_USERNAME: conf[CONF_USERNAME],
CONF_PASSWORD: conf[CONF_PASSWORD],
},
)
)
return True
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
async def async_setup_entry(hass, config_entry):

View File

@ -33,10 +33,6 @@ class VeSyncFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
errors=errors if errors else {},
)
async def async_step_import(self, import_config):
"""Handle external yaml configuration."""
return await self.async_step_user(import_config)
async def async_step_user(self, user_input=None):
"""Handle a flow start."""
if self._async_current_entries():

View File

@ -33,18 +33,6 @@ async def test_invalid_login_error(hass):
assert result["errors"] == {"base": "invalid_auth"}
async def test_config_flow_configuration_yaml(hass):
"""Test config flow with configuration.yaml user input."""
test_dict = {CONF_USERNAME: "user", CONF_PASSWORD: "pass"}
flow = config_flow.VeSyncFlowHandler()
flow.hass = hass
with patch("pyvesync.vesync.VeSync.login", return_value=True):
result = await flow.async_step_import(test_dict)
assert result["data"].get(CONF_USERNAME) == test_dict[CONF_USERNAME]
assert result["data"].get(CONF_PASSWORD) == test_dict[CONF_PASSWORD]
async def test_config_flow_user_input(hass):
"""Test config flow with user input."""
flow = config_flow.VeSyncFlowHandler()