From 29010105c146684c0daffa4e04c061d65073e62f Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Mon, 31 Aug 2020 23:46:36 +0200 Subject: [PATCH] change elif in if when returning --- .../circadian_lighting/switch.py | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/custom_components/circadian_lighting/switch.py b/custom_components/circadian_lighting/switch.py index 729046c4..a342b045 100755 --- a/custom_components/circadian_lighting/switch.py +++ b/custom_components/circadian_lighting/switch.py @@ -250,9 +250,9 @@ class CircadianSwitch(SwitchEntity, RestoreEntity): def _color_temperature(self): return ( - self._sleep_colortemp - if self.is_sleep() - else self._circadian_lighting._colortemp + self._circadian_lighting._colortemp + if not self.is_sleep() + else self._sleep_colortemp ) def calc_ct(self): @@ -270,14 +270,13 @@ class CircadianSwitch(SwitchEntity, RestoreEntity): def calc_brightness(self): if self._disable_brightness_adjust is True: return None - elif self.is_sleep(): + if self.is_sleep(): return self._sleep_brightness - elif self._circadian_lighting._percent > 0: + if self._circadian_lighting._percent > 0: return self._max_brightness - else: - delta_brightness = self._max_brightness - self._min_brightness - procent = (100 + self._circadian_lighting._percent) / 100 - return (delta_brightness * procent) + self._min_brightness + delta_brightness = self._max_brightness - self._min_brightness + procent = (100 + self._circadian_lighting._percent) / 100 + return (delta_brightness * procent) + self._min_brightness @log(logger=_LOGGER) def _update_switch(self, lights=None, transition=None, force=False): @@ -298,10 +297,9 @@ class CircadianSwitch(SwitchEntity, RestoreEntity): def _should_adjust(self): if self._state is not True: return False - elif self._is_disabled(): + if self._is_disabled(): return False - else: - return True + return True def _adjust_lights(self, lights, transition=None): if not self._should_adjust():