Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ATTR_DEVICE_STATE: False,
},
],
[
"set_hex_color", "valid", {
'color': '4a418a',
}, {
ATTR_LIGHT_COLOR_HEX: '4a418a',
},
],
[
"set_hex_color", "invalid", {
'color': 'RandomString',
}, {
ATTR_LIGHT_COLOR_HEX: 'RandomString',
},
],
[
"set_hex_color", "with_transitiontime", {
'color': '4a418a',
'transition_time': 2
}, {
ATTR_LIGHT_COLOR_HEX: '4a418a',
ATTR_TRANSITION_TIME: 2
},
],
[
"set_predefined_color", "valid", {
'colorname': 'Saturated Purple'
}, {
def supported_features(data):
SUPPORTED_COLOR_FEATURES = 0
if ATTR_LIGHT_DIMMER in data:
SUPPORTED_COLOR_FEATURES = SUPPORTED_COLOR_FEATURES\
+ SUPPORT_BRIGHTNESS
if ATTR_LIGHT_COLOR_HEX in data:
SUPPORTED_COLOR_FEATURES = SUPPORTED_COLOR_FEATURES\
+ SUPPORT_HEX_COLOR
if ATTR_LIGHT_MIREDS in data:
SUPPORTED_COLOR_FEATURES = SUPPORTED_COLOR_FEATURES\
+ SUPPORT_COLOR_TEMP
if X in data and Y in data:
SUPPORTED_COLOR_FEATURES = SUPPORTED_COLOR_FEATURES\
+ SUPPORT_XY_COLOR
if ATTR_LIGHT_MIREDS not in data and X in data and Y in data and \
ATTR_LIGHT_COLOR_SATURATION in data and ATTR_LIGHT_COLOR_HUE\
in data:
SUPPORTED_COLOR_FEATURES = SUPPORTED_COLOR_FEATURES\
+ SUPPORT_RGB_COLOR
def hex_color(self):
if self.supported_features & SUPPORT_HEX_COLOR:
return self.raw.get(ATTR_LIGHT_COLOR_HEX)
def set_hex_color(self, color, *, index=0, transition_time=None):
"""Set hex color of the light."""
values = {
ATTR_LIGHT_COLOR_HEX: color,
}
if transition_time is not None:
values[ATTR_TRANSITION_TIME] = transition_time
return self.set_values(values, index=index)
def hex_color(self):
return self.raw.get(ATTR_LIGHT_COLOR_HEX)
def set_hex_color(self, color, transition_time=None):
"""Set hex color of a group."""
values = {
ATTR_LIGHT_COLOR_HEX: color,
}
if transition_time is not None:
values[ATTR_TRANSITION_TIME] = transition_time
return self.set_values(values)