'Test state change via topic.'

def test_state_change_via_topic(self):

    with assert_setup_component(1, light.DOMAIN):
        assert setup_component(self.hass, light.DOMAIN, {light.DOMAIN: {'platform': 'mqtt_template', 'name': 'test', 'state_topic': 'test_light_rgb', 'command_topic': 'test_light_rgb/set', 'command_on_template': 'on,{{    brightness|d    }},{{    color_temp|d    }},{{    white_value|d    }},{{    red|d    }}-{{    green|d    }}-{{    blue|d    }}', 'command_off_template': 'off', 'state_template': '{{    value.split(",")[0]    }}'}})
    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('white_value'))
    self.assertFalse(state.attributes.get(ATTR_ASSUMED_STATE))
    fire_mqtt_message(self.hass, 'test_light_rgb', 'on')
    self.hass.block_till_done()
    state = self.hass.states.get('light.test')
    self.assertEqual(STATE_ON, 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('white_value'))
