fix(config_flow): align target_penalty slider max with THRESHOLD_RANGES (#898)#898
Open
jackmcintyre wants to merge 1 commit into
Open
fix(config_flow): align target_penalty slider max with THRESHOLD_RANGES (#898)#898jackmcintyre wants to merge 1 commit into
jackmcintyre wants to merge 1 commit into
Conversation
…ES (#898) The options-flow NumberSelector for target_penalty capped at max=0.100, but THRESHOLD_RANGES (used by the NumberEntity) allows max=0.200. A user who set 0.15 via the number entity would be silently clamped to 0.100 on re-opening the options flow. Const.py comment at line 250 confirms 0.200 is intended ('#885: raised 0.015 -> 0.03 ... the soft lever can at least exceed typical charge prices'). Also adds a parametrized regression test asserting every advanced-schema selector's max matches THRESHOLD_RANGES, so this drift can't recur silently. TDD: failing test (assert 0.1 == 0.2), then fix (max=0.100 -> max=0.200). 3220 pass, coverage 95%.
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.
Summary
The options-flow
NumberSelectorfortarget_penaltycapped atmax=0.100, butTHRESHOLD_RANGES(used by theNumberEntity) allowsmax=0.200. A user who set0.15via the number entity would be silently clamped to0.100on re-opening the options flow.const.py:250comment confirms0.200is intended: "#885: raised 0.015 -> 0.03 ... the soft lever can at least exceed typical charge prices".Changes
config_flow/__init__.py:778:max=0.100→max=0.200(matchesTHRESHOLD_RANGES).TestAdvancedSchemaBoundsasserts every advanced-schema selector'smaxmatchesTHRESHOLD_RANGES, so this drift can't recur silently.Validation
assert 0.1 == 0.2), then fix.uv run ruff checkclean.Note on entity-name drift (out of scope)
Live HA has
number.localshift_target_shortfall_penaltybut the code buildsnumber.localshift_target_penalty(fromCONF_TARGET_PENALTY = "target_penalty"). This is a deployment-drift artifact (the live install was running an older version where the key wastarget_shortfall_penalty), not a code bug. It'll self-resolve when the integration is reloaded with current code. Not changed in this PR.