From 88d355561422d1df6f402f0e397a829a05126d1c Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Thu, 27 Aug 2020 23:40:59 +0200 Subject: [PATCH] assign brightness variable --- custom_components/circadian_lighting/switch.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/custom_components/circadian_lighting/switch.py b/custom_components/circadian_lighting/switch.py index e64ce37b..080f14d9 100644 --- a/custom_components/circadian_lighting/switch.py +++ b/custom_components/circadian_lighting/switch.py @@ -326,10 +326,9 @@ class CircadianSwitch(SwitchEntity, RestoreEntity): which = None service_data = {ATTR_ENTITY_ID: light} - if self._attributes["brightness"] is not None: - service_data[ATTR_BRIGHTNESS] = int( - (self._attributes["brightness"] / 100) * 254 - ) + brightness = self._attributes["brightness"] + if brightness is not None: + service_data[ATTR_BRIGHTNESS] = int((brightness / 100) * 254) if transition is not None: service_data[ATTR_TRANSITION] = transition