Add color setting trait (#22894)
This commit is contained in:
parent
37f3eccb1e
commit
51e6d5380e
4 changed files with 97 additions and 137 deletions
|
@ -452,14 +452,15 @@ async def test_startstop_vacuum(hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_color_spectrum_light(hass):
|
||||
async def test_color_setting_color_light(hass):
|
||||
"""Test ColorSpectrum trait support for light domain."""
|
||||
assert not trait.ColorSpectrumTrait.supported(light.DOMAIN, 0, None)
|
||||
assert trait.ColorSpectrumTrait.supported(light.DOMAIN,
|
||||
light.SUPPORT_COLOR, None)
|
||||
assert not trait.ColorSettingTrait.supported(light.DOMAIN, 0, None)
|
||||
assert trait.ColorSettingTrait.supported(light.DOMAIN,
|
||||
light.SUPPORT_COLOR, None)
|
||||
|
||||
trt = trait.ColorSpectrumTrait(hass, State('light.bla', STATE_ON, {
|
||||
trt = trait.ColorSettingTrait(hass, State('light.bla', STATE_ON, {
|
||||
light.ATTR_HS_COLOR: (0, 94),
|
||||
ATTR_SUPPORTED_FEATURES: light.SUPPORT_COLOR,
|
||||
}), BASIC_CONFIG)
|
||||
|
||||
assert trt.sync_attributes() == {
|
||||
|
@ -472,11 +473,6 @@ async def test_color_spectrum_light(hass):
|
|||
}
|
||||
}
|
||||
|
||||
assert not trt.can_execute(trait.COMMAND_COLOR_ABSOLUTE, {
|
||||
'color': {
|
||||
'temperature': 400
|
||||
}
|
||||
})
|
||||
assert trt.can_execute(trait.COMMAND_COLOR_ABSOLUTE, {
|
||||
'color': {
|
||||
'spectrumRGB': 16715792
|
||||
|
@ -496,17 +492,17 @@ async def test_color_spectrum_light(hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_color_temperature_light(hass):
|
||||
async def test_color_setting_temperature_light(hass):
|
||||
"""Test ColorTemperature trait support for light domain."""
|
||||
assert not trait.ColorTemperatureTrait.supported(light.DOMAIN, 0, None)
|
||||
assert trait.ColorTemperatureTrait.supported(light.DOMAIN,
|
||||
light.SUPPORT_COLOR_TEMP,
|
||||
None)
|
||||
assert not trait.ColorSettingTrait.supported(light.DOMAIN, 0, None)
|
||||
assert trait.ColorSettingTrait.supported(light.DOMAIN,
|
||||
light.SUPPORT_COLOR_TEMP, None)
|
||||
|
||||
trt = trait.ColorTemperatureTrait(hass, State('light.bla', STATE_ON, {
|
||||
trt = trait.ColorSettingTrait(hass, State('light.bla', STATE_ON, {
|
||||
light.ATTR_MIN_MIREDS: 200,
|
||||
light.ATTR_COLOR_TEMP: 300,
|
||||
light.ATTR_MAX_MIREDS: 500,
|
||||
ATTR_SUPPORTED_FEATURES: light.SUPPORT_COLOR_TEMP,
|
||||
}), BASIC_CONFIG)
|
||||
|
||||
assert trt.sync_attributes() == {
|
||||
|
@ -525,12 +521,6 @@ async def test_color_temperature_light(hass):
|
|||
'temperature': 400
|
||||
}
|
||||
})
|
||||
assert not trt.can_execute(trait.COMMAND_COLOR_ABSOLUTE, {
|
||||
'color': {
|
||||
'spectrumRGB': 16715792
|
||||
}
|
||||
})
|
||||
|
||||
calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
|
||||
with pytest.raises(helpers.SmartHomeError) as err:
|
||||
|
@ -553,14 +543,13 @@ async def test_color_temperature_light(hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_color_temperature_light_bad_temp(hass):
|
||||
async def test_color_light_temperature_light_bad_temp(hass):
|
||||
"""Test ColorTemperature trait support for light domain."""
|
||||
assert not trait.ColorTemperatureTrait.supported(light.DOMAIN, 0, None)
|
||||
assert trait.ColorTemperatureTrait.supported(light.DOMAIN,
|
||||
light.SUPPORT_COLOR_TEMP,
|
||||
None)
|
||||
assert not trait.ColorSettingTrait.supported(light.DOMAIN, 0, None)
|
||||
assert trait.ColorSettingTrait.supported(light.DOMAIN,
|
||||
light.SUPPORT_COLOR_TEMP, None)
|
||||
|
||||
trt = trait.ColorTemperatureTrait(hass, State('light.bla', STATE_ON, {
|
||||
trt = trait.ColorSettingTrait(hass, State('light.bla', STATE_ON, {
|
||||
light.ATTR_MIN_MIREDS: 200,
|
||||
light.ATTR_COLOR_TEMP: 0,
|
||||
light.ATTR_MAX_MIREDS: 500,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue