def async_subscribe(hass, topic, callback, qos=DEFAULT_QOS):
 @asyncio.coroutine
 def mqtt_topic_subscriber(event):
  'Match subscribed MQTT topic.'
  if (not _match_topic(topic, event.data[ATTR_TOPIC])):
   return
  hass.async_run_job(callback, event.data[ATTR_TOPIC], event.data[ATTR_PAYLOAD], event.data[ATTR_QOS])
 async_remove = hass.bus.async_listen(EVENT_MQTT_MESSAGE_RECEIVED, mqtt_topic_subscriber)
 MQTT_CLIENT.subscribe(topic, qos)
 return async_remove

def async_subscribe ( hass , topic , callback , qos = DEFAULT_QOS ) : @ asyncio . coroutine def mqtt_topic_subscriber ( event ) : if ( not _match_topic ( topic , event . data [ ATTR_TOPIC ] ) ) : return hass . async_run_job ( callback , event . data [ ATTR_TOPIC ] , event . data [ ATTR_PAYLOAD ] , event . data [ ATTR_QOS ] ) async_remove = hass . bus . async_listen ( EVENT_MQTT_MESSAGE_RECEIVED , mqtt_topic_subscriber ) MQTT_CLIENT . subscribe ( topic , qos ) return async_remove
subscribe to an mqtt topic .