Skip to content

Commit 2b1c082

Browse files
authored
Add min schema for new event + missing state changes (#1028)
* Add min schema for new event * Add missed state dump changes too
1 parent 75144c0 commit 2b1c082

2 files changed

Lines changed: 28 additions & 11 deletions

File tree

src/lib/forward.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,14 @@ export class EventForwarder {
147147
);
148148

149149
this.clientsController.driver.controller.on("status changed", (status) =>
150-
this.forwardEvent({
151-
source: "controller",
152-
event: "status changed",
153-
status,
154-
}),
150+
this.forwardEvent(
151+
{
152+
source: "controller",
153+
event: "status changed",
154+
status,
155+
},
156+
31,
157+
),
155158
);
156159

157160
this.clientsController.driver.controller.on("heal network done", (result) =>

src/lib/state.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
TranslatedValueID,
77
ValueMetadata,
88
DeviceClass,
9+
Duration,
910
CommandClass,
1011
InterviewStage,
1112
ZWaveLibraryTypes,
@@ -312,12 +313,17 @@ interface NodeStateSchema14 extends NodeStateSchema10 {
312313
keepAwake: boolean;
313314
}
314315

315-
type NodeStateSchema15 = Omit<NodeStateSchema14, "commandClasses">;
316+
type NodeStateSchema29 = Omit<NodeStateSchema14, "commandClasses">;
316317

317-
interface NodeStateSchema30 extends NodeStateSchema15 {
318+
interface NodeStateSchema30 extends NodeStateSchema29 {
318319
lastSeen: MaybeNotKnown<Date>;
319320
}
320321

322+
interface NodeStateSchema31 extends NodeStateSchema30 {
323+
defaultVolume?: number;
324+
defaultTransitionDuration?: string;
325+
}
326+
321327
export type NodeState =
322328
| NodeStateSchema0
323329
| NodeStateSchema1
@@ -327,8 +333,9 @@ export type NodeState =
327333
| NodeStateSchema7
328334
| NodeStateSchema10
329335
| NodeStateSchema14
330-
| NodeStateSchema15
331-
| NodeStateSchema30;
336+
| NodeStateSchema29
337+
| NodeStateSchema30
338+
| NodeStateSchema31;
332339

333340
interface FoundNodeStateSchema19 {
334341
nodeId: number;
@@ -643,12 +650,19 @@ export const dumpNode = (node: ZWaveNode, schemaVersion: number): NodeState => {
643650
}
644651

645652
if (schemaVersion <= 29) {
646-
return node14 as NodeStateSchema15;
653+
return node14 as NodeStateSchema29;
647654
}
648655

649656
const node30 = node14 as Partial<NodeStateSchema30>;
650657
node30.lastSeen = node.lastSeen;
651-
return node30 as NodeStateSchema30;
658+
if (schemaVersion <= 30) {
659+
return node30 as NodeStateSchema30;
660+
}
661+
662+
const node31 = node30 as NodeStateSchema31;
663+
node31.defaultVolume = node.defaultVolume;
664+
node31.defaultTransitionDuration = node.defaultTransitionDuration;
665+
return node31;
652666
};
653667

654668
export const dumpFoundNode = (

0 commit comments

Comments
 (0)