Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make RGB values consistent as int. fixes #10766 #10782

Merged
merged 2 commits into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/util/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def color_rgbw_to_rgb(r, g, b, w):

def color_rgb_to_hex(r, g, b):
"""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):
Expand Down
1 change: 1 addition & 0 deletions tests/util/test_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def test_color_rgb_to_hex(self):
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(51, 153, 255) == '3399ff'
assert color_util.color_rgb_to_hex(255, 67.9204190, 0) == 'ff4400'


class ColorTemperatureMiredToKelvinTests(unittest.TestCase):
Expand Down