Entity service (#15991)
* Add entity service helper * Use entity service helper * Context
This commit is contained in:
1 parent
e52ba87af1
commit
b682e48e12
14 files changed
+276
-387
No files matched your search
@@ -107,19 +107,10 @@ def async_setup(hass, config):
|
||||
if not entities:
|
||||
return False
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_set_value_service(call):
|
||||
"""Handle a calls to the input box services."""
|
||||
target_inputs = component.async_extract_from_service(call)
|
||||
|
||||
tasks = [input_text.async_set_value(call.data[ATTR_VALUE])
|
||||
for input_text in target_inputs]
|
||||
if tasks:
|
||||
yield from asyncio.wait(tasks, loop=hass.loop)
|
||||
|
||||
hass.services.async_register(
|
||||
DOMAIN, SERVICE_SET_VALUE, async_set_value_service,
|
||||
schema=SERVICE_SET_VALUE_SCHEMA)
|
||||
component.async_register_entity_service(
|
||||
SERVICE_SET_VALUE, SERVICE_SET_VALUE_SCHEMA,
|
||||
'async_set_value'
|
||||
)
|
||||
|
||||
yield from component.async_add_entities(entities)
|
||||
return True
|
||||
|
||||
Reference in new issue
Block a user