parent
50b6c5948d
commit
ea2ff6aae3
26 changed files with 50 additions and 49 deletions
|
@ -167,7 +167,7 @@ def async_setup(hass, config):
|
||||||
def async_handle_core_service(call):
|
def async_handle_core_service(call):
|
||||||
"""Service handler for handling core services."""
|
"""Service handler for handling core services."""
|
||||||
if call.service == SERVICE_HOMEASSISTANT_STOP:
|
if call.service == SERVICE_HOMEASSISTANT_STOP:
|
||||||
hass.async_add_job(hass.async_stop())
|
hass.async_create_task(hass.async_stop())
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -183,7 +183,7 @@ def async_setup(hass, config):
|
||||||
return
|
return
|
||||||
|
|
||||||
if call.service == SERVICE_HOMEASSISTANT_RESTART:
|
if call.service == SERVICE_HOMEASSISTANT_RESTART:
|
||||||
hass.async_add_job(hass.async_stop(RESTART_EXIT_CODE))
|
hass.async_create_task(hass.async_stop(RESTART_EXIT_CODE))
|
||||||
|
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
ha.DOMAIN, SERVICE_HOMEASSISTANT_STOP, async_handle_core_service)
|
ha.DOMAIN, SERVICE_HOMEASSISTANT_STOP, async_handle_core_service)
|
||||||
|
|
|
@ -187,7 +187,7 @@ class AlarmControlPanel(Entity):
|
||||||
|
|
||||||
This method must be run in the event loop and returns a coroutine.
|
This method must be run in the event loop and returns a coroutine.
|
||||||
"""
|
"""
|
||||||
return self.hass.async_add_job(self.alarm_disarm, code)
|
return self.hass.async_add_executor_job(self.alarm_disarm, code)
|
||||||
|
|
||||||
def alarm_arm_home(self, code=None):
|
def alarm_arm_home(self, code=None):
|
||||||
"""Send arm home command."""
|
"""Send arm home command."""
|
||||||
|
@ -198,7 +198,7 @@ class AlarmControlPanel(Entity):
|
||||||
|
|
||||||
This method must be run in the event loop and returns a coroutine.
|
This method must be run in the event loop and returns a coroutine.
|
||||||
"""
|
"""
|
||||||
return self.hass.async_add_job(self.alarm_arm_home, code)
|
return self.hass.async_add_executor_job(self.alarm_arm_home, code)
|
||||||
|
|
||||||
def alarm_arm_away(self, code=None):
|
def alarm_arm_away(self, code=None):
|
||||||
"""Send arm away command."""
|
"""Send arm away command."""
|
||||||
|
@ -209,7 +209,7 @@ class AlarmControlPanel(Entity):
|
||||||
|
|
||||||
This method must be run in the event loop and returns a coroutine.
|
This method must be run in the event loop and returns a coroutine.
|
||||||
"""
|
"""
|
||||||
return self.hass.async_add_job(self.alarm_arm_away, code)
|
return self.hass.async_add_executor_job(self.alarm_arm_away, code)
|
||||||
|
|
||||||
def alarm_arm_night(self, code=None):
|
def alarm_arm_night(self, code=None):
|
||||||
"""Send arm night command."""
|
"""Send arm night command."""
|
||||||
|
@ -220,7 +220,7 @@ class AlarmControlPanel(Entity):
|
||||||
|
|
||||||
This method must be run in the event loop and returns a coroutine.
|
This method must be run in the event loop and returns a coroutine.
|
||||||
"""
|
"""
|
||||||
return self.hass.async_add_job(self.alarm_arm_night, code)
|
return self.hass.async_add_executor_job(self.alarm_arm_night, code)
|
||||||
|
|
||||||
def alarm_trigger(self, code=None):
|
def alarm_trigger(self, code=None):
|
||||||
"""Send alarm trigger command."""
|
"""Send alarm trigger command."""
|
||||||
|
@ -231,7 +231,7 @@ class AlarmControlPanel(Entity):
|
||||||
|
|
||||||
This method must be run in the event loop and returns a coroutine.
|
This method must be run in the event loop and returns a coroutine.
|
||||||
"""
|
"""
|
||||||
return self.hass.async_add_job(self.alarm_trigger, code)
|
return self.hass.async_add_executor_job(self.alarm_trigger, code)
|
||||||
|
|
||||||
def alarm_arm_custom_bypass(self, code=None):
|
def alarm_arm_custom_bypass(self, code=None):
|
||||||
"""Send arm custom bypass command."""
|
"""Send arm custom bypass command."""
|
||||||
|
@ -242,7 +242,8 @@ class AlarmControlPanel(Entity):
|
||||||
|
|
||||||
This method must be run in the event loop and returns a coroutine.
|
This method must be run in the event loop and returns a coroutine.
|
||||||
"""
|
"""
|
||||||
return self.hass.async_add_job(self.alarm_arm_custom_bypass, code)
|
return self.hass.async_add_executor_job(
|
||||||
|
self.alarm_arm_custom_bypass, code)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state_attributes(self):
|
def state_attributes(self):
|
||||||
|
|
|
@ -68,7 +68,7 @@ def turn_on(hass, entity_id):
|
||||||
def async_turn_on(hass, entity_id):
|
def async_turn_on(hass, entity_id):
|
||||||
"""Async reset the alert."""
|
"""Async reset the alert."""
|
||||||
data = {ATTR_ENTITY_ID: entity_id}
|
data = {ATTR_ENTITY_ID: entity_id}
|
||||||
hass.async_add_job(
|
hass.async_create_task(
|
||||||
hass.services.async_call(DOMAIN, SERVICE_TURN_ON, data))
|
hass.services.async_call(DOMAIN, SERVICE_TURN_ON, data))
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ def turn_off(hass, entity_id):
|
||||||
def async_turn_off(hass, entity_id):
|
def async_turn_off(hass, entity_id):
|
||||||
"""Async acknowledge the alert."""
|
"""Async acknowledge the alert."""
|
||||||
data = {ATTR_ENTITY_ID: entity_id}
|
data = {ATTR_ENTITY_ID: entity_id}
|
||||||
hass.async_add_job(
|
hass.async_create_task(
|
||||||
hass.services.async_call(DOMAIN, SERVICE_TURN_OFF, data))
|
hass.services.async_call(DOMAIN, SERVICE_TURN_OFF, data))
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ def toggle(hass, entity_id):
|
||||||
def async_toggle(hass, entity_id):
|
def async_toggle(hass, entity_id):
|
||||||
"""Async toggle acknowledgement of alert."""
|
"""Async toggle acknowledgement of alert."""
|
||||||
data = {ATTR_ENTITY_ID: entity_id}
|
data = {ATTR_ENTITY_ID: entity_id}
|
||||||
hass.async_add_job(
|
hass.async_create_task(
|
||||||
hass.services.async_call(DOMAIN, SERVICE_TOGGLE, data))
|
hass.services.async_call(DOMAIN, SERVICE_TOGGLE, data))
|
||||||
|
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ class Alert(ToggleEntity):
|
||||||
else:
|
else:
|
||||||
yield from self._schedule_notify()
|
yield from self._schedule_notify()
|
||||||
|
|
||||||
self.hass.async_add_job(self.async_update_ha_state)
|
self.async_schedule_update_ha_state()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def end_alerting(self):
|
def end_alerting(self):
|
||||||
|
@ -228,7 +228,7 @@ class Alert(ToggleEntity):
|
||||||
self._firing = False
|
self._firing = False
|
||||||
if self._done_message and self._send_done_message:
|
if self._done_message and self._send_done_message:
|
||||||
yield from self._notify_done_message()
|
yield from self._notify_done_message()
|
||||||
self.hass.async_add_job(self.async_update_ha_state)
|
self.async_schedule_update_ha_state()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def _schedule_notify(self):
|
def _schedule_notify(self):
|
||||||
|
|
|
@ -214,11 +214,11 @@ def async_setup(hass, config):
|
||||||
CONF_PASSWORD: password
|
CONF_PASSWORD: password
|
||||||
})
|
})
|
||||||
|
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, 'camera', 'mjpeg', mjpeg_camera, config))
|
hass, 'camera', 'mjpeg', mjpeg_camera, config))
|
||||||
|
|
||||||
if sensors:
|
if sensors:
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, 'sensor', DOMAIN, {
|
hass, 'sensor', DOMAIN, {
|
||||||
CONF_NAME: name,
|
CONF_NAME: name,
|
||||||
CONF_HOST: host,
|
CONF_HOST: host,
|
||||||
|
@ -226,7 +226,7 @@ def async_setup(hass, config):
|
||||||
}, config))
|
}, config))
|
||||||
|
|
||||||
if switches:
|
if switches:
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, 'switch', DOMAIN, {
|
hass, 'switch', DOMAIN, {
|
||||||
CONF_NAME: name,
|
CONF_NAME: name,
|
||||||
CONF_HOST: host,
|
CONF_HOST: host,
|
||||||
|
@ -234,7 +234,7 @@ def async_setup(hass, config):
|
||||||
}, config))
|
}, config))
|
||||||
|
|
||||||
if motion:
|
if motion:
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, 'binary_sensor', DOMAIN, {
|
hass, 'binary_sensor', DOMAIN, {
|
||||||
CONF_HOST: host,
|
CONF_HOST: host,
|
||||||
CONF_NAME: name,
|
CONF_NAME: name,
|
||||||
|
|
|
@ -218,10 +218,10 @@ def _setup_atv(hass, atv_config):
|
||||||
ATTR_POWER: power
|
ATTR_POWER: power
|
||||||
}
|
}
|
||||||
|
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, 'media_player', DOMAIN, atv_config))
|
hass, 'media_player', DOMAIN, atv_config))
|
||||||
|
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, 'remote', DOMAIN, atv_config))
|
hass, 'remote', DOMAIN, atv_config))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ async def async_setup(hass, config):
|
||||||
|
|
||||||
async def async_setup_entry(hass, entry):
|
async def async_setup_entry(hass, entry):
|
||||||
"""Set up Cast from a config entry."""
|
"""Set up Cast from a config entry."""
|
||||||
hass.async_add_job(hass.config_entries.async_forward_entry_setup(
|
hass.async_create_task(hass.config_entries.async_forward_entry_setup(
|
||||||
entry, 'media_player'))
|
entry, 'media_player'))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ async def _async_has_devices(hass):
|
||||||
"""Return if there are devices that can be discovered."""
|
"""Return if there are devices that can be discovered."""
|
||||||
from pychromecast.discovery import discover_chromecasts
|
from pychromecast.discovery import discover_chromecasts
|
||||||
|
|
||||||
return await hass.async_add_job(discover_chromecasts)
|
return await hass.async_add_executor_job(discover_chromecasts)
|
||||||
|
|
||||||
|
|
||||||
config_entry_flow.register_discovery_flow(
|
config_entry_flow.register_discovery_flow(
|
||||||
|
|
|
@ -97,7 +97,7 @@ async def async_setup_entry(hass, config_entry):
|
||||||
hass.data[DATA_DECONZ_UNSUB] = []
|
hass.data[DATA_DECONZ_UNSUB] = []
|
||||||
|
|
||||||
for component in ['binary_sensor', 'light', 'scene', 'sensor']:
|
for component in ['binary_sensor', 'light', 'scene', 'sensor']:
|
||||||
hass.async_add_job(hass.config_entries.async_forward_entry_setup(
|
hass.async_create_task(hass.config_entries.async_forward_entry_setup(
|
||||||
config_entry, component))
|
config_entry, component))
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
|
@ -143,12 +143,12 @@ async def async_setup(hass, config):
|
||||||
# No users, cannot continue
|
# No users, cannot continue
|
||||||
return False
|
return False
|
||||||
|
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, 'sensor', DOMAIN, {
|
hass, 'sensor', DOMAIN, {
|
||||||
CONF_SENSORS: sensors,
|
CONF_SENSORS: sensors,
|
||||||
}, config))
|
}, config))
|
||||||
|
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, 'binary_sensor', DOMAIN, {
|
hass, 'binary_sensor', DOMAIN, {
|
||||||
CONF_BINARY_SENSORS: binary_sensors,
|
CONF_BINARY_SENSORS: binary_sensors,
|
||||||
}, config))
|
}, config))
|
||||||
|
|
|
@ -167,21 +167,21 @@ def async_setup(hass, config):
|
||||||
|
|
||||||
# Load sub-components for Envisalink
|
# Load sub-components for Envisalink
|
||||||
if partitions:
|
if partitions:
|
||||||
hass.async_add_job(async_load_platform(
|
hass.async_create_task(async_load_platform(
|
||||||
hass, 'alarm_control_panel', 'envisalink', {
|
hass, 'alarm_control_panel', 'envisalink', {
|
||||||
CONF_PARTITIONS: partitions,
|
CONF_PARTITIONS: partitions,
|
||||||
CONF_CODE: code,
|
CONF_CODE: code,
|
||||||
CONF_PANIC: panic_type
|
CONF_PANIC: panic_type
|
||||||
}, config
|
}, config
|
||||||
))
|
))
|
||||||
hass.async_add_job(async_load_platform(
|
hass.async_create_task(async_load_platform(
|
||||||
hass, 'sensor', 'envisalink', {
|
hass, 'sensor', 'envisalink', {
|
||||||
CONF_PARTITIONS: partitions,
|
CONF_PARTITIONS: partitions,
|
||||||
CONF_CODE: code
|
CONF_CODE: code
|
||||||
}, config
|
}, config
|
||||||
))
|
))
|
||||||
if zones:
|
if zones:
|
||||||
hass.async_add_job(async_load_platform(
|
hass.async_create_task(async_load_platform(
|
||||||
hass, 'binary_sensor', 'envisalink', {
|
hass, 'binary_sensor', 'envisalink', {
|
||||||
CONF_ZONES: zones
|
CONF_ZONES: zones
|
||||||
}, config
|
}, config
|
||||||
|
|
|
@ -117,7 +117,7 @@ class HomematicipHAP:
|
||||||
self.config_entry.data.get(HMIPC_HAPID))
|
self.config_entry.data.get(HMIPC_HAPID))
|
||||||
|
|
||||||
for component in COMPONENTS:
|
for component in COMPONENTS:
|
||||||
self.hass.async_add_job(
|
self.hass.async_create_task(
|
||||||
self.hass.config_entries.async_forward_entry_setup(
|
self.hass.config_entries.async_forward_entry_setup(
|
||||||
self.config_entry, component)
|
self.config_entry, component)
|
||||||
)
|
)
|
||||||
|
|
|
@ -78,7 +78,7 @@ class HueBridge:
|
||||||
host)
|
host)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
hass.async_add_job(hass.config_entries.async_forward_entry_setup(
|
hass.async_create_task(hass.config_entries.async_forward_entry_setup(
|
||||||
self.config_entry, 'light'))
|
self.config_entry, 'light'))
|
||||||
|
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
|
|
|
@ -148,7 +148,7 @@ def async_setup(hass, config):
|
||||||
device.states[state_key].name,
|
device.states[state_key].name,
|
||||||
platform)
|
platform)
|
||||||
|
|
||||||
hass.async_add_job(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(
|
discovery.async_load_platform(
|
||||||
hass, platform, DOMAIN,
|
hass, platform, DOMAIN,
|
||||||
discovered={'address': device.address.id,
|
discovered={'address': device.address.id,
|
||||||
|
|
|
@ -107,7 +107,7 @@ async def async_setup(hass, config):
|
||||||
('scene', 'Scene'),
|
('scene', 'Scene'),
|
||||||
('notify', 'Notification')):
|
('notify', 'Notification')):
|
||||||
found_devices = _get_devices(hass, discovery_type)
|
found_devices = _get_devices(hass, discovery_type)
|
||||||
hass.async_add_job(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(hass, component, DOMAIN, {
|
discovery.async_load_platform(hass, component, DOMAIN, {
|
||||||
ATTR_DISCOVER_DEVICES: found_devices
|
ATTR_DISCOVER_DEVICES: found_devices
|
||||||
}, config))
|
}, config))
|
||||||
|
|
|
@ -63,8 +63,8 @@ def async_setup(hass, base_config):
|
||||||
_LOGGER.info("Connected to Lutron smartbridge at %s", config[CONF_HOST])
|
_LOGGER.info("Connected to Lutron smartbridge at %s", config[CONF_HOST])
|
||||||
|
|
||||||
for component in LUTRON_CASETA_COMPONENTS:
|
for component in LUTRON_CASETA_COMPONENTS:
|
||||||
hass.async_add_job(discovery.async_load_platform(hass, component,
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
DOMAIN, {}, config))
|
hass, component, DOMAIN, {}, config))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ async def _discover_persistent_devices(hass, gateway):
|
||||||
@callback
|
@callback
|
||||||
def _discover_mysensors_platform(hass, platform, new_devices):
|
def _discover_mysensors_platform(hass, platform, new_devices):
|
||||||
"""Discover a MySensors platform."""
|
"""Discover a MySensors platform."""
|
||||||
task = hass.async_add_job(discovery.async_load_platform(
|
task = hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, platform, DOMAIN,
|
hass, platform, DOMAIN,
|
||||||
{ATTR_DEVICES: new_devices, CONF_NAME: DOMAIN}))
|
{ATTR_DEVICES: new_devices, CONF_NAME: DOMAIN}))
|
||||||
return task
|
return task
|
||||||
|
|
|
@ -127,7 +127,7 @@ async def async_setup_entry(hass, entry):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for component in 'climate', 'camera', 'sensor', 'binary_sensor':
|
for component in 'climate', 'camera', 'sensor', 'binary_sensor':
|
||||||
hass.async_add_job(hass.config_entries.async_forward_entry_setup(
|
hass.async_create_task(hass.config_entries.async_forward_entry_setup(
|
||||||
entry, component))
|
entry, component))
|
||||||
|
|
||||||
def set_mode(service):
|
def set_mode(service):
|
||||||
|
|
|
@ -151,7 +151,7 @@ async def async_setup(hass, config):
|
||||||
('sensor', conf[CONF_SENSORS]),
|
('sensor', conf[CONF_SENSORS]),
|
||||||
('switch', conf[CONF_SWITCHES]),
|
('switch', conf[CONF_SWITCHES]),
|
||||||
]:
|
]:
|
||||||
hass.async_add_job(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(hass, component, DOMAIN, schema,
|
discovery.async_load_platform(hass, component, DOMAIN, schema,
|
||||||
config))
|
config))
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ def async_setup_sabnzbd(hass, sab_api, config, name):
|
||||||
|
|
||||||
if config.get(CONF_SENSORS):
|
if config.get(CONF_SENSORS):
|
||||||
hass.data[DATA_SABNZBD] = sab_api_data
|
hass.data[DATA_SABNZBD] = sab_api_data
|
||||||
hass.async_add_job(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(hass, 'sensor', DOMAIN, {}, config))
|
discovery.async_load_platform(hass, 'sensor', DOMAIN, {}, config))
|
||||||
|
|
||||||
async def async_service_handler(service):
|
async def async_service_handler(service):
|
||||||
|
|
|
@ -98,10 +98,10 @@ def async_setup(hass, config):
|
||||||
conf,
|
conf,
|
||||||
conf.get(CONF_ARM_HOME_MODE))
|
conf.get(CONF_ARM_HOME_MODE))
|
||||||
|
|
||||||
task_control_panel = hass.async_add_job(
|
task_control_panel = hass.async_create_task(
|
||||||
async_load_platform(hass, 'alarm_control_panel', DOMAIN, conf, config))
|
async_load_platform(hass, 'alarm_control_panel', DOMAIN, conf, config))
|
||||||
|
|
||||||
task_zones = hass.async_add_job(
|
task_zones = hass.async_create_task(
|
||||||
async_load_platform(hass, 'binary_sensor', DOMAIN,
|
async_load_platform(hass, 'binary_sensor', DOMAIN,
|
||||||
{CONF_ZONES: zones}, config))
|
{CONF_ZONES: zones}, config))
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ async def async_setup(hass, config):
|
||||||
|
|
||||||
async def async_setup_entry(hass, entry):
|
async def async_setup_entry(hass, entry):
|
||||||
"""Set up Sonos from a config entry."""
|
"""Set up Sonos from a config entry."""
|
||||||
hass.async_add_job(hass.config_entries.async_forward_entry_setup(
|
hass.async_create_task(hass.config_entries.async_forward_entry_setup(
|
||||||
entry, 'media_player'))
|
entry, 'media_player'))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ async def _async_has_devices(hass):
|
||||||
"""Return if there are devices that can be discovered."""
|
"""Return if there are devices that can be discovered."""
|
||||||
import soco
|
import soco
|
||||||
|
|
||||||
return await hass.async_add_job(soco.discover)
|
return await hass.async_add_executor_job(soco.discover)
|
||||||
|
|
||||||
|
|
||||||
config_entry_flow.register_discovery_flow(DOMAIN, 'Sonos', _async_has_devices)
|
config_entry_flow.register_discovery_flow(DOMAIN, 'Sonos', _async_has_devices)
|
||||||
|
|
|
@ -56,14 +56,14 @@ def async_setup(hass, config):
|
||||||
# add sensor devices for each zone (typically motion/fire/door sensors)
|
# add sensor devices for each zone (typically motion/fire/door sensors)
|
||||||
zones = yield from api.get_zones()
|
zones = yield from api.get_zones()
|
||||||
if zones:
|
if zones:
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, 'binary_sensor', DOMAIN,
|
hass, 'binary_sensor', DOMAIN,
|
||||||
{ATTR_DISCOVER_DEVICES: zones}, config))
|
{ATTR_DISCOVER_DEVICES: zones}, config))
|
||||||
|
|
||||||
# create a separate alarm panel for each area
|
# create a separate alarm panel for each area
|
||||||
areas = yield from api.get_areas()
|
areas = yield from api.get_areas()
|
||||||
if areas:
|
if areas:
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, 'alarm_control_panel', DOMAIN,
|
hass, 'alarm_control_panel', DOMAIN,
|
||||||
{ATTR_DISCOVER_AREAS: areas}, config))
|
{ATTR_DISCOVER_AREAS: areas}, config))
|
||||||
|
|
||||||
|
|
|
@ -166,8 +166,8 @@ async def _setup_gateway(hass, hass_config, host, identity, key,
|
||||||
return True
|
return True
|
||||||
|
|
||||||
gateways[gateway_id] = gateway
|
gateways[gateway_id] = gateway
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, 'light', DOMAIN, {'gateway': gateway_id}, hass_config))
|
hass, 'light', DOMAIN, {'gateway': gateway_id}, hass_config))
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, 'sensor', DOMAIN, {'gateway': gateway_id}, hass_config))
|
hass, 'sensor', DOMAIN, {'gateway': gateway_id}, hass_config))
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -88,7 +88,7 @@ async def async_setup(hass, config):
|
||||||
service = device.find_first_service(IP_SERVICE)
|
service = device.find_first_service(IP_SERVICE)
|
||||||
if _service['serviceType'] == CIC_SERVICE:
|
if _service['serviceType'] == CIC_SERVICE:
|
||||||
unit = config.get(CONF_UNITS)
|
unit = config.get(CONF_UNITS)
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_create_task(discovery.async_load_platform(
|
||||||
hass, 'sensor', DOMAIN, {'unit': unit}, config))
|
hass, 'sensor', DOMAIN, {'unit': unit}, config))
|
||||||
except UpnpSoapError as error:
|
except UpnpSoapError as error:
|
||||||
_LOGGER.error(error)
|
_LOGGER.error(error)
|
||||||
|
|
|
@ -39,7 +39,7 @@ async def async_setup(hass, config):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for component in SUPPORTED_DOMAINS:
|
for component in SUPPORTED_DOMAINS:
|
||||||
hass.async_add_job(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(hass, component, DOMAIN, {}, config))
|
discovery.async_load_platform(hass, component, DOMAIN, {}, config))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ async def async_load_platform(hass, component, platform, discovered=None,
|
||||||
Use `listen_platform` to register a callback for these events.
|
Use `listen_platform` to register a callback for these events.
|
||||||
|
|
||||||
Warning: Do not await this inside a setup method to avoid a dead lock.
|
Warning: Do not await this inside a setup method to avoid a dead lock.
|
||||||
Use `hass.async_add_job(async_load_platform(..))` instead.
|
Use `hass.async_create_task(async_load_platform(..))` instead.
|
||||||
|
|
||||||
This method is a coroutine.
|
This method is a coroutine.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -91,7 +91,7 @@ async def test_setup_entry_successful(hass):
|
||||||
"""Test setup entry is successful."""
|
"""Test setup entry is successful."""
|
||||||
entry = Mock()
|
entry = Mock()
|
||||||
entry.data = {'host': '1.2.3.4', 'port': 80, 'api_key': '1234567890ABCDEF'}
|
entry.data = {'host': '1.2.3.4', 'port': 80, 'api_key': '1234567890ABCDEF'}
|
||||||
with patch.object(hass, 'async_add_job') as mock_add_job, \
|
with patch.object(hass, 'async_create_task') as mock_add_job, \
|
||||||
patch.object(hass, 'config_entries') as mock_config_entries, \
|
patch.object(hass, 'config_entries') as mock_config_entries, \
|
||||||
patch('pydeconz.DeconzSession.async_load_parameters',
|
patch('pydeconz.DeconzSession.async_load_parameters',
|
||||||
return_value=mock_coro(True)):
|
return_value=mock_coro(True)):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue