Skip to content

Commit 9dc2aa1

Browse files
committed
Use the Matter Auto fallback when SetTarget omits speed
1 parent 061f7f0 commit 9dc2aa1

4 files changed

Lines changed: 9 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ If you like this project and find it useful, please consider giving it a star on
3434
### Added
3535

3636
- [closureControl]: Refactor `MoveTo` target-state fallbacks and set the main state to `Stopped` when the closure is already at the requested target, or `Moving` otherwise.
37+
- [closureDimension]: Use the Matter `Auto` fallback when `SetTarget` omits speed.
3738

3839
### Changed
3940

docs/CHANGELOG.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ <h2 id="3105-dev-branch">[3.10.5] - Dev branch</h2>
155155
<h3 id="added">Added</h3>
156156
<ul>
157157
<li>[closureControl]: Refactor <code>MoveTo</code> target-state fallbacks and set the main state to <code>Stopped</code> when the closure is already at the requested target, or <code>Moving</code> otherwise.</li>
158+
<li>[closureDimension]: Use the Matter <code>Auto</code> fallback when <code>SetTarget</code> omits speed.</li>
158159
</ul>
159160
<h3 id="changed">Changed</h3>
160161
<ul>

packages/core/src/devices/closurePanel.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ export class MatterbridgeClosureDimensionServer extends ClosureDimensionServer.w
6161
...previousTarget,
6262
...(request?.position !== undefined ? { position: request.position } : null),
6363
...(request?.latch !== undefined ? { latch: request.latch } : null),
64-
speed: request?.speed ?? previousTarget.speed ?? ThreeLevelAuto.Auto,
64+
speed: request?.speed ?? ThreeLevelAuto.Auto,
6565
};
66-
6766
this.state.targetState = nextTarget;
6867
};
6968

packages/core/vitest/devices/closurePanel.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ describe('Matterbridge ' + NAME, () => {
8585
await device.invokeBehaviorCommand('closureDimension', 'ClosureDimension.setTarget', { position: 5000 });
8686
expect(device.getAttribute(ClosureDimension.id, 'targetState')).toMatchObject({ position: 5000 });
8787

88-
// Exercise latch/speed optional fields.
89-
await device.invokeBehaviorCommand('closureDimension', 'ClosureDimension.setTarget', { latch: true, speed: 2 });
88+
await device.invokeBehaviorCommand('closureDimension', 'ClosureDimension.setTarget', { latch: true, speed: ThreeLevelAuto.Medium });
89+
expect(device.getAttribute(ClosureDimension.id, 'targetState')).toMatchObject({ speed: ThreeLevelAuto.Medium });
90+
91+
// An omitted position retains its previous target, while an omitted speed falls back to Auto.
92+
await device.invokeBehaviorCommand('closureDimension', 'ClosureDimension.setTarget', { latch: true });
93+
expect(device.getAttribute(ClosureDimension.id, 'targetState')).toEqual({ position: 5000, latch: true, speed: ThreeLevelAuto.Auto });
9094

9195
await device.invokeBehaviorCommand('closureDimension', 'ClosureDimension.step', {
9296
direction: ClosureDimension.StepDirection.Increase,

0 commit comments

Comments
 (0)