Fix SmartHab import flow (#41093)

This commit is contained in:
Baptiste Candellier 2020-10-03 03:26:08 +02:00 committed by GitHub
parent 9765fc13e8
commit 9611e5223a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 9 deletions

View File

@ -34,15 +34,18 @@ async def async_setup(hass, config) -> bool:
"""Set up the SmartHab platform."""
hass.data.setdefault(DOMAIN, {})
sh_conf = config.get(DOMAIN)
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data=sh_conf,
if DOMAIN not in config:
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=config[DOMAIN],
)
)
)
return True

View File

@ -16,6 +16,9 @@ _LOGGER = logging.getLogger(__name__)
class SmartHabConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""SmartHab config flow."""
VERSION = 1
CONNECTION_CLASS = config_entries.CONN_CLASS_CLOUD_POLL
def _show_setup_form(self, user_input=None, errors=None):
"""Show the setup form to the user."""
@ -72,6 +75,6 @@ class SmartHabConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self._show_setup_form(user_input, errors)
async def async_step_import(self, user_input):
async def async_step_import(self, import_info):
"""Handle import from legacy config."""
return await self.async_step_user(user_input)
return await self.async_step_user(import_info)