From 5491c7dcf173a9b34166c1d07475808bc8bb2417 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Thu, 27 Aug 2020 23:22:38 +0200 Subject: [PATCH] simplify color settings --- custom_components/circadian_lighting/switch.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/custom_components/circadian_lighting/switch.py b/custom_components/circadian_lighting/switch.py index 6ee48d0d..9c5f1dd8 100644 --- a/custom_components/circadian_lighting/switch.py +++ b/custom_components/circadian_lighting/switch.py @@ -346,27 +346,21 @@ class CircadianSwitch(SwitchEntity, RestoreEntity): # Set color of array of ct. if self._lights_ct is not None and light in self._lights_ct: which = "CT" - mired = int(self.calc_ct()) if self._lights_ct is not None else None - if mired is not None: - service_data[ATTR_COLOR_TEMP] = mired + service_data[ATTR_COLOR_TEMP] = int(self.calc_ct()) if brightness is not None: service_data[ATTR_BRIGHTNESS] = brightness # Set color of array of rgb. elif self._lights_rgb is not None and light in self._lights_rgb: which = "RGB" - rgb = tuple(map(int, self.calc_rgb())) if self._lights_rgb is not None else None - if rgb is not None: - service_data[ATTR_RGB_COLOR] = rgb + service_data[ATTR_RGB_COLOR] = tuple(map(int, self.calc_rgb())) if brightness is not None: service_data[ATTR_BRIGHTNESS] = brightness # Set color of array of xy. elif self._lights_xy is not None and light in self._lights_xy: which = "XY" - xy = self.calc_xy() if self._lights_xy is not None else None - if xy is not None: - service_data[ATTR_XY_COLOR] = xy + service_data[ATTR_XY_COLOR] = self.calc_xy() if brightness is not None: service_data[ATTR_BRIGHTNESS] = brightness service_data[ATTR_WHITE_VALUE] = brightness