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

Fix tradfri lights #7212

Merged
merged 2 commits into from
Apr 22, 2017
Merged
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
9 changes: 4 additions & 5 deletions homeassistant/components/light/tradfri.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
PLATFORM_SCHEMA as LIGHT_PLATFORM_SCHEMA
from homeassistant.components.tradfri import KEY_GATEWAY
from homeassistant.util import color as color_util
from homeassistant.util import slugify

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -48,12 +47,12 @@ def __init__(self, light):

if self._light_data.hex_color is not None:
if self._light.device_info.manufacturer == IKEA:
self._features &= SUPPORT_COLOR_TEMP
self._features |= SUPPORT_COLOR_TEMP
else:
self._features &= SUPPORT_RGB_COLOR
self._features |= SUPPORT_RGB_COLOR

self._ok_temps = ALLOWED_TEMPERATURES.get(
slugify(self._light.device_info.manufacturer))
self._light.device_info.manufacturer)

@property
def supported_features(self):
Expand Down Expand Up @@ -123,7 +122,7 @@ def turn_on(self, **kwargs):
kelvin = color_util.color_temperature_mired_to_kelvin(
kwargs[ATTR_COLOR_TEMP])
# find closest allowed kelvin temp from user input
kelvin = min(self._ok_temps.keys(), key=lambda x: abs(x-kelvin))
kelvin = min(self._ok_temps.keys(), key=lambda x: abs(x - kelvin))
self._light_control.set_hex_color(self._ok_temps[kelvin])

def update(self):
Expand Down