mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Remove deprecated YAML configuration from VeSync (#52358)
This commit is contained in:
parent
635cf59909
commit
04e631ed1f
@ -2,9 +2,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pyvesync import VeSync
|
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.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
@ -25,42 +23,7 @@ PLATFORMS = ["switch", "fan", "light"]
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry):
|
async def async_setup_entry(hass, config_entry):
|
||||||
|
@ -33,10 +33,6 @@ class VeSyncFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
errors=errors if errors else {},
|
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):
|
async def async_step_user(self, user_input=None):
|
||||||
"""Handle a flow start."""
|
"""Handle a flow start."""
|
||||||
if self._async_current_entries():
|
if self._async_current_entries():
|
||||||
|
@ -33,18 +33,6 @@ async def test_invalid_login_error(hass):
|
|||||||
assert result["errors"] == {"base": "invalid_auth"}
|
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):
|
async def test_config_flow_user_input(hass):
|
||||||
"""Test config flow with user input."""
|
"""Test config flow with user input."""
|
||||||
flow = config_flow.VeSyncFlowHandler()
|
flow = config_flow.VeSyncFlowHandler()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user