'Subscribe mqtt events.
This method must be run in the event loop and returns a coroutine.'

def async_added_to_hass(self):

    @callback
    def message_received(topic, payload, qos):
        'Run    when    new    MQTT    message    has    been    received.'
        if (payload not in (STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY, STATE_ALARM_PENDING, STATE_ALARM_TRIGGERED)):
            _LOGGER.warning('Received    unexpected    payload:    %s', payload)
            return
        self._state = payload
        self.hass.async_add_job(self.async_update_ha_state())
    return mqtt.async_subscribe(self.hass, self._state_topic, message_received, self._qos)
