Repository navigation
Conversation
- ColorControlServer defaults colorLoopDirection to Decrement, the old model default and the CHIP SDK default. - Transitions starts a cyclic transition without a target at its min or max, so MoveHue, EnhancedMoveHue and the color loop start at hue 0 moving down or at the highest hue moving up. - The cyclic range includes both min and max: addValueWithOverflow, the default calculateCyclicDistance, the hue distances and the rounded state value no longer skip a value at the wrap. ColorControlServer uses the Transitions default distance instead of its own copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tick the box to add this pull request to the merge queue (same as
|
There was a problem hiding this comment.
🟡 Changes recommended
An upward hue transition from 254 to 0 can finish halfway through its requested duration due to rounding, requiring a completion-condition fix and a slow boundary-transition regression test.
1 open issue
What changed in this PR
This PR corrects hue movement in ColorControlServer and aligns shared cyclic arithmetic with inclusive minimum and maximum values.
Changes:
- Default new color loops to Decrement while preserving stored direction values.
- Allow cyclic movement to start at bounds and wrap without skipping hue values.
- Add regression tests and changelog entries for the corrected behavior.
Build, lint, formatting checks, and tests were not run in this review environment.
| File | Description |
|---|---|
packages/node/test/behaviors/color-control/ColorControlServerTest.ts |
Tests direction defaults, wrap paths, and movement from bounds. |
packages/node/test/behavior/cluster/ClusterBehaviorFeaturesTest.ts |
Updates the expected color-loop direction default. |
packages/node/src/behaviors/color-control/ColorControlServer.ts |
Corrects direction defaults and inclusive hue distances. |
packages/node/src/behavior/Transitions.ts |
Updates cyclic distance, boundary starts, and rounded-state wrapping. |
packages/general/test/util/NumberTest.ts |
Tests inclusive wrapping, offset ranges, and multiple cycles. |
packages/general/src/util/Number.ts |
Implements inclusive cyclic addition using modulo arithmetic. |
CHANGELOG.md |
Documents color-control and public numeric utility fixes. |
Review effort: Balanced
- The first step applies one step interval, not two, so a transition no longer ends one step early. - The timer step ends a transition when the value reaches the target, with half a millisecond of change as tolerance for rounding errors, and only after the step's final value is committed. - The $Changed observer ends a transition only for values the timer did not publish, so a rounded value equal to the target no longer ends a transition early; hardware updates still end it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Transitions can report completion before committed state reaches the target, while persistent cached values can suppress external feedback and prevent transitions from finishing.
2 open issues
1 resolved since last review
Review effort: Balanced
| if (this.#propertyStates[state.name] === state) { | ||
| this.finish(state.name); | ||
| } |
|
|
||
| if (newValue === targetValue) { | ||
| // A value the timer published is rounded, so only the timer step ends its own transition | ||
| if (newValue === targetValue && newValue !== this.#publishedValues.get(name)) { |

Three defects in how
ColorControlServermoves the hue.colorLoopDirectiondefaults to Increment. Matter 1.4.2 removed the default from the specification, and the server took over the old model defaults as its own State values. For this attribute it took Increment, but the old model default was 0, which is Decrement. The CHIP SDK all-clusters app also uses 0x00. The attribute is nonvolatile, so devices that already stored a value keep it; only new nodes start with Decrement.Transitions.startreturned without starting when a property sat atminmoving down or atmaxmoving up. For the cyclic hue properties this is wrong: MoveHue, EnhancedMoveHue and the color loop run until stopped and wrap around ("If the hue reaches the minimum allowed for the device, then wraparound and proceed from its maximum allowed value"). With the Decrement default, the first color loop of a new device starting at hue 0 did not move at all.Transitionsruns with its timer ended one step (100 ms) before the requested time, because the first step already applied two step intervals of change. It also ended as soon as the published, rounded value equaled the target, so a move by one unit, such as MoveToHue from 254 up to 0, ended after half its time.addValueWithOverflowand the hue distance calculations treatedminandmaxas one value, so a cycle had 254 steps for the 255 hue values 0 to 254. Going down from 0 gave 253 instead of 254. The specification continues from the maximum, somaxandminare neighbors, not the same value.Fix
The cyclic range now includes both
minandmaxeverywhere:addValueWithOverflow, the defaultTransitions.calculateCyclicDistanceand the Down, Shortest and Longest distances inColorControlServer. A cyclic value between steps is fractional and can lie betweenmaxandmax + 1, so the rounded value that goes into state is wrapped too.ColorControlServerpassed its owncalculateCyclicDistancefor MoveToHue and StepHue, which computed the same distance as theTransitionsdefault because the sign of the rate is the chosen direction. It now uses the default, so the range rule exists once inTransitionsand once in the hue distance that chooses the direction.The timer now ends a transition the way the CHIP SDK does, on time instead of on the rounded value: the first step applies one step interval, and the step ends the transition when the value reaches the target. Less than half a millisecond of change left counts as reached, because adding up the steps leaves rounding errors. The end is reported after the step that wrote the final value has committed, so a client never sees a remaining time of zero before the final value. A
$Changedevent still ends a transition when its value is the target and the timer did not publish it, which keeps the integration where hardware updates the state. A report at a full second now carries the value of the step before it, 100 ms older than the report time.addValueWithOverflowis exported from@matter/general, and its result changes for every input that wraps (8 + 5 in 0..10 gives 2 instead of 3). No caller outsideTransitionsandColorControlServerexists in the repository. The change is listed as a fix because the old result contradicted the specification's wrap rule.A StepHue with a StepSize of 255 is a full turn and now ends at the start hue without a transition. Before, it moved by one. Both differ from a full turn over the transition time; this case is left as is.
🤖 Generated with Claude Code