MQTT convert to async (#6064)
* Migrate mqtt to async * address paulus comment / convert it complet async * adress paulus comment / remove future * Automation triggers should be async * Fix MQTT async calls * Show that event helpers are callbacks * Fix tests * Lint
This commit is contained in:
parent
fa2c1dafdf
commit
e1cbd6b4c0
25 changed files with 356 additions and 231 deletions
|
@ -4,6 +4,7 @@ Offer MQTT listening automation rules.
|
|||
For more details about this automation rule, please refer to the documentation
|
||||
at https://home-assistant.io/components/automation/#mqtt-trigger
|
||||
"""
|
||||
import asyncio
|
||||
import json
|
||||
|
||||
import voluptuous as vol
|
||||
|
@ -24,6 +25,7 @@ TRIGGER_SCHEMA = vol.Schema({
|
|||
})
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_trigger(hass, config, action):
|
||||
"""Listen for state changes based on configuration."""
|
||||
topic = config.get(CONF_TOPIC)
|
||||
|
@ -49,4 +51,6 @@ def async_trigger(hass, config, action):
|
|||
'trigger': data
|
||||
})
|
||||
|
||||
return mqtt.async_subscribe(hass, topic, mqtt_automation_listener)
|
||||
remove = yield from mqtt.async_subscribe(
|
||||
hass, topic, mqtt_automation_listener)
|
||||
return remove
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue