Only initialize Nuki configurations (#49747)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
pull/50222/head
Sezer K 2021-05-07 07:29:37 +02:00 committed by GitHub
parent 93628554cb
commit 316f6ba397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 5 deletions

View File

@ -10,7 +10,7 @@ from requests.exceptions import RequestException
from homeassistant import exceptions
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TOKEN
from homeassistant.const import CONF_HOST, CONF_PLATFORM, CONF_PORT, CONF_TOKEN
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
DataUpdateCoordinator,
@ -22,6 +22,7 @@ from .const import (
DATA_COORDINATOR,
DATA_LOCKS,
DATA_OPENERS,
DEFAULT_PORT,
DEFAULT_TIMEOUT,
DOMAIN,
ERROR_STATES,
@ -59,11 +60,18 @@ async def async_setup(hass, config):
continue
for conf in confs:
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=conf
if CONF_PLATFORM in conf and conf[CONF_PLATFORM] == DOMAIN:
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={
CONF_HOST: conf[CONF_HOST],
CONF_PORT: conf.get(CONF_PORT, DEFAULT_PORT),
CONF_TOKEN: conf[CONF_TOKEN],
},
)
)
)
return True