diff --git a/homeassistant/components/ambient_station/__init__.py b/homeassistant/components/ambient_station/__init__.py index 347ba700060..f276597c79a 100644 --- a/homeassistant/components/ambient_station/__init__.py +++ b/homeassistant/components/ambient_station/__init__.py @@ -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] diff --git a/homeassistant/components/ambient_station/config_flow.py b/homeassistant/components/ambient_station/config_flow.py index 429388dcaba..5b40300498b 100644 --- a/homeassistant/components/ambient_station/config_flow.py +++ b/homeassistant/components/ambient_station/config_flow.py @@ -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: diff --git a/tests/components/ambient_station/test_config_flow.py b/tests/components/ambient_station/test_config_flow.py index a64b7761338..806d31b5386 100644 --- a/tests/components/ambient_station/test_config_flow.py +++ b/tests/components/ambient_station/test_config_flow.py @@ -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")))],