Remove service helper (4) (#16892)
* Update media_player * Update lock * Update notify * Update remote * Update scene * Update vacuum * Remove timer helpers * Removed unused legacy helpers
This commit is contained in:
1 parent
d0ddc28f96
commit
dd45e99302
23 files changed
+499
-520
No files matched your search
@@ -70,63 +70,6 @@ def is_on(hass, entity_id=None):
|
||||
return hass.states.is_state(entity_id, STATE_ON)
|
||||
|
||||
|
||||
@bind_hass
|
||||
def turn_on(hass, activity=None, entity_id=None):
|
||||
"""Turn all or specified remote on."""
|
||||
data = {
|
||||
key: value for key, value in [
|
||||
(ATTR_ACTIVITY, activity),
|
||||
(ATTR_ENTITY_ID, entity_id),
|
||||
] if value is not None}
|
||||
hass.services.call(DOMAIN, SERVICE_TURN_ON, data)
|
||||
|
||||
|
||||
@bind_hass
|
||||
def turn_off(hass, activity=None, entity_id=None):
|
||||
"""Turn all or specified remote off."""
|
||||
data = {}
|
||||
if activity:
|
||||
data[ATTR_ACTIVITY] = activity
|
||||
|
||||
if entity_id:
|
||||
data[ATTR_ENTITY_ID] = entity_id
|
||||
|
||||
hass.services.call(DOMAIN, SERVICE_TURN_OFF, data)
|
||||
|
||||
|
||||
@bind_hass
|
||||
def toggle(hass, activity=None, entity_id=None):
|
||||
"""Toggle all or specified remote."""
|
||||
data = {}
|
||||
if activity:
|
||||
data[ATTR_ACTIVITY] = activity
|
||||
|
||||
if entity_id:
|
||||
data[ATTR_ENTITY_ID] = entity_id
|
||||
|
||||
hass.services.call(DOMAIN, SERVICE_TOGGLE, data)
|
||||
|
||||
|
||||
@bind_hass
|
||||
def send_command(hass, command, entity_id=None, device=None,
|
||||
num_repeats=None, delay_secs=None):
|
||||
"""Send a command to a device."""
|
||||
data = {ATTR_COMMAND: command}
|
||||
if entity_id:
|
||||
data[ATTR_ENTITY_ID] = entity_id
|
||||
|
||||
if device:
|
||||
data[ATTR_DEVICE] = device
|
||||
|
||||
if num_repeats:
|
||||
data[ATTR_NUM_REPEATS] = num_repeats
|
||||
|
||||
if delay_secs:
|
||||
data[ATTR_DELAY_SECS] = delay_secs
|
||||
|
||||
hass.services.call(DOMAIN, SERVICE_SEND_COMMAND, data)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup(hass, config):
|
||||
"""Track states and offer events for remotes."""
|
||||
|
||||
Reference in new issue
Block a user