mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
* make RGB consitant as int. fixes #10766 * fix rounding and only change for hex convertion
This commit is contained in:
parent
6cd9ca018a
commit
2daea92379
@ -357,7 +357,7 @@ def color_rgbw_to_rgb(r, g, b, w):
|
|||||||
|
|
||||||
def color_rgb_to_hex(r, g, b):
|
def color_rgb_to_hex(r, g, b):
|
||||||
"""Return a RGB color from a hex color string."""
|
"""Return a RGB color from a hex color string."""
|
||||||
return '{0:02x}{1:02x}{2:02x}'.format(r, g, b)
|
return '{0:02x}{1:02x}{2:02x}'.format(round(r), round(g), round(b))
|
||||||
|
|
||||||
|
|
||||||
def rgb_hex_to_rgb_list(hex_string):
|
def rgb_hex_to_rgb_list(hex_string):
|
||||||
|
@ -212,6 +212,7 @@ class TestColorUtil(unittest.TestCase):
|
|||||||
assert color_util.color_rgb_to_hex(255, 255, 255) == 'ffffff'
|
assert color_util.color_rgb_to_hex(255, 255, 255) == 'ffffff'
|
||||||
assert color_util.color_rgb_to_hex(0, 0, 0) == '000000'
|
assert color_util.color_rgb_to_hex(0, 0, 0) == '000000'
|
||||||
assert color_util.color_rgb_to_hex(51, 153, 255) == '3399ff'
|
assert color_util.color_rgb_to_hex(51, 153, 255) == '3399ff'
|
||||||
|
assert color_util.color_rgb_to_hex(255, 67.9204190, 0) == 'ff4400'
|
||||||
|
|
||||||
|
|
||||||
class ColorTemperatureMiredToKelvinTests(unittest.TestCase):
|
class ColorTemperatureMiredToKelvinTests(unittest.TestCase):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user