Add color setting trait (#22894)
This commit is contained in:
1 parent
37f3eccb1e
commit
51e6d5380e
4 files changed
+97
-137
No files matched your search
@@ -10,8 +10,7 @@ DEMO_DEVICES = [{
|
||||
},
|
||||
'traits': [
|
||||
'action.devices.traits.OnOff', 'action.devices.traits.Brightness',
|
||||
'action.devices.traits.ColorSpectrum',
|
||||
'action.devices.traits.ColorTemperature'
|
||||
'action.devices.traits.ColorSetting',
|
||||
],
|
||||
'type':
|
||||
'action.devices.types.LIGHT',
|
||||
@@ -50,8 +49,7 @@ DEMO_DEVICES = [{
|
||||
},
|
||||
'traits': [
|
||||
'action.devices.traits.OnOff', 'action.devices.traits.Brightness',
|
||||
'action.devices.traits.ColorSpectrum',
|
||||
'action.devices.traits.ColorTemperature'
|
||||
'action.devices.traits.ColorSetting',
|
||||
],
|
||||
'type':
|
||||
'action.devices.types.LIGHT',
|
||||
@@ -65,8 +63,7 @@ DEMO_DEVICES = [{
|
||||
},
|
||||
'traits': [
|
||||
'action.devices.traits.OnOff', 'action.devices.traits.Brightness',
|
||||
'action.devices.traits.ColorSpectrum',
|
||||
'action.devices.traits.ColorTemperature'
|
||||
'action.devices.traits.ColorSetting',
|
||||
],
|
||||
'type':
|
||||
'action.devices.types.LIGHT',
|
||||
|
||||
@@ -93,8 +93,7 @@ async def test_sync_message(hass):
|
||||
'traits': [
|
||||
trait.TRAIT_BRIGHTNESS,
|
||||
trait.TRAIT_ONOFF,
|
||||
trait.TRAIT_COLOR_SPECTRUM,
|
||||
trait.TRAIT_COLOR_TEMP,
|
||||
trait.TRAIT_COLOR_SETTING,
|
||||
],
|
||||
'type': sh.TYPE_LIGHT,
|
||||
'willReportState': False,
|
||||
@@ -172,8 +171,7 @@ async def test_sync_in_area(hass, registries):
|
||||
'traits': [
|
||||
trait.TRAIT_BRIGHTNESS,
|
||||
trait.TRAIT_ONOFF,
|
||||
trait.TRAIT_COLOR_SPECTRUM,
|
||||
trait.TRAIT_COLOR_TEMP,
|
||||
trait.TRAIT_COLOR_SETTING,
|
||||
],
|
||||
'type': sh.TYPE_LIGHT,
|
||||
'willReportState': False,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user