From 39fd8f2be0f3d6bef27705d167b5eab8113d5709 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Mon, 31 Jul 2023 18:37:58 -0700 Subject: [PATCH] Remove check --- custom_components/adaptive_lighting/switch.py | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 0a062fd6..772aa1e0 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -1268,25 +1268,15 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): adapt_color: bool | None = None, prefer_rgb_color: bool | None = None, ) -> None: + # This should never happen if it's been proactively adapted. + # The context.parent_id is the context.id of the service call that was intercepted + # and context.id here is from the resulting "light_event" event. + assert not self.manager.is_proactively_adapting(context.parent_id) + if (lock := self.manager.turn_off_locks.get(light)) and lock.locked(): _LOGGER.debug("%s: '%s' is locked", self._name, light) return - if context.parent_id is not None and self.manager.is_proactively_adapting( - context.parent_id, - ): - # Skip if adaptation was already executed by the service call interceptor. - # The context.parent_id is the context.id of the service call that was intercepted - # and context.id here is from the resulting "light_event" event. - _LOGGER.debug( - "%s: Skipping reactive adaptation of light %s with context.id=%s and context.parent_id=%s", - self._name, - light, - context.id, - context.parent_id, - ) - return - data = await self.prepare_adaptation_data( light, transition,