mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-28 04:44:39 +02:00
fix: clamp() collapsed to minimum when min_brightness > max_brightness (#1507)
* fix: clamp() collapsed to minimum when min_brightness > max_brightness A user can intentionally set min_brightness > max_brightness (or the equivalent for color temperature) for an inverted timescale -- e.g. a porch light that should be brighter at night than during the day. clamp()'s max(minimum, min(value, maximum)) assumed minimum <= maximum; when inverted, min(value, maximum) is always <= maximum < minimum, so max(minimum, ...) always returns minimum. linear and tanh brightness modes -- both of which end in a clamp(brightness, min_brightness, max_brightness) call -- got stuck returning one fixed value regardless of the time of day. Fixes #1421 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * test: accept current Home Assistant brightness validation errors Keep asserting the maximum brightness limit without depending on the validation library's dictionary-path wording. --------- Co-authored-by: Oscar Pacheco <proscar@MacBook-Pro-de-Oscar.local> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bas Nijholt <bas@nijho.lt> Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
This commit is contained in:
parent
c620d1480a
commit
67d4a2f657
3 changed files with 101 additions and 3 deletions
|
|
@ -1727,7 +1727,7 @@ async def test_change_switch_settings_service(hass):
|
|||
# Test changing to illegal max brightness
|
||||
with pytest.raises(
|
||||
voluptuous.error.MultipleInvalid,
|
||||
match="value must be at most 100 for dictionary",
|
||||
match="value must be at most 100",
|
||||
):
|
||||
await change_switch_settings(**{CONF_MAX_BRIGHTNESS: 5000})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue