Google Assistant: Migrate light setting trait to use HSV color spectrum (#22980)
* Migrate light setting trait to use HSV * Fix tests * Fix all the typos
This commit is contained in:
1 parent
c2cfc4a813
commit
f33bf718c7
4 files changed
+83
-29
No files matched your search
@@ -174,8 +174,12 @@ def test_query_request(hass_fixture, assistant_client, auth_header):
|
||||
assert devices['light.bed_light']['on'] is False
|
||||
assert devices['light.ceiling_lights']['on'] is True
|
||||
assert devices['light.ceiling_lights']['brightness'] == 70
|
||||
assert devices['light.kitchen_lights']['color']['spectrumRGB'] == 16727919
|
||||
assert devices['light.kitchen_lights']['color']['temperature'] == 4166
|
||||
assert devices['light.kitchen_lights']['color']['spectrumHsv'] == {
|
||||
'hue': 345,
|
||||
'saturation': 0.75,
|
||||
'value': 0.7058823529411765,
|
||||
}
|
||||
assert devices['light.kitchen_lights']['color']['temperatureK'] == 4166
|
||||
assert devices['media_player.lounge_room']['on'] is True
|
||||
|
||||
|
||||
|
||||
@@ -98,9 +98,11 @@ async def test_sync_message(hass):
|
||||
'type': sh.TYPE_LIGHT,
|
||||
'willReportState': False,
|
||||
'attributes': {
|
||||
'colorModel': 'rgb',
|
||||
'temperatureMinK': 2000,
|
||||
'temperatureMaxK': 6535,
|
||||
'colorModel': 'hsv',
|
||||
'colorTemperatureRange': {
|
||||
'temperatureMinK': 2000,
|
||||
'temperatureMaxK': 6535,
|
||||
}
|
||||
},
|
||||
'roomHint': 'Living Room'
|
||||
}]
|
||||
@@ -176,9 +178,11 @@ async def test_sync_in_area(hass, registries):
|
||||
'type': sh.TYPE_LIGHT,
|
||||
'willReportState': False,
|
||||
'attributes': {
|
||||
'colorModel': 'rgb',
|
||||
'temperatureMinK': 2000,
|
||||
'temperatureMaxK': 6535,
|
||||
'colorModel': 'hsv',
|
||||
'colorTemperatureRange': {
|
||||
'temperatureMinK': 2000,
|
||||
'temperatureMaxK': 6535,
|
||||
}
|
||||
},
|
||||
'roomHint': 'Living Room'
|
||||
}]
|
||||
@@ -252,8 +256,12 @@ async def test_query_message(hass):
|
||||
'online': True,
|
||||
'brightness': 30,
|
||||
'color': {
|
||||
'spectrumRGB': 4194303,
|
||||
'temperature': 2500,
|
||||
'spectrumHsv': {
|
||||
'hue': 180,
|
||||
'saturation': 0.75,
|
||||
'value': 0.3058823529411765,
|
||||
},
|
||||
'temperatureK': 2500,
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -338,8 +346,12 @@ async def test_execute(hass):
|
||||
"online": True,
|
||||
'brightness': 20,
|
||||
'color': {
|
||||
'spectrumRGB': 16773155,
|
||||
'temperature': 2631,
|
||||
'spectrumHsv': {
|
||||
'hue': 56,
|
||||
'saturation': 0.86,
|
||||
'value': 0.2,
|
||||
},
|
||||
'temperatureK': 2631,
|
||||
},
|
||||
}
|
||||
}]
|
||||
|
||||
@@ -459,17 +459,22 @@ async def test_color_setting_color_light(hass):
|
||||
light.SUPPORT_COLOR, None)
|
||||
|
||||
trt = trait.ColorSettingTrait(hass, State('light.bla', STATE_ON, {
|
||||
light.ATTR_HS_COLOR: (0, 94),
|
||||
light.ATTR_HS_COLOR: (20, 94),
|
||||
light.ATTR_BRIGHTNESS: 200,
|
||||
ATTR_SUPPORTED_FEATURES: light.SUPPORT_COLOR,
|
||||
}), BASIC_CONFIG)
|
||||
|
||||
assert trt.sync_attributes() == {
|
||||
'colorModel': 'rgb'
|
||||
'colorModel': 'hsv'
|
||||
}
|
||||
|
||||
assert trt.query_attributes() == {
|
||||
'color': {
|
||||
'spectrumRGB': 16715535
|
||||
'spectrumHsv': {
|
||||
'hue': 20,
|
||||
'saturation': 0.94,
|
||||
'value': 200 / 255,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,6 +496,22 @@ async def test_color_setting_color_light(hass):
|
||||
light.ATTR_HS_COLOR: (240, 93.725),
|
||||
}
|
||||
|
||||
await trt.execute(trait.COMMAND_COLOR_ABSOLUTE, BASIC_DATA, {
|
||||
'color': {
|
||||
'spectrumHSV': {
|
||||
'hue': 100,
|
||||
'saturation': .50,
|
||||
'value': .20,
|
||||
}
|
||||
}
|
||||
})
|
||||
assert len(calls) == 2
|
||||
assert calls[1].data == {
|
||||
ATTR_ENTITY_ID: 'light.bla',
|
||||
light.ATTR_HS_COLOR: [100, 50],
|
||||
light.ATTR_BRIGHTNESS: .2 * 255,
|
||||
}
|
||||
|
||||
|
||||
async def test_color_setting_temperature_light(hass):
|
||||
"""Test ColorTemperature trait support for light domain."""
|
||||
@@ -506,13 +527,15 @@ async def test_color_setting_temperature_light(hass):
|
||||
}), BASIC_CONFIG)
|
||||
|
||||
assert trt.sync_attributes() == {
|
||||
'temperatureMinK': 2000,
|
||||
'temperatureMaxK': 5000,
|
||||
'colorTemperatureRange': {
|
||||
'temperatureMinK': 2000,
|
||||
'temperatureMaxK': 5000,
|
||||
}
|
||||
}
|
||||
|
||||
assert trt.query_attributes() == {
|
||||
'color': {
|
||||
'temperature': 3333
|
||||
'temperatureK': 3333
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user