Refactor mysensors light
* Add a light entity class per V_LIGHT, V_DIMMER, V_RGB and V_RGBW.
Make these classes inherit each other up to MySensorsLight class.
* Map the entity classes to their S_TYPE in a dict.
* Check if an entity class map or just an entity class have been passed
to pf_callback_factory before using the entity_class variable in
homeassistant/components/mysensors.py.
* Add rgb_hex_to_list function in homeassistant/util/color.py.
This commit is contained in:
1 parent
bb37708716
commit
03423cc3a9
3 files changed
+244
-102
No files matched your search
@@ -1,5 +1,6 @@
|
||||
"""
|
||||
homeassistant.util.color
|
||||
homeassistant.util.color.
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Color util methods.
|
||||
"""
|
||||
@@ -9,7 +10,7 @@ Color util methods.
|
||||
# License: Code is given as is. Use at your own risk and discretion.
|
||||
# pylint: disable=invalid-name
|
||||
def color_RGB_to_xy(R, G, B):
|
||||
""" Convert from RGB color to XY color. """
|
||||
"""Convert from RGB color to XY color."""
|
||||
if R + G + B == 0:
|
||||
return 0, 0
|
||||
|
||||
@@ -50,9 +51,7 @@ def color_RGB_to_xy(R, G, B):
|
||||
# Copyright (c) 2014 Benjamin Knight / MIT License.
|
||||
# pylint: disable=bad-builtin
|
||||
def color_xy_brightness_to_RGB(vX, vY, brightness):
|
||||
'''
|
||||
Convert from XYZ to RGB.
|
||||
'''
|
||||
"""Convert from XYZ to RGB."""
|
||||
brightness /= 255.
|
||||
if brightness == 0:
|
||||
return (0, 0, 0)
|
||||
@@ -88,3 +87,11 @@ def color_xy_brightness_to_RGB(vX, vY, brightness):
|
||||
r, g, b = map(lambda x: int(x * 255), [r, g, b])
|
||||
|
||||
return (r, g, b)
|
||||
|
||||
|
||||
def rgb_hex_to_list(hex_string):
|
||||
"""Return an RGB color value list from a hex color string."""
|
||||
return [int(hex_string[i:i + len(hex_string) // 3], 16)
|
||||
for i in range(0,
|
||||
len(hex_string),
|
||||
len(hex_string) // 3)]
|
||||
Reference in new issue
Block a user