From 3be5f4448876f0ace7f712154d5d621bfeca99ce Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 25 Aug 2020 18:46:52 +0200 Subject: [PATCH] simplify calc_ct and calc_rgb --- custom_components/circadian_lighting/switch.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/custom_components/circadian_lighting/switch.py b/custom_components/circadian_lighting/switch.py index 139a6c06..76aaa6f7 100644 --- a/custom_components/circadian_lighting/switch.py +++ b/custom_components/circadian_lighting/switch.py @@ -283,16 +283,11 @@ class CircadianSwitch(SwitchEntity, RestoreEntity): return is_sleep def calc_ct(self): - if self.is_sleep(): - return color_temperature_kelvin_to_mired(self._sleep_colortemp) - else: - return color_temperature_kelvin_to_mired(self._cl.data["colortemp"]) + col_temp = self._sleep_colortemp if self.is_sleep() else self._cl.data["colortemp"] + return color_temperature_kelvin_to_mired(col_temp) def calc_rgb(self): - if self.is_sleep(): - return color_temperature_to_rgb(self._sleep_colortemp) - else: - return color_temperature_to_rgb(self._cl.data["colortemp"]) + return self.calc_ct() def calc_xy(self): return color_RGB_to_xy(*self.calc_rgb())