Fix race condition on boot. Fix #106
This commit is contained in:
parent
d928fab449
commit
6b61bf18cd
@ -3,21 +3,27 @@ import logging
|
|||||||
from .mod_view import setup_view
|
from .mod_view import setup_view
|
||||||
from .connection import setup_connection
|
from .connection import setup_connection
|
||||||
from .service import setup_service
|
from .service import setup_service
|
||||||
from .const import DOMAIN, DATA_DEVICES, DATA_ALIASES, DATA_ADDERS, CONFIG_DEVICES, DATA_CONFIG
|
from .const import (
|
||||||
|
DOMAIN,
|
||||||
|
DATA_DEVICES,
|
||||||
|
DATA_ALIASES,
|
||||||
|
DATA_ADDERS,
|
||||||
|
CONFIG_DEVICES,
|
||||||
|
DATA_CONFIG
|
||||||
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass, config):
|
async def async_setup(hass, config):
|
||||||
|
|
||||||
await setup_connection(hass, config)
|
|
||||||
setup_view(hass)
|
setup_view(hass)
|
||||||
|
|
||||||
aliases = {}
|
aliases = {}
|
||||||
for d in config[DOMAIN].get(CONFIG_DEVICES, {}):
|
for d in config[DOMAIN].get(CONFIG_DEVICES, {}):
|
||||||
name = config[DOMAIN][CONFIG_DEVICES][d].get("name", None)
|
name = config[DOMAIN][CONFIG_DEVICES][d].get("name", None)
|
||||||
if name:
|
if name:
|
||||||
aliases[name] = d.replace('_','-')
|
aliases[name] = d.replace('_', '-')
|
||||||
|
|
||||||
hass.data[DOMAIN] = {
|
hass.data[DOMAIN] = {
|
||||||
DATA_DEVICES: {},
|
DATA_DEVICES: {},
|
||||||
@ -26,16 +32,14 @@ async def async_setup(hass, config):
|
|||||||
DATA_CONFIG: config[DOMAIN],
|
DATA_CONFIG: config[DOMAIN],
|
||||||
}
|
}
|
||||||
|
|
||||||
await hass.helpers.discovery.async_load_platform("media_player", DOMAIN, {}, config)
|
async_load_platform = hass.helpers.discovery.async_load_platform
|
||||||
await hass.helpers.discovery.async_load_platform("sensor", DOMAIN, {}, config)
|
await async_load_platform("media_player", DOMAIN, {}, config)
|
||||||
await hass.helpers.discovery.async_load_platform("binary_sensor", DOMAIN, {}, config)
|
await async_load_platform("sensor", DOMAIN, {}, config)
|
||||||
await hass.helpers.discovery.async_load_platform("light", DOMAIN, {}, config)
|
await async_load_platform("binary_sensor", DOMAIN, {}, config)
|
||||||
await hass.helpers.discovery.async_load_platform("camera", DOMAIN, {}, config)
|
await async_load_platform("light", DOMAIN, {}, config)
|
||||||
|
await async_load_platform("camera", DOMAIN, {}, config)
|
||||||
|
|
||||||
await setup_service(hass)
|
await setup_service(hass)
|
||||||
|
await setup_connection(hass, config)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user