'Test the controlling of the state via topic.'

def test_controlling_state_via_topic(self):

    config = {light.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'test_light_rgb/status', 'command_topic': 'test_light_rgb/set', 'brightness_state_topic': 'test_light_rgb/brightness/status', 'brightness_command_topic': 'test_light_rgb/brightness/set', 'rgb_state_topic': 'test_light_rgb/rgb/status', 'rgb_command_topic': 'test_light_rgb/rgb/set', 'color_temp_state_topic': 'test_light_rgb/color_temp/status', 'color_temp_command_topic': 'test_light_rgb/color_temp/set', 'effect_state_topic': 'test_light_rgb/effect/status', 'effect_command_topic': 'test_light_rgb/effect/set', 'white_value_state_topic': 'test_light_rgb/white_value/status', 'white_value_command_topic': 'test_light_rgb/white_value/set', 'xy_state_topic': 'test_light_rgb/xy/status', 'xy_command_topic': 'test_light_rgb/xy/set', 'qos': '0', 'payload_on': 1, 'payload_off': 0}}
    with assert_setup_component(1, light.DOMAIN):
        assert setup_component(self.hass, light.DOMAIN, config)
    state = self.hass.states.get('light.test')
    self.assertEqual(STATE_OFF, state.state)
    self.assertIsNone(state.attributes.get('rgb_color'))
    self.assertIsNone(state.attributes.get('brightness'))
    self.assertIsNone(state.attributes.get('color_temp'))
    self.assertIsNone(state.attributes.get('effect'))
    self.assertIsNone(state.attributes.get('white_value'))
    self.assertIsNone(state.attributes.get('xy_color'))
    self.assertFalse(state.attributes.get(ATTR_ASSUMED_STATE))
    fire_mqtt_message(self.hass, 'test_light_rgb/status', '1')
    self.hass.block_till_done()
    state = self.hass.states.get('light.test')
    self.assertEqual(STATE_ON, state.state)
    self.assertEqual([255, 255, 255], state.attributes.get('rgb_color'))
    self.assertEqual(255, state.attributes.get('brightness'))
    self.assertEqual(150, state.attributes.get('color_temp'))
    self.assertEqual('none', state.attributes.get('effect'))
    self.assertEqual(255, state.attributes.get('white_value'))
    self.assertEqual([1, 1], state.attributes.get('xy_color'))
    fire_mqtt_message(self.hass, 'test_light_rgb/status', '0')
    self.hass.block_till_done()
    state = self.hass.states.get('light.test')
    self.assertEqual(STATE_OFF, state.state)
    fire_mqtt_message(self.hass, 'test_light_rgb/status', '1')
    self.hass.block_till_done()
    fire_mqtt_message(self.hass, 'test_light_rgb/brightness/status', '100')
    self.hass.block_till_done()
    light_state = self.hass.states.get('light.test')
    self.hass.block_till_done()
    self.assertEqual(100, light_state.attributes['brightness'])
    fire_mqtt_message(self.hass, 'test_light_rgb/color_temp/status', '300')
    self.hass.block_till_done()
    light_state = self.hass.states.get('light.test')
    self.hass.block_till_done()
    self.assertEqual(300, light_state.attributes['color_temp'])
    fire_mqtt_message(self.hass, 'test_light_rgb/effect/status', 'rainbow')
    self.hass.block_till_done()
    light_state = self.hass.states.get('light.test')
    self.hass.block_till_done()
    self.assertEqual('rainbow', light_state.attributes['effect'])
    fire_mqtt_message(self.hass, 'test_light_rgb/white_value/status', '100')
    self.hass.block_till_done()
    light_state = self.hass.states.get('light.test')
    self.hass.block_till_done()
    self.assertEqual(100, light_state.attributes['white_value'])
    fire_mqtt_message(self.hass, 'test_light_rgb/status', '1')
    self.hass.block_till_done()
    fire_mqtt_message(self.hass, 'test_light_rgb/rgb/status', '125,125,125')
    self.hass.block_till_done()
    light_state = self.hass.states.get('light.test')
    self.assertEqual([125, 125, 125], light_state.attributes.get('rgb_color'))
    fire_mqtt_message(self.hass, 'test_light_rgb/xy/status', '0.675,0.322')
    self.hass.block_till_done()
    light_state = self.hass.states.get('light.test')
    self.assertEqual([0.675, 0.322], light_state.attributes.get('xy_color'))
