Only initialize Nuki configurations (#49747)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
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

View File

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