mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Deprecate YAML config for Ambient PWs (2021.9.0 removal) (#52459)
This commit is contained in:
parent
628eafaf68
commit
d980dd8d59
@ -2,14 +2,12 @@
|
||||
|
||||
from aioambient import Client
|
||||
from aioambient.errors import WebsocketError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
DOMAIN as BINARY_SENSOR,
|
||||
)
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR
|
||||
from homeassistant.config_entries import SOURCE_IMPORT
|
||||
from homeassistant.const import (
|
||||
ATTR_LOCATION,
|
||||
ATTR_NAME,
|
||||
@ -291,44 +289,13 @@ SENSOR_TYPES = {
|
||||
TYPE_YEARLYRAININ: ("Yearly Rain", "in", SENSOR, None),
|
||||
}
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_APP_KEY): cv.string,
|
||||
vol.Required(CONF_API_KEY): cv.string,
|
||||
}
|
||||
)
|
||||
},
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
"""Set up the Ambient PWS integration."""
|
||||
hass.data[DOMAIN] = {}
|
||||
hass.data[DOMAIN][DATA_CLIENT] = {}
|
||||
|
||||
if DOMAIN not in config:
|
||||
return True
|
||||
conf = config[DOMAIN]
|
||||
|
||||
# Store config for use during entry setup:
|
||||
hass.data[DOMAIN][DATA_CONFIG] = conf
|
||||
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data={CONF_API_KEY: conf[CONF_API_KEY], CONF_APP_KEY: conf[CONF_APP_KEY]},
|
||||
)
|
||||
)
|
||||
|
||||
return True
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry):
|
||||
"""Set up the Ambient PWS as config entry."""
|
||||
hass.data.setdefault(DOMAIN, {DATA_CLIENT: {}})
|
||||
|
||||
if not config_entry.unique_id:
|
||||
hass.config_entries.async_update_entry(
|
||||
config_entry, unique_id=config_entry.data[CONF_APP_KEY]
|
||||
|
@ -29,10 +29,6 @@ class AmbientStationFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
errors=errors if errors else {},
|
||||
)
|
||||
|
||||
async def async_step_import(self, import_config):
|
||||
"""Import a config entry from configuration.yaml."""
|
||||
return await self.async_step_user(import_config)
|
||||
|
||||
async def async_step_user(self, user_input=None):
|
||||
"""Handle the start of the config flow."""
|
||||
if not user_input:
|
||||
|
@ -83,27 +83,6 @@ async def test_show_form(hass):
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"get_devices_response",
|
||||
[mock_coro(return_value=json.loads(load_fixture("ambient_devices.json")))],
|
||||
)
|
||||
async def test_step_import(hass, mock_aioambient):
|
||||
"""Test that the import step works."""
|
||||
conf = {CONF_API_KEY: "12345abcde12345abcde", CONF_APP_KEY: "67890fghij67890fghij"}
|
||||
|
||||
flow = config_flow.AmbientStationFlowHandler()
|
||||
flow.hass = hass
|
||||
flow.context = {"source": SOURCE_USER}
|
||||
|
||||
result = await flow.async_step_import(import_config=conf)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["title"] == "67890fghij67"
|
||||
assert result["data"] == {
|
||||
CONF_API_KEY: "12345abcde12345abcde",
|
||||
CONF_APP_KEY: "67890fghij67890fghij",
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"get_devices_response",
|
||||
[mock_coro(return_value=json.loads(load_fixture("ambient_devices.json")))],
|
||||
|
Loading…
x
Reference in New Issue
Block a user