Skip to content

fix(config_flow): align target_penalty slider max with THRESHOLD_RANGES (#898)#898

Open
jackmcintyre wants to merge 1 commit into
mainfrom
issue/898
Open

fix(config_flow): align target_penalty slider max with THRESHOLD_RANGES (#898)#898
jackmcintyre wants to merge 1 commit into
mainfrom
issue/898

Conversation

@jackmcintyre

Copy link
Copy Markdown
Owner

Summary

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:250 comment confirms 0.200 is 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.100max=0.200 (matches THRESHOLD_RANGES).
  • New parametrized regression test TestAdvancedSchemaBounds asserts every advanced-schema selector's max matches THRESHOLD_RANGES, so this drift can't recur silently.

Validation

  • TDD: failing test (assert 0.1 == 0.2), then fix.
  • Full suite: 3220 passed, 1 xfailed. Coverage: 95%.
  • uv run ruff check clean.

Note on entity-name drift (out of scope)

Live HA has number.localshift_target_shortfall_penalty but the code builds number.localshift_target_penalty (from CONF_TARGET_PENALTY = "target_penalty"). This is a deployment-drift artifact (the live install was running an older version where the key was target_shortfall_penalty), not a code bug. It'll self-resolve when the integration is reloaded with current code. Not changed in this PR.

…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%.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant