Cleanup run_callback_threadsafe (#6187)
* Cleanup run_callback_threadsafe * fix spell * Revert image_processing, they need to wait for updatepull/6049/merge
parent
1cd1facbd0
commit
106b7a9d8f
homeassistant/components
image_processing
light
switch
|
@ -18,7 +18,6 @@ from homeassistant.const import (
|
|||
SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE, ATTR_ENTITY_ID)
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers import service, event
|
||||
from homeassistant.util.async import run_callback_threadsafe
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -62,8 +61,7 @@ def is_on(hass, entity_id):
|
|||
|
||||
def turn_on(hass, entity_id):
|
||||
"""Reset the alert."""
|
||||
run_callback_threadsafe(
|
||||
hass.loop, async_turn_on, hass, entity_id).result()
|
||||
hass.add_job(async_turn_on, hass, entity_id)
|
||||
|
||||
|
||||
@callback
|
||||
|
@ -76,8 +74,7 @@ def async_turn_on(hass, entity_id):
|
|||
|
||||
def turn_off(hass, entity_id):
|
||||
"""Acknowledge alert."""
|
||||
run_callback_threadsafe(
|
||||
hass.loop, async_turn_off, hass, entity_id).result()
|
||||
hass.add_job(async_turn_off, hass, entity_id)
|
||||
|
||||
|
||||
@callback
|
||||
|
@ -90,7 +87,7 @@ def async_turn_off(hass, entity_id):
|
|||
|
||||
def toggle(hass, entity_id):
|
||||
"""Toggle acknowledgement of alert."""
|
||||
run_callback_threadsafe(hass.loop, async_toggle, hass, entity_id)
|
||||
hass.add_job(async_toggle, hass, entity_id)
|
||||
|
||||
|
||||
@callback
|
||||
|
|
|
@ -20,8 +20,7 @@ from homeassistant.helpers.entity import Entity, async_generate_entity_id
|
|||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
from homeassistant.helpers.event import async_track_state_change
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.util.async import (
|
||||
run_callback_threadsafe, run_coroutine_threadsafe)
|
||||
from homeassistant.util.async import run_coroutine_threadsafe
|
||||
|
||||
DOMAIN = 'group'
|
||||
|
||||
|
@ -98,7 +97,7 @@ def is_on(hass, entity_id):
|
|||
|
||||
def reload(hass):
|
||||
"""Reload the automation from config."""
|
||||
hass.services.call(DOMAIN, SERVICE_RELOAD)
|
||||
hass.add_job(async_reload, hass)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
|
@ -365,7 +364,7 @@ class Group(Entity):
|
|||
|
||||
def start(self):
|
||||
"""Start tracking members."""
|
||||
run_callback_threadsafe(self.hass.loop, self.async_start).result()
|
||||
self.hass.add_job(self.async_start)
|
||||
|
||||
@callback
|
||||
def async_start(self):
|
||||
|
|
|
@ -108,8 +108,7 @@ class ImageProcessingFaceEntity(ImageProcessingEntity):
|
|||
def process_faces(self, faces, total):
|
||||
"""Send event with detected faces and store data."""
|
||||
run_callback_threadsafe(
|
||||
self.hass.loop, self.async_process_faces, faces, total
|
||||
).result()
|
||||
self.hass.loop, self.async_process_faces, faces, total).result()
|
||||
|
||||
@callback
|
||||
def async_process_faces(self, faces, total):
|
||||
|
|
|
@ -24,8 +24,6 @@ from homeassistant.helpers.config_validation import PLATFORM_SCHEMA # noqa
|
|||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.restore_state import async_restore_state
|
||||
import homeassistant.util.color as color_util
|
||||
from homeassistant.util.async import run_callback_threadsafe
|
||||
|
||||
|
||||
DOMAIN = "light"
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
@ -145,10 +143,10 @@ def turn_on(hass, entity_id=None, transition=None, brightness=None,
|
|||
rgb_color=None, xy_color=None, color_temp=None, white_value=None,
|
||||
profile=None, flash=None, effect=None, color_name=None):
|
||||
"""Turn all or specified light on."""
|
||||
run_callback_threadsafe(
|
||||
hass.loop, async_turn_on, hass, entity_id, transition, brightness,
|
||||
hass.add_job(
|
||||
async_turn_on, hass, entity_id, transition, brightness,
|
||||
rgb_color, xy_color, color_temp, white_value,
|
||||
profile, flash, effect, color_name).result()
|
||||
profile, flash, effect, color_name)
|
||||
|
||||
|
||||
@callback
|
||||
|
@ -178,8 +176,7 @@ def async_turn_on(hass, entity_id=None, transition=None, brightness=None,
|
|||
|
||||
def turn_off(hass, entity_id=None, transition=None):
|
||||
"""Turn all or specified light off."""
|
||||
run_callback_threadsafe(
|
||||
hass.loop, async_turn_off, hass, entity_id, transition).result()
|
||||
hass.add_job(async_turn_off, hass, entity_id, transition)
|
||||
|
||||
|
||||
@callback
|
||||
|
|
|
@ -22,7 +22,6 @@ from homeassistant.const import (EVENT_HOMEASSISTANT_START,
|
|||
STATE_NOT_HOME, STATE_OFF, STATE_ON,
|
||||
ATTR_HIDDEN, HTTP_BAD_REQUEST)
|
||||
from homeassistant.core import State, split_entity_id, DOMAIN as HA_DOMAIN
|
||||
from homeassistant.util.async import run_callback_threadsafe
|
||||
|
||||
DOMAIN = "logbook"
|
||||
DEPENDENCIES = ['recorder', 'frontend']
|
||||
|
@ -68,9 +67,7 @@ LOG_MESSAGE_SCHEMA = vol.Schema({
|
|||
|
||||
def log_entry(hass, name, message, domain=None, entity_id=None):
|
||||
"""Add an entry to the logbook."""
|
||||
run_callback_threadsafe(
|
||||
hass.loop, async_log_entry, hass, name, message, domain, entity_id
|
||||
).result()
|
||||
hass.add_job(async_log_entry, hass, name, message, domain, entity_id)
|
||||
|
||||
|
||||
def async_log_entry(hass, name, message, domain=None, entity_id=None):
|
||||
|
|
|
@ -16,7 +16,6 @@ from homeassistant.helpers import config_validation as cv
|
|||
from homeassistant.helpers.entity import async_generate_entity_id
|
||||
from homeassistant.util import slugify
|
||||
from homeassistant.config import load_yaml_config_file
|
||||
from homeassistant.util.async import run_callback_threadsafe
|
||||
|
||||
DOMAIN = 'persistent_notification'
|
||||
ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
||||
|
@ -39,9 +38,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
def create(hass, message, title=None, notification_id=None):
|
||||
"""Generate a notification."""
|
||||
run_callback_threadsafe(
|
||||
hass.loop, async_create, hass, message, title, notification_id
|
||||
).result()
|
||||
hass.add_job(async_create, hass, message, title, notification_id)
|
||||
|
||||
|
||||
@callback
|
||||
|
|
|
@ -21,7 +21,6 @@ from homeassistant.const import (
|
|||
STATE_ON, SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE,
|
||||
ATTR_ENTITY_ID)
|
||||
from homeassistant.components import group
|
||||
from homeassistant.util.async import run_callback_threadsafe
|
||||
|
||||
DOMAIN = 'switch'
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
@ -59,8 +58,7 @@ def is_on(hass, entity_id=None):
|
|||
|
||||
def turn_on(hass, entity_id=None):
|
||||
"""Turn all or specified switch on."""
|
||||
run_callback_threadsafe(
|
||||
hass.loop, async_turn_on, hass, entity_id).result()
|
||||
hass.add_job(async_turn_on, hass, entity_id)
|
||||
|
||||
|
||||
@callback
|
||||
|
@ -72,8 +70,7 @@ def async_turn_on(hass, entity_id=None):
|
|||
|
||||
def turn_off(hass, entity_id=None):
|
||||
"""Turn all or specified switch off."""
|
||||
run_callback_threadsafe(
|
||||
hass.loop, async_turn_off, hass, entity_id).result()
|
||||
hass.add_job(async_turn_off, hass, entity_id)
|
||||
|
||||
|
||||
@callback
|
||||
|
|
Loading…
Reference in New Issue