EventBus: return function to unlisten

This commit is contained in:
Paulus Schoutsen committed 2016-08-25 23:25:35 -07:00
1 parent 62ba0fa7a2
commit d9ecc4af64
11 files changed
+183 -83

No files matched your search

+6 -1
View File
@@ -170,9 +170,14 @@ def subscribe(hass, topic, callback, qos=DEFAULT_QOS):
callback(event.data[ATTR_TOPIC], event.data[ATTR_PAYLOAD],
event.data[ATTR_QOS])
hass.bus.listen(EVENT_MQTT_MESSAGE_RECEIVED, mqtt_topic_subscriber)
remove = hass.bus.listen(EVENT_MQTT_MESSAGE_RECEIVED,
mqtt_topic_subscriber)
# Future: track subscriber count and unsubscribe in remove
MQTT_CLIENT.subscribe(topic, qos)
return remove
def _setup_server(hass, config):
"""Try to start embedded MQTT broker."""