Use hue/sat as internal light color interface (#11288)
* Accept and report both xy and RGB color for lights * Fix demo light supported_features * Add new XY color util functions * Always make color changes available as xy and RGB * Always expose color as RGB and XY * Consolidate color supported_features * Test fixes * Additional test fix * Use hue/sat as the hass core color interface * Tests updates * Assume MQTT RGB devices need full RGB brightness * Convert new platforms * More migration * Use float for HS API * Fix backwards conversion for KNX lights * Adjust limitless min saturation for new scale
This commit is contained in:
parent
6b059489a6
commit
89c7c80e42
57 changed files with 898 additions and 965 deletions
|
@ -250,12 +250,12 @@ class TestLightMQTT(unittest.TestCase):
|
|||
|
||||
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, 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'))
|
||||
self.assertEqual((0.32, 0.336), state.attributes.get('xy_color'))
|
||||
|
||||
fire_mqtt_message(self.hass, 'test_light_rgb/status', '0')
|
||||
self.hass.block_till_done()
|
||||
|
@ -303,7 +303,7 @@ class TestLightMQTT(unittest.TestCase):
|
|||
self.hass.block_till_done()
|
||||
|
||||
light_state = self.hass.states.get('light.test')
|
||||
self.assertEqual([125, 125, 125],
|
||||
self.assertEqual((255, 255, 255),
|
||||
light_state.attributes.get('rgb_color'))
|
||||
|
||||
fire_mqtt_message(self.hass, 'test_light_rgb/xy/status',
|
||||
|
@ -311,7 +311,7 @@ class TestLightMQTT(unittest.TestCase):
|
|||
self.hass.block_till_done()
|
||||
|
||||
light_state = self.hass.states.get('light.test')
|
||||
self.assertEqual([0.675, 0.322],
|
||||
self.assertEqual((0.652, 0.343),
|
||||
light_state.attributes.get('xy_color'))
|
||||
|
||||
def test_brightness_controlling_scale(self):
|
||||
|
@ -458,11 +458,11 @@ class TestLightMQTT(unittest.TestCase):
|
|||
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((0, 123, 255), 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'))
|
||||
self.assertEqual((0.14, 0.131), state.attributes.get('xy_color'))
|
||||
|
||||
def test_sending_mqtt_commands_and_optimistic(self): \
|
||||
# pylint: disable=invalid-name
|
||||
|
@ -516,18 +516,18 @@ class TestLightMQTT(unittest.TestCase):
|
|||
|
||||
self.mock_publish.async_publish.assert_has_calls([
|
||||
mock.call('test_light_rgb/set', 'on', 2, False),
|
||||
mock.call('test_light_rgb/rgb/set', '75,75,75', 2, False),
|
||||
mock.call('test_light_rgb/rgb/set', '50,50,50', 2, False),
|
||||
mock.call('test_light_rgb/brightness/set', 50, 2, False),
|
||||
mock.call('test_light_rgb/white_value/set', 80, 2, False),
|
||||
mock.call('test_light_rgb/xy/set', '0.123,0.123', 2, False),
|
||||
mock.call('test_light_rgb/xy/set', '0.32,0.336', 2, False),
|
||||
], any_order=True)
|
||||
|
||||
state = self.hass.states.get('light.test')
|
||||
self.assertEqual(STATE_ON, state.state)
|
||||
self.assertEqual((75, 75, 75), state.attributes['rgb_color'])
|
||||
self.assertEqual((255, 255, 255), state.attributes['rgb_color'])
|
||||
self.assertEqual(50, state.attributes['brightness'])
|
||||
self.assertEqual(80, state.attributes['white_value'])
|
||||
self.assertEqual((0.123, 0.123), state.attributes['xy_color'])
|
||||
self.assertEqual((0.32, 0.336), state.attributes['xy_color'])
|
||||
|
||||
def test_sending_mqtt_rgb_command_with_template(self):
|
||||
"""Test the sending of RGB command with template."""
|
||||
|
@ -554,12 +554,12 @@ class TestLightMQTT(unittest.TestCase):
|
|||
|
||||
self.mock_publish.async_publish.assert_has_calls([
|
||||
mock.call('test_light_rgb/set', 'on', 0, False),
|
||||
mock.call('test_light_rgb/rgb/set', '#ff8040', 0, False),
|
||||
mock.call('test_light_rgb/rgb/set', '#ff803f', 0, False),
|
||||
], any_order=True)
|
||||
|
||||
state = self.hass.states.get('light.test')
|
||||
self.assertEqual(STATE_ON, state.state)
|
||||
self.assertEqual((255, 128, 64), state.attributes['rgb_color'])
|
||||
self.assertEqual((255, 128, 63), state.attributes['rgb_color'])
|
||||
|
||||
def test_show_brightness_if_only_command_topic(self):
|
||||
"""Test the brightness if only a command topic is present."""
|
||||
|
@ -679,7 +679,7 @@ class TestLightMQTT(unittest.TestCase):
|
|||
|
||||
state = self.hass.states.get('light.test')
|
||||
self.assertEqual(STATE_ON, state.state)
|
||||
self.assertEqual([1, 1], state.attributes.get('xy_color'))
|
||||
self.assertEqual((0.32, 0.336), state.attributes.get('xy_color'))
|
||||
|
||||
def test_on_command_first(self):
|
||||
"""Test on command being sent before brightness."""
|
||||
|
@ -799,7 +799,7 @@ class TestLightMQTT(unittest.TestCase):
|
|||
self.hass.block_till_done()
|
||||
|
||||
self.mock_publish.async_publish.assert_has_calls([
|
||||
mock.call('test_light/rgb', '75,75,75', 0, False),
|
||||
mock.call('test_light/rgb', '50,50,50', 0, False),
|
||||
mock.call('test_light/bright', 50, 0, False)
|
||||
], any_order=True)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue