From a4d0074710e9317c46f36f800fe879af90274220 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Fri, 9 Oct 2020 09:43:37 +0200 Subject: [PATCH] Log all state change events --- custom_components/adaptive_lighting/switch.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index c5b38fcb..f36673e6 100755 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -998,17 +998,19 @@ class TurnOnOffListener: return new_state = event.data.get("new_state") - if ( - new_state is not None - and new_state.state == STATE_ON - and is_our_context(new_state.context) - ): + if new_state is not None and new_state.state == STATE_ON: _LOGGER.debug( "Detected a '%s' 'state_changed' event: '%s' with context.id='%s'", entity_id, new_state.attributes, new_state.context.id, ) + + if ( + new_state is not None + and new_state.state == STATE_ON + and is_our_context(new_state.context) + ): # It is possible to have multiple state change events with the same context. # This can happen because a `turn_on.light(brightness_pct=100, transition=30)` # event leads to an instant state change of