Remove deprecated YAML configuration from Abode (#52357)

This commit is contained in:
Franck Nijhof 2021-06-30 22:28:57 +02:00 committed by GitHub
parent 4a94ed8f5a
commit 635cf59909
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 79 deletions

View File

@ -1,5 +1,4 @@
"""Support for the Abode Security System.""" """Support for the Abode Security System."""
from copy import deepcopy
from functools import partial from functools import partial
from abodepy import Abode from abodepy import Abode
@ -8,7 +7,6 @@ import abodepy.helpers.timeline as TIMELINE
from requests.exceptions import ConnectTimeout, HTTPError from requests.exceptions import ConnectTimeout, HTTPError
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
ATTR_DATE, ATTR_DATE,
@ -44,22 +42,7 @@ ATTR_APP_TYPE = "app_type"
ATTR_EVENT_BY = "event_by" ATTR_EVENT_BY = "event_by"
ATTR_VALUE = "value" ATTR_VALUE = "value"
CONFIG_SCHEMA = vol.Schema( CONFIG_SCHEMA = cv.deprecated(DOMAIN)
vol.All(
# Deprecated in Home Assistant 2021.6
cv.deprecated(DOMAIN),
{
DOMAIN: vol.Schema(
{
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(CONF_POLLING, default=False): cv.boolean,
}
)
},
),
extra=vol.ALLOW_EXTRA,
)
CHANGE_SETTING_SCHEMA = vol.Schema( CHANGE_SETTING_SCHEMA = vol.Schema(
{vol.Required(ATTR_SETTING): cv.string, vol.Required(ATTR_VALUE): cv.string} {vol.Required(ATTR_SETTING): cv.string, vol.Required(ATTR_VALUE): cv.string}
@ -92,22 +75,6 @@ class AbodeSystem:
self.logout_listener = None self.logout_listener = None
async def async_setup(hass, config):
"""Set up Abode integration."""
if DOMAIN not in config:
return True
conf = config[DOMAIN]
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=deepcopy(conf)
)
)
return True
async def async_setup_entry(hass, config_entry): async def async_setup_entry(hass, config_entry):
"""Set up Abode integration from a config entry.""" """Set up Abode integration from a config entry."""
username = config_entry.data.get(CONF_USERNAME) username = config_entry.data.get(CONF_USERNAME)

View File

@ -158,13 +158,3 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self._password = user_input[CONF_PASSWORD] self._password = user_input[CONF_PASSWORD]
return await self._async_abode_login(step_id="reauth_confirm") return await self._async_abode_login(step_id="reauth_confirm")
async def async_step_import(self, import_config):
"""Import a config entry from configuration.yaml."""
if self._async_current_entries():
LOGGER.warning("Already configured; Only a single configuration possible")
return self.async_abort(reason="single_instance_allowed")
self._polling = import_config.get(CONF_POLLING, False)
return await self.async_step_user(import_config)

View File

@ -7,7 +7,7 @@ from abodepy.helpers.errors import MFA_CODE_REQUIRED
from homeassistant import data_entry_flow from homeassistant import data_entry_flow
from homeassistant.components.abode import config_flow from homeassistant.components.abode import config_flow
from homeassistant.components.abode.const import DOMAIN from homeassistant.components.abode.const import DOMAIN
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_REAUTH, SOURCE_USER from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
from homeassistant.const import ( from homeassistant.const import (
CONF_PASSWORD, CONF_PASSWORD,
CONF_USERNAME, CONF_USERNAME,
@ -46,17 +46,6 @@ async def test_one_config_allowed(hass):
assert step_user_result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert step_user_result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert step_user_result["reason"] == "single_instance_allowed" assert step_user_result["reason"] == "single_instance_allowed"
conf = {
CONF_USERNAME: "user@email.com",
CONF_PASSWORD: "password",
CONF_POLLING: False,
}
import_config_result = await flow.async_step_import(conf)
assert import_config_result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert import_config_result["reason"] == "single_instance_allowed"
async def test_invalid_credentials(hass): async def test_invalid_credentials(hass):
"""Test that invalid credentials throws an error.""" """Test that invalid credentials throws an error."""
@ -90,29 +79,6 @@ async def test_connection_error(hass):
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
async def test_step_import(hass):
"""Test that the import step works."""
conf = {
CONF_USERNAME: "user@email.com",
CONF_PASSWORD: "password",
CONF_POLLING: False,
}
with patch("homeassistant.components.abode.config_flow.Abode"), patch(
"abodepy.UTILS"
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=conf
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == "user@email.com"
assert result["data"] == {
CONF_USERNAME: "user@email.com",
CONF_PASSWORD: "password",
CONF_POLLING: False,
}
async def test_step_user(hass): async def test_step_user(hass):
"""Test that the user step works.""" """Test that the user step works."""
conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"} conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"}