fix: call detect_bulb() in *_percentage() methods before reading value_max#714
Open
jasonacox-sam wants to merge 1 commit into
Open
Conversation
…thods When set_brightness_percentage(), set_white_percentage(), or set_colourtemp_percentage() is called before bulb detection has run, self.dpset['value_max'] is still -1 (the unconfigured default). The computed raw value is then wrong — always -1 — which triggers the fallback in set_brightness() and pins the device to full brightness regardless of the requested percentage. Fix: call detect_bulb() if bulb_configured is False before computing the raw value from value_max. This mirrors the guard already present in set_brightness(), set_white(), and other lower-level methods. Fixes jasonacox#713
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.
Fixes #713
Problem
When
set_brightness_percentage(),set_white_percentage(), orset_colourtemp_percentage()is called before bulb detection has run,self.dpset['value_max']is still-1(the unconfigured default). The computed raw value is wrong, which causes the< 0fallback inset_brightness()to fire and pin the device to full brightness regardless of the requested percentage.Fix
Add a
if not self.bulb_configured: self.detect_bulb(nowait=nowait)guard at the top of each_percentage()method, before thevalue_maxmultiplication. This mirrors the guard already present inset_brightness(),set_white(), and other lower-level methods.Affected Methods
set_brightness_percentage()set_white_percentage()set_colourtemp_percentage()Testing
Workaround confirmed by @andreidiaconescu18 in #713 — calling
d.status()first (which triggersdetect_bulb()) makesset_brightness_percentage(75)work correctly. This PR makes that detection automatic.— Sam ⚙️