Fix too green color conversion (#13828)
* Prepare test * Fix too green color conversion * Fix remaining tests
This commit is contained in:
1 parent
2a5751c09d
commit
9c1bc18def
6 files changed
+50
-50
No files matched your search
@@ -29,15 +29,15 @@ class TestDemoLight(unittest.TestCase):
|
||||
def test_state_attributes(self):
|
||||
"""Test light state attributes."""
|
||||
light.turn_on(
|
||||
self.hass, ENTITY_LIGHT, xy_color=(.4, .6), brightness=25)
|
||||
self.hass, ENTITY_LIGHT, xy_color=(.4, .4), brightness=25)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_LIGHT)
|
||||
self.assertTrue(light.is_on(self.hass, ENTITY_LIGHT))
|
||||
self.assertEqual((0.378, 0.574), state.attributes.get(
|
||||
self.assertEqual((0.4, 0.4), state.attributes.get(
|
||||
light.ATTR_XY_COLOR))
|
||||
self.assertEqual(25, state.attributes.get(light.ATTR_BRIGHTNESS))
|
||||
self.assertEqual(
|
||||
(207, 255, 0), state.attributes.get(light.ATTR_RGB_COLOR))
|
||||
(255, 234, 164), state.attributes.get(light.ATTR_RGB_COLOR))
|
||||
self.assertEqual('rainbow', state.attributes.get(light.ATTR_EFFECT))
|
||||
light.turn_on(
|
||||
self.hass, ENTITY_LIGHT, rgb_color=(251, 253, 255),
|
||||
@@ -48,7 +48,7 @@ class TestDemoLight(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
(250, 252, 255), state.attributes.get(light.ATTR_RGB_COLOR))
|
||||
self.assertEqual(
|
||||
(0.316, 0.333), state.attributes.get(light.ATTR_XY_COLOR))
|
||||
(0.319, 0.326), state.attributes.get(light.ATTR_XY_COLOR))
|
||||
light.turn_on(self.hass, ENTITY_LIGHT, color_temp=400, effect='none')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_LIGHT)
|
||||
|
||||
@@ -255,7 +255,7 @@ class TestLightMQTT(unittest.TestCase):
|
||||
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((0.32, 0.336), state.attributes.get('xy_color'))
|
||||
self.assertEqual((0.323, 0.329), state.attributes.get('xy_color'))
|
||||
|
||||
fire_mqtt_message(self.hass, 'test_light_rgb/status', '0')
|
||||
self.hass.block_till_done()
|
||||
@@ -311,7 +311,7 @@ class TestLightMQTT(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
|
||||
light_state = self.hass.states.get('light.test')
|
||||
self.assertEqual((0.652, 0.343),
|
||||
self.assertEqual((0.672, 0.324),
|
||||
light_state.attributes.get('xy_color'))
|
||||
|
||||
def test_brightness_controlling_scale(self):
|
||||
@@ -519,7 +519,7 @@ class TestLightMQTT(unittest.TestCase):
|
||||
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.32,0.336', 2, False),
|
||||
mock.call('test_light_rgb/xy/set', '0.323,0.329', 2, False),
|
||||
], any_order=True)
|
||||
|
||||
state = self.hass.states.get('light.test')
|
||||
@@ -527,7 +527,7 @@ class TestLightMQTT(unittest.TestCase):
|
||||
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.32, 0.336), state.attributes['xy_color'])
|
||||
self.assertEqual((0.323, 0.329), state.attributes['xy_color'])
|
||||
|
||||
def test_sending_mqtt_rgb_command_with_template(self):
|
||||
"""Test the sending of RGB command with template."""
|
||||
@@ -679,7 +679,7 @@ class TestLightMQTT(unittest.TestCase):
|
||||
|
||||
state = self.hass.states.get('light.test')
|
||||
self.assertEqual(STATE_ON, state.state)
|
||||
self.assertEqual((0.32, 0.336), state.attributes.get('xy_color'))
|
||||
self.assertEqual((0.323, 0.329), state.attributes.get('xy_color'))
|
||||
|
||||
def test_on_command_first(self):
|
||||
"""Test on command being sent before brightness."""
|
||||
|
||||
@@ -206,7 +206,7 @@ class TestLightMQTTJSON(unittest.TestCase):
|
||||
self.assertEqual(155, state.attributes.get('color_temp'))
|
||||
self.assertEqual('colorloop', state.attributes.get('effect'))
|
||||
self.assertEqual(150, state.attributes.get('white_value'))
|
||||
self.assertEqual((0.32, 0.336), state.attributes.get('xy_color'))
|
||||
self.assertEqual((0.323, 0.329), state.attributes.get('xy_color'))
|
||||
|
||||
# Turn the light off
|
||||
fire_mqtt_message(self.hass, 'test_light_rgb', '{"state":"OFF"}')
|
||||
|
||||
Reference in new issue
Block a user