Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions homeassistant/components/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
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__)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions homeassistant/components/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
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'

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -365,7 +364,7 @@ def async_update_tracked_entity_ids(self, entity_ids):

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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ def state_attributes(self):
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):
Expand Down
11 changes: 4 additions & 7 deletions homeassistant/components/light/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions homeassistant/components/logbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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']
Expand Down Expand Up @@ -68,9 +67,7 @@

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):
Expand Down
5 changes: 1 addition & 4 deletions homeassistant/components/persistent_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
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 + '.{}'
Expand All @@ -39,9 +38,7 @@

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
Expand Down
7 changes: 2 additions & 5 deletions homeassistant/components/switch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down