From 2d064e519500fa5b5728bb933524586efb5900c3 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 25 Aug 2020 18:59:04 +0200 Subject: [PATCH] fix in calc_rgb --- custom_components/circadian_lighting/switch.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/custom_components/circadian_lighting/switch.py b/custom_components/circadian_lighting/switch.py index 7d2fc80d..96afdfbd 100644 --- a/custom_components/circadian_lighting/switch.py +++ b/custom_components/circadian_lighting/switch.py @@ -267,14 +267,15 @@ class CircadianSwitch(SwitchEntity, RestoreEntity): return is_sleep + @property + def _color_temperature(self): + return self._sleep_colortemp if self.is_sleep() else self._cl.data["colortemp"] + def calc_ct(self): - col_temp = ( - self._sleep_colortemp if self.is_sleep() else self._cl.data["colortemp"] - ) - return color_temperature_kelvin_to_mired(col_temp) + return color_temperature_kelvin_to_mired(self._color_temperature) def calc_rgb(self): - return self.calc_ct() + return color_temperature_to_rgb(self._color_temperature) def calc_xy(self): return color_RGB_to_xy(*self.calc_rgb())