mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-28 12:54:22 +02:00
lux_reduction sensor: report reduction %, not retained factor
The 'Lux reduction' sensor published the retained brightness factor, so it read 100% when nothing was being reduced (0% actual reduction) — the label and value were inverses. Now it publishes the actual reduction: 100 - round(factor*100), so 0% = no dimming, higher = more cut, None when the gate is inactive. Updates the output-sensors spec scenarios to match (71 -> 29, 100 -> 0, adds the gate-inactive None case) and adds a publish-level value test (none existed — the prior scenarios were never enforced in code).
This commit is contained in:
parent
7c565a5f5f
commit
76f04237d7
3 changed files with 43 additions and 16 deletions
|
|
@ -1475,11 +1475,12 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity):
|
|||
if current_lux is not None and self._target_lux > 0:
|
||||
ambient_lux: float | None = current_lux
|
||||
if current_lux > self._target_lux:
|
||||
lux_reduction = round(
|
||||
min(self._target_lux / current_lux, 1.0) * 100,
|
||||
)
|
||||
factor = min(self._target_lux / current_lux, 1.0)
|
||||
# Report the *reduction*, not the retained factor: 0 % means
|
||||
# no dimming (curve passes through), 100 % means fully cut.
|
||||
lux_reduction = 100 - round(factor * 100)
|
||||
else:
|
||||
lux_reduction = 100
|
||||
lux_reduction = 0
|
||||
else:
|
||||
ambient_lux = current_lux
|
||||
lux_reduction = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue