adaptive-lighting/custom_components
Ahmad Tawakol 51e0b11860 Use the sleep RGB colour as the floor whenever it is configured
A switch with `sleep_rgb_or_color_temp: rgb_color` expresses its sleep colour
as RGB. `_apply_intensity` only walked RGB towards `sleep_rgb_color` on the
`adapt_until_sleep` path; everywhere else it re-derived RGB from the
interpolated colour temperature. Intensity 0 therefore produced
`color_temperature_to_rgb(sleep_color_temp)` rather than the configured
`sleep_rgb_color`, breaking the guarantee that 0 reproduces sleep mode.

The condition is now the switch's own configuration -- the sleep floor being in
force, and the sleep colour being expressed as RGB -- which subsumes the
`adapt_until_sleep` case and makes the `keep_rgb` parameter redundant.

The `minimum` floor still derives RGB from the colour temperature, because its
anchor is `min_color_temp`, a Kelvin, and the sleep colour is not the floor
there.

The existing test asserted the RGB match only when `force_rgb_color` was set,
so it stepped over this. Replaced with a test that asserts what was actually
promised, under both values of `adapt_until_sleep`, plus one pinning the
`minimum` floor's Kelvin-derived behaviour.

Reported by greptile-apps on #1593.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 18:47:10 -03:00
..
adaptive_lighting Use the sleep RGB colour as the floor whenever it is configured 2026-09-07 18:47:10 -03:00