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:
Adam Mills authored and Paulus Schoutsen committed 2018-03-18 15:00:29 -07:00
1 parent 6b059489a6
commit 89c7c80e42
57 files changed
+898 -965

No files matched your search

@@ -21,7 +21,7 @@ async def test_sync_message(hass):
light = DemoLight(
None, 'Demo Light',
state=False,
rgb=[237, 224, 33]
hs_color=(180, 75),
)
light.hass = hass
light.entity_id = 'light.demo_light'
@@ -88,7 +88,7 @@ async def test_query_message(hass):
light = DemoLight(
None, 'Demo Light',
state=False,
rgb=[237, 224, 33]
hs_color=(180, 75),
)
light.hass = hass
light.entity_id = 'light.demo_light'
@@ -97,7 +97,7 @@ async def test_query_message(hass):
light2 = DemoLight(
None, 'Another Light',
state=True,
rgb=[237, 224, 33],
hs_color=(180, 75),
ct=400,
brightness=78,
)
@@ -137,7 +137,7 @@ async def test_query_message(hass):
'online': True,
'brightness': 30,
'color': {
'spectrumRGB': 15589409,
'spectrumRGB': 4194303,
'temperature': 2500,
}
},
@@ -197,7 +197,7 @@ async def test_execute(hass):
"online": True,
'brightness': 20,
'color': {
'spectrumRGB': 15589409,
'spectrumRGB': 16773155,
'temperature': 2631,
},
}
@@ -361,12 +361,10 @@ async def test_color_spectrum_light(hass):
"""Test ColorSpectrum trait support for light domain."""
assert not trait.ColorSpectrumTrait.supported(light.DOMAIN, 0)
assert trait.ColorSpectrumTrait.supported(light.DOMAIN,
light.SUPPORT_RGB_COLOR)
assert trait.ColorSpectrumTrait.supported(light.DOMAIN,
light.SUPPORT_XY_COLOR)
light.SUPPORT_COLOR)
trt = trait.ColorSpectrumTrait(State('light.bla', STATE_ON, {
light.ATTR_RGB_COLOR: [255, 10, 10]
light.ATTR_HS_COLOR: (0, 94),
}))
assert trt.sync_attributes() == {
@@ -375,7 +373,7 @@ async def test_color_spectrum_light(hass):
assert trt.query_attributes() == {
'color': {
'spectrumRGB': 16714250
'spectrumRGB': 16715535
}
}
@@ -399,7 +397,7 @@ async def test_color_spectrum_light(hass):
assert len(calls) == 1
assert calls[0].data == {
ATTR_ENTITY_ID: 'light.bla',
light.ATTR_RGB_COLOR: [16, 16, 255]
light.ATTR_HS_COLOR: (240, 93.725),
}