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

def async_added_to_hass(self):

    async_track_state_change(self.hass, self.entity_id, self._async_state_changed_listener)
    @callback
    def message_received(topic, payload, qos):
        'Run    when    new    MQTT    message    has    been    received.'
        if (payload == self._payload_disarm):
            self.async_alarm_disarm(self._code)
        elif (payload == self._payload_arm_home):
            self.async_alarm_arm_home(self._code)
        elif (payload == self._payload_arm_away):
            self.async_alarm_arm_away(self._code)
        else:
            _LOGGER.warning('Received    unexpected    payload:    %s', payload)
            return
    return mqtt.async_subscribe(self.hass, self._command_topic, message_received, self._qos)
