Skip to content

CTRange: recompute the warm/cool split for the new range - #2231

Merged
openshwprojects merged 1 commit into
openshwprojects:mainfrom
ryan-ronnander:ctrange-recompute
Sep 16, 2026
Merged

openshwprojects merged 1 commit into
openshwprojects:mainfrom
ryan-ronnander:ctrange-recompute

Conversation

@ryan-ronnander

Copy link
Copy Markdown
Contributor

I wanted these bulbs to keep their last color temperature and come on at full when the power is physically turned on at the light switch. That means flag 12 plus a startup command of backlog CTRange 154 370; led_dimmer 100; led_enableAll 1. These are four-PWM style bulbs without dedicated cool LEDs, so flag 24 (LED_EMULATE_COOL_WITH_RGB) synthesises cool white from the color channels. Instead they came back at the wrong temperature with the RGB and warm LEDs both lit, where at 2700 K the warm LED should be carrying it alone, pulling ~14 W instead of ~9 W at the wall.

CTRange updates min/max but never recomputes the warm/cool split derived from the old range.

Before

CTRange 154 500        ->  {"1":0, "2":0, "3":0, "5":100}
led_temperature 370    ->  {"1":60,"2":60,"3":60,"5":100}   split computed against 154-500
CTRange 154 370        ->  {"1":60,"2":60,"3":60,"5":100}   <- range changed, split did not
led_temperature 370    ->  {"1":0, "2":0, "3":0, "5":100}   same value, now correct

After

CTRange 154 500        ->  {"1":60,"2":60,"3":60,"5":100}   recomputed for the new range
led_temperature 370    ->  {"1":60,"2":60,"3":60,"5":100}
CTRange 154 370        ->  {"1":0, "2":0, "3":0, "5":100}   recomputed again, no re-issue needed

This happens on every boot when CTRange is in a startup command, since the saved temperature is restored before CTRange runs.

Nothing here is specific to emulated cool white - any device whose range changes after a temperature is set gets the stale split. It is just very noticeable on these four-PWM bulbs, where a wrong cool value lights the color LEDs outright.

bApply is false because true also forces Light_Temperature. I tried that first and a bulb showing red jumped straight to warm white on the next CTRange, so the apply only runs when we are already in temperature mode.

@openshwprojects
openshwprojects merged commit c21bbac into openshwprojects:main Sep 16, 2026
67 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.18.313 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants