'Test updating with via state topic.'

def test_update_state_via_state_topic(self):

    assert setup_component(self.hass, alarm_control_panel.DOMAIN, {alarm_control_panel.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'alarm/state', 'command_topic': 'alarm/command'}})
    entity_id = 'alarm_control_panel.test'
    self.assertEqual(STATE_UNKNOWN, self.hass.states.get(entity_id).state)
    for state in (STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY, STATE_ALARM_PENDING, STATE_ALARM_TRIGGERED):
        fire_mqtt_message(self.hass, 'alarm/state', state)
        self.hass.block_till_done()
        self.assertEqual(state, self.hass.states.get(entity_id).state)
