From 7ef47b19c8b285444dddd0f2ff4878fab02a551c Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Thu, 27 Aug 2020 23:47:28 +0200 Subject: [PATCH] which can never not be set --- custom_components/circadian_lighting/switch.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/custom_components/circadian_lighting/switch.py b/custom_components/circadian_lighting/switch.py index 080f14d9..e3fc2fea 100644 --- a/custom_components/circadian_lighting/switch.py +++ b/custom_components/circadian_lighting/switch.py @@ -324,7 +324,6 @@ class CircadianSwitch(SwitchEntity, RestoreEntity): if not is_on(self.hass, light): continue - which = None service_data = {ATTR_ENTITY_ID: light} brightness = self._attributes["brightness"] if brightness is not None: @@ -353,13 +352,12 @@ class CircadianSwitch(SwitchEntity, RestoreEntity): elif light in self._lights_brightness: which = "Brightness" - if which is not None: - self.hass.services.call(LIGHT_DOMAIN, SERVICE_TURN_ON, service_data) - key_value_strings = [ - f"{k}: {v}" for k, v in service_data.items() if k != ATTR_ENTITY_ID - ] - msg = ", ".join(key_value_strings) - _LOGGER.debug(f"{light} {which} Adjusted - {msg}") + self.hass.services.call(LIGHT_DOMAIN, SERVICE_TURN_ON, service_data) + key_value_strings = [ + f"{k}: {v}" for k, v in service_data.items() if k != ATTR_ENTITY_ID + ] + msg = ", ".join(key_value_strings) + _LOGGER.debug(f"{light} {which} Adjusted - {msg}") def light_state_changed(self, entity_id, from_state, to_state): with suppress(Exception):