Repository navigation
fix: drop the stored auto-reset delay when autoreset_control_seconds is 0 - #1635
Open
BrawnyBravo wants to merge 1 commit into
Open
BrawnyBravo wants to merge 1 commit into
BrawnyBravo wants to merge 1 commit into
Conversation
…is 0 set_auto_reset_manual_control_times() returned early for a time of 0, so the delay stored by a previous configuration stayed in the manager. The manager outlives config entry reloads, so after changing the option to 0 lights kept being auto-reset with the old delay until Home Assistant was restarted. Remove the light's stored delay instead, and add a regression test that reloads a profile with the option set to 0 while another profile keeps the manager alive. Fixes basnijholt#1631 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
AdaptiveLightingManager.set_auto_reset_manual_control_times()returned early when the time was0. The manager outlives config entry reloads (as long as another profile stays loaded), so the delay stored by the previous configuration stayed inauto_reset_manual_control_times, andset_manual_control_attributes()kept scheduling the auto-reset timer with it. Changingautoreset_control_secondsto0therefore had no effect until Home Assistant was restarted.The setter now removes the light's stored delay when the time is
0(and still logs the change, e.g. "from 60 seconds to 0 seconds").I did not cancel a running timer in the setter: a reload already cancels the old profile's timers, and the next manual change calls
_handle_timer()withdelay=None, which cancels any leftover timer.Why
With v1.32.0 the auto-reset re-adapts the light immediately (#1506), so a leftover delay is now visible: a manual brightness change gets undone after the old delay even though the option says
0.How tested
test_disabling_autoreset_takes_effect_on_reloadintests/test_switch.py: sets up a profile withautoreset_control_seconds: 60plus a second profile that keeps the manager alive, makes a manual change, updates the options to0(which reloads the entry), then makes another manual change and checks that no delay is stored, no timer is created andautoreset_time_remainingis empty.main({'light.light_1': 60}is still stored) and passes with the fix.Possible behaviour change
When one light is in several profiles and one of them has
autoreset_control_seconds: 0, the last profile to set up now wins for0as well, the same as already happens between two non-zero values. Before, a0profile never overrode a non-zero one.Fixes #1631
🤖 Generated with Claude Code