From dee6eed67f20cb7eca892c4fd710e0e88c7a337b Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 30 Aug 2022 10:29:32 -0700 Subject: [PATCH] Take care of the turn_on_event not having registered an event for entity_id --- custom_components/adaptive_lighting/switch.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 5eb29a9a..7f910702 100755 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -1512,6 +1512,11 @@ class TurnOnOffListener: transition = None turn_on_event = self.turn_on_event.get(entity_id) + if turn_on_event is None: + # This means that the light never got a 'turn_on' call that we + # registered. I am not 100% sure why this happens, but it does. + # This is a fix for #170 and #232 + return False id_turn_on = turn_on_event.context.id id_off_to_on = off_to_on_event.context.id