From 1c2224cc5c89d8780c05d98237f5a6ea9fb3e333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Soko=C5=82owski?= Date: Thu, 2 Nov 2017 09:18:20 +0100 Subject: [PATCH] Fixed Tradfri whitebulbs handling after #9703 (#10040) --- homeassistant/components/light/tradfri.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/light/tradfri.py b/homeassistant/components/light/tradfri.py index 0a54522d7b7..c71ca60ee03 100644 --- a/homeassistant/components/light/tradfri.py +++ b/homeassistant/components/light/tradfri.py @@ -161,16 +161,18 @@ class TradfriLight(Light): @property def min_mireds(self): """Return the coldest color_temp that this light supports.""" - return color_util.color_temperature_kelvin_to_mired( - self._light_control.max_kelvin - ) + if self._light_control.max_kelvin is not None: + return color_util.color_temperature_kelvin_to_mired( + self._light_control.max_kelvin + ) @property def max_mireds(self): """Return the warmest color_temp that this light supports.""" - return color_util.color_temperature_kelvin_to_mired( - self._light_control.min_kelvin - ) + if self._light_control.min_kelvin is not None: + return color_util.color_temperature_kelvin_to_mired( + self._light_control.min_kelvin + ) @property def device_state_attributes(self): @@ -219,9 +221,11 @@ class TradfriLight(Light): @property def color_temp(self): """Return the CT color value in mireds.""" - return color_util.color_temperature_kelvin_to_mired( - self._light_data.kelvin_color_inferred - ) + kelvin_color = self._light_data.kelvin_color_inferred + if kelvin_color is not None: + return color_util.color_temperature_kelvin_to_mired( + kelvin_color + ) @property def rgb_color(self):