This commit is contained in:
Paulus Schoutsen committed 2019-07-31 12:25:30 -07:00
1 parent da05dfe708
commit 4de97abc3a
2676 files changed
+163166 -140084

No files matched your search

+22 -13
View File
@@ -4,11 +4,18 @@ All containing methods are legacy helpers that should not be used by new
components. Instead call the service directly.
"""
from homeassistant.components.remote import (
ATTR_ACTIVITY, ATTR_ALTERNATIVE, ATTR_COMMAND, ATTR_DELAY_SECS,
ATTR_DEVICE, ATTR_NUM_REPEATS, ATTR_TIMEOUT, DOMAIN,
SERVICE_LEARN_COMMAND, SERVICE_SEND_COMMAND)
from homeassistant.const import (
ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_ON)
ATTR_ACTIVITY,
ATTR_ALTERNATIVE,
ATTR_COMMAND,
ATTR_DELAY_SECS,
ATTR_DEVICE,
ATTR_NUM_REPEATS,
ATTR_TIMEOUT,
DOMAIN,
SERVICE_LEARN_COMMAND,
SERVICE_SEND_COMMAND,
)
from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_ON
from homeassistant.loader import bind_hass
@@ -16,10 +23,10 @@ from homeassistant.loader import 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}
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)
@@ -37,8 +44,9 @@ def turn_off(hass, activity=None, entity_id=None):
@bind_hass
def send_command(hass, command, entity_id=None, device=None,
num_repeats=None, delay_secs=None):
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:
@@ -57,8 +65,9 @@ def send_command(hass, command, entity_id=None, device=None,
@bind_hass
def learn_command(hass, entity_id=None, device=None, command=None,
alternative=None, timeout=None):
def learn_command(
hass, entity_id=None, device=None, command=None, alternative=None, timeout=None
):
"""Learn a command from a device."""
data = {}
if entity_id: