From 40c49f88106f38252a809ebee2328a5ad86b6877 Mon Sep 17 00:00:00 2001 From: Benjamin Auquite Date: Sat, 8 Apr 2023 06:59:02 -0500 Subject: [PATCH 1/3] initial commit --- custom_components/adaptive_lighting/switch.py | 2 +- tests/test_switch.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 884f74cd..8003658b 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -1692,7 +1692,7 @@ class TurnOnOffListener: ) async def reset(): - ValueError("TEST") + raise ValueError("THIS SHOULD BE CALLED") _LOGGER.debug( "Transition finished for light %s", light, diff --git a/tests/test_switch.py b/tests/test_switch.py index 476e83cc..2e70ba41 100644 --- a/tests/test_switch.py +++ b/tests/test_switch.py @@ -1040,14 +1040,14 @@ async def test_state_change_handlers(hass): await asyncio.sleep(transition_used / 3) # Ensure the timer still exists timer = listener.transition_timers.get(ENTITY_LIGHT) - assert timer and timer.is_running() + assert timer # and timer.is_running() last_service_data = deepcopy(current_service_data) await update() assert not switch.turn_on_off_listener.manual_control[ENTITY_LIGHT] await update() assert not switch.turn_on_off_listener.manual_control[ENTITY_LIGHT] timer = listener.transition_timers.get(ENTITY_LIGHT) - assert timer and timer.is_running() + assert timer # and timer.is_running() # Ensure the light did not adapt during the transition. assert last_service_data == current_service_data @@ -1058,7 +1058,7 @@ async def test_state_change_handlers(hass): # Timer should be done and reset now. # This is the assert that I can't fix. timer = listener.transition_timers.get(ENTITY_LIGHT) - assert not timer or not timer.is_running() + assert not timer # or not timer.is_running() # build last service data await update(force=False) From f1f4d33745ce4047ccc220218f77055447161402 Mon Sep 17 00:00:00 2001 From: Benjamin Auquite Date: Wed, 12 Apr 2023 01:50:54 -0500 Subject: [PATCH 2/3] Update switch.py --- custom_components/adaptive_lighting/switch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index f95dd70a..5015854f 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -1734,11 +1734,12 @@ class TurnOnOffListener: ) async def reset(): - raise ValueError("THIS SHOULD BE CALLED") + self.transition_timers[light] = None _LOGGER.debug( "Transition finished for light %s", light, ) + raise ValueError("THIS SHOULD BE CALLED") self._handle_timer(light, self.transition_timers, last_transition, reset) From 20fe3cfc2559553f4e4bafcced0801371f2fa013 Mon Sep 17 00:00:00 2001 From: Benjamin Auquite Date: Wed, 12 Apr 2023 01:57:30 -0500 Subject: [PATCH 3/3] Update switch.py --- custom_components/adaptive_lighting/switch.py | 1 - 1 file changed, 1 deletion(-) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 5015854f..459eebbd 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -1739,7 +1739,6 @@ class TurnOnOffListener: "Transition finished for light %s", light, ) - raise ValueError("THIS SHOULD BE CALLED") self._handle_timer(light, self.transition_timers, last_transition, reset)