From 76b544682ef0a9997f571cfbbbbd679c5b023882 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 1 Sep 2020 08:38:19 +0200 Subject: [PATCH] fix typos and use self._brightness --- custom_components/circadian_lighting/switch.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/custom_components/circadian_lighting/switch.py b/custom_components/circadian_lighting/switch.py index 8519fe9f..312d2c91 100755 --- a/custom_components/circadian_lighting/switch.py +++ b/custom_components/circadian_lighting/switch.py @@ -272,16 +272,16 @@ class CircadianSwitch(SwitchEntity, RestoreEntity): def calc_hs(self): return color_xy_to_hs(*self.calc_xy()) - def calc_brightness(self): - if self._disable_brightness_adjust is True: + def calc_brightness(self) -> float: + if self._disable_brightness_adjust: return None if self.is_sleep(): return self._sleep_brightness if self._circadian_lighting._percent > 0: return self._max_brightness delta_brightness = self._max_brightness - self._min_brightness - procent = (100 + self._circadian_lighting._percent) / 100 - return (delta_brightness * procent) + self._min_brightness + percent = (100 + self._circadian_lighting._percent) / 100 + return (delta_brightness * percent) + self._min_brightness @log(logger=_LOGGER) def _update_switch(self, lights=None, transition=None, force=False): @@ -318,9 +318,8 @@ class CircadianSwitch(SwitchEntity, RestoreEntity): continue service_data = {ATTR_ENTITY_ID: light} - brightness = self._brightness - if brightness is not None: - service_data[ATTR_BRIGHTNESS] = int((brightness / 100) * 254) + if self._brightness is not None: + service_data[ATTR_BRIGHTNESS] = int((self._brightness / 100) * 254) if transition is not None: service_data[ATTR_TRANSITION] = transition