mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-16 00:34:04 +02:00
fix: restore original order of checks in just_turned_off
The previous commit incorrectly moved the _off_to_on_state_event_is_from_turn_on check to before the context ID match check, which broke test_separate_turn_on_commands. The original order must be: 1. Check on_to_off_event is None → return False 2. Check context IDs match → return True (polling artifact) 3. Get transition info 4. Check _off_to_on_state_event_is_from_turn_on → return False This commit restores that order while keeping the light group detection logic in _off_to_on_state_event_is_from_turn_on.
This commit is contained in:
parent
bf0478fe0c
commit
5789aa1ef1
1 changed files with 13 additions and 15 deletions
|
|
@ -2781,21 +2781,6 @@ class AdaptiveLightingManager:
|
|||
)
|
||||
return False
|
||||
|
||||
# Check if the off→on state change was triggered by a light.turn_on call.
|
||||
# This check now also handles light groups: if a member light was turned on
|
||||
# after the group turned off, the group's turn-on is considered valid.
|
||||
# See: https://github.com/basnijholt/adaptive-lighting/issues/1378
|
||||
if self._off_to_on_state_event_is_from_turn_on(entity_id, off_to_on_event):
|
||||
is_toggle = off_to_on_event == self.toggle_event.get(entity_id)
|
||||
from_service = "light.toggle" if is_toggle else "light.turn_on"
|
||||
_LOGGER.debug(
|
||||
"just_turned_off: State change 'off' → 'on' triggered by '%s'",
|
||||
from_service,
|
||||
)
|
||||
return False
|
||||
|
||||
# If context IDs match but no turn_on event was found, this is likely a polling
|
||||
# artifact (HA briefly seeing the light as ON during a turn_off transition).
|
||||
if off_to_on_event.context.id == on_to_off_event.context.id:
|
||||
_LOGGER.debug(
|
||||
"just_turned_off: 'on' → 'off' state change has the same context.id as the"
|
||||
|
|
@ -2812,6 +2797,19 @@ class AdaptiveLightingManager:
|
|||
else:
|
||||
transition = None
|
||||
|
||||
# Check if the off→on state change was triggered by a light.turn_on call.
|
||||
# This check now also handles light groups: if a member light was turned on
|
||||
# after the group turned off, the group's turn-on is considered valid.
|
||||
# See: https://github.com/basnijholt/adaptive-lighting/issues/1378
|
||||
if self._off_to_on_state_event_is_from_turn_on(entity_id, off_to_on_event):
|
||||
is_toggle = off_to_on_event == self.toggle_event.get(entity_id)
|
||||
from_service = "light.toggle" if is_toggle else "light.turn_on"
|
||||
_LOGGER.debug(
|
||||
"just_turned_off: State change 'off' → 'on' triggered by '%s'",
|
||||
from_service,
|
||||
)
|
||||
return False
|
||||
|
||||
if (
|
||||
turn_off_event is not None
|
||||
and id_on_to_off == turn_off_event.context.id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue