'Test the brightness controlling scale.'

def test_brightness_controlling_scale(self):

    with assert_setup_component(1, light.DOMAIN):
        assert setup_component(self.hass, light.DOMAIN, {light.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'test_scale/status', 'command_topic': 'test_scale/set', 'brightness_state_topic': 'test_scale/brightness/status', 'brightness_command_topic': 'test_scale/brightness/set', 'brightness_scale': '99', 'qos': 0, 'payload_on': 'on', 'payload_off': 'off'}})
    state = self.hass.states.get('light.test')
    self.assertEqual(STATE_OFF, state.state)
    self.assertIsNone(state.attributes.get('brightness'))
    self.assertFalse(state.attributes.get(ATTR_ASSUMED_STATE))
    fire_mqtt_message(self.hass, 'test_scale/status', 'on')
    self.hass.block_till_done()
    state = self.hass.states.get('light.test')
    self.assertEqual(STATE_ON, state.state)
    self.assertEqual(255, state.attributes.get('brightness'))
    fire_mqtt_message(self.hass, 'test_scale/status', 'off')
    self.hass.block_till_done()
    state = self.hass.states.get('light.test')
    self.assertEqual(STATE_OFF, state.state)
    fire_mqtt_message(self.hass, 'test_scale/status', 'on')
    self.hass.block_till_done()
    fire_mqtt_message(self.hass, 'test_scale/brightness/status', '99')
    self.hass.block_till_done()
    light_state = self.hass.states.get('light.test')
    self.hass.block_till_done()
    self.assertEqual(255, light_state.attributes['brightness'])
