'Test the setting og the state with a template.'

def test_controlling_state_via_topic_with_templates(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', 'color_temp_state_topic': 'test_light_rgb/color_temp/status', 'effect_state_topic': 'test_light_rgb/effect/status', 'rgb_state_topic': 'test_light_rgb/rgb/status', 'white_value_state_topic': 'test_light_rgb/white_value/status', 'xy_state_topic': 'test_light_rgb/xy/status', 'state_value_template': '{{    value_json.hello    }}', 'brightness_value_template': '{{    value_json.hello    }}', 'color_temp_value_template': '{{    value_json.hello    }}', 'effect_value_template': '{{    value_json.hello    }}', 'rgb_value_template': '{{    value_json.hello    |    join(",")    }}', 'white_value_template': '{{    value_json.hello    }}', 'xy_value_template': '{{    value_json.hello    |    join(",")    }}'}}
    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('brightness'))
    self.assertIsNone(state.attributes.get('rgb_color'))
    fire_mqtt_message(self.hass, 'test_light_rgb/rgb/status', '{"hello":    [1,    2,    3]}')
    fire_mqtt_message(self.hass, 'test_light_rgb/status', '{"hello":    "ON"}')
    fire_mqtt_message(self.hass, 'test_light_rgb/brightness/status', '{"hello":    "50"}')
    fire_mqtt_message(self.hass, 'test_light_rgb/color_temp/status', '{"hello":    "300"}')
    fire_mqtt_message(self.hass, 'test_light_rgb/effect/status', '{"hello":    "rainbow"}')
    fire_mqtt_message(self.hass, 'test_light_rgb/white_value/status', '{"hello":    "75"}')
    fire_mqtt_message(self.hass, 'test_light_rgb/xy/status', '{"hello":    [0.123,0.123]}')
    self.hass.block_till_done()
    state = self.hass.states.get('light.test')
    self.assertEqual(STATE_ON, state.state)
    self.assertEqual(50, state.attributes.get('brightness'))
    self.assertEqual([1, 2, 3], state.attributes.get('rgb_color'))
    self.assertEqual(300, state.attributes.get('color_temp'))
    self.assertEqual('rainbow', state.attributes.get('effect'))
    self.assertEqual(75, state.attributes.get('white_value'))
    self.assertEqual([0.123, 0.123], state.attributes.get('xy_color'))
