Skip to content

Commit 8c54894

Browse files
authored
feat: support zwave-js v13 (#1236)
1 parent f1eb414 commit 8c54894

9 files changed

+323
-203
lines changed

package-lock.json

+271-189
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"ws": "^8.13.0"
3535
},
3636
"peerDependencies": {
37-
"zwave-js": "^12.11.0"
37+
"zwave-js": "^13.0.0"
3838
},
3939
"devDependencies": {
4040
"@tsconfig/node18": "^18.2.1",
@@ -54,7 +54,7 @@
5454
"semver": "^7.5.4",
5555
"ts-node": "^10.9.2",
5656
"typescript": "^5.3.3",
57-
"zwave-js": "^12.11.0"
57+
"zwave-js": "^13.0.0"
5858
},
5959
"husky": {
6060
"hooks": {

src/lib/const.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const version = require("../../package.json").version;
44
export const minSchemaVersion = 0;
55

66
// maximal/current schema version the server supports
7-
export const maxSchemaVersion = 36;
7+
export const maxSchemaVersion = 37;
88

99
export const applicationName = "zwave-js-server";
1010
export const dnssdServiceType = applicationName;

src/lib/controller/command.ts

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export enum ControllerCommand {
2020
isFailedNode = "controller.is_failed_node",
2121
getAssociationGroups = "controller.get_association_groups",
2222
getAssociations = "controller.get_associations",
23+
checkAssociation = "controller.check_association",
2324
isAssociationAllowed = "controller.is_association_allowed",
2425
addAssociations = "controller.add_associations",
2526
removeAssociations = "controller.remove_associations",

src/lib/controller/incoming_message.ts

+10
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ export interface IncomingCommandControllerGetAssociations
137137
endpoint?: number;
138138
}
139139

140+
export interface IncomingCommandControllerCheckAssociation
141+
extends IncomingCommandControllerBase {
142+
command: ControllerCommand.checkAssociation;
143+
nodeId: number;
144+
group: number;
145+
association: AssociationAddress;
146+
endpoint?: number;
147+
}
148+
140149
export interface IncomingCommandControllerIsAssociationAllowed
141150
extends IncomingCommandControllerBase {
142151
command: ControllerCommand.isAssociationAllowed;
@@ -350,6 +359,7 @@ export type IncomingMessageController =
350359
| IncomingCommandControllerIsFailedNode
351360
| IncomingCommandControllerGetAssociationGroups
352361
| IncomingCommandControllerGetAssociations
362+
| IncomingCommandControllerCheckAssociation
353363
| IncomingCommandControllerIsAssociationAllowed
354364
| IncomingCommandControllerAddAssociations
355365
| IncomingCommandControllerRemoveAssociations

src/lib/controller/message_handler.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
guessFirmwareFileFormat,
1414
ExclusionStrategy,
1515
ExclusionOptions,
16+
AssociationCheckResult,
1617
} from "zwave-js";
1718
import { dumpController } from "..";
1819
import {
@@ -186,13 +187,21 @@ export class ControllerMessageHandler {
186187
.forEach((value, key) => (associations[key] = value));
187188
return { associations };
188189
}
190+
case ControllerCommand.checkAssociation: {
191+
const result = driver.controller.checkAssociation(
192+
{ nodeId: message.nodeId, endpoint: message.endpoint },
193+
message.group,
194+
message.association,
195+
);
196+
return { result };
197+
}
189198
case ControllerCommand.isAssociationAllowed: {
190-
const allowed = driver.controller.isAssociationAllowed(
199+
const result = driver.controller.checkAssociation(
191200
{ nodeId: message.nodeId, endpoint: message.endpoint },
192201
message.group,
193202
message.association,
194203
);
195-
return { allowed };
204+
return { allowed: result === AssociationCheckResult.OK };
196205
}
197206
case ControllerCommand.addAssociations: {
198207
await driver.controller.addAssociations(

src/lib/controller/outgoing_message.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
AssociationAddress,
3+
AssociationCheckResult,
34
AssociationGroup,
45
FirmwareUpdateInfo,
56
LifelineRoutes,
@@ -31,6 +32,7 @@ export interface ControllerResultTypes {
3132
[ControllerCommand.getAssociations]: {
3233
associations: Record<number, readonly AssociationAddress[]>;
3334
};
35+
[ControllerCommand.checkAssociation]: { result: AssociationCheckResult };
3436
[ControllerCommand.isAssociationAllowed]: { allowed: boolean };
3537
[ControllerCommand.addAssociations]: Record<string, never>;
3638
[ControllerCommand.removeAssociations]: Record<string, never>;

src/lib/forward.ts

+21-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
Endpoint,
44
FirmwareUpdateProgress,
55
FirmwareUpdateResult,
6+
InclusionStrategy,
67
NodeStatistics,
78
NodeStatus,
89
RemoveNodeReason,
@@ -84,12 +85,26 @@ export class EventForwarder {
8485
}
8586
}
8687

87-
this.clientsController.driver.controller.on("inclusion started", (secure) =>
88-
this.forwardEvent({
89-
source: "controller",
90-
event: "inclusion started",
91-
secure,
92-
}),
88+
this.clientsController.driver.controller.on(
89+
"inclusion started",
90+
(strategy) => {
91+
// forward event to all connected clients, respecting schemaVersion it supports
92+
this.clientsController.clients.forEach((client) => {
93+
if (client.schemaVersion >= 37) {
94+
this.sendEvent(client, {
95+
source: "controller",
96+
event: "inclusion started",
97+
strategy,
98+
});
99+
} else {
100+
this.sendEvent(client, {
101+
source: "controller",
102+
event: "inclusion started",
103+
secure: strategy !== InclusionStrategy.Insecure,
104+
});
105+
}
106+
});
107+
},
93108
);
94109

95110
this.clientsController.driver.controller.on(

src/lib/state.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ import {
2424
InclusionState,
2525
FoundNode,
2626
RebuildRoutesStatus,
27+
getEnumMemberName,
2728
} from "zwave-js";
2829
import { DeviceConfig } from "@zwave-js/config";
2930
import {
31+
BasicDeviceClass,
3032
CommandClasses,
3133
ConfigurationMetadata,
3234
ConfigValue,
@@ -467,7 +469,6 @@ export const dumpConfigurationMetadata = (
467469
unit: metadata.unit,
468470
valueSize: metadata.valueSize,
469471
format: metadata.format,
470-
noBulkSupport: metadata.noBulkSupport,
471472
isAdvanced: metadata.isAdvanced,
472473
requiresReInclusion: metadata.requiresReInclusion,
473474
allowManualEntry: metadata.allowManualEntry,
@@ -775,8 +776,8 @@ export const dumpDeviceClass = (
775776
): DeviceClassState => {
776777
const base: Partial<DeviceClassState0> = {
777778
basic: {
778-
key: deviceClass.basic.key,
779-
label: deviceClass.basic.label,
779+
key: deviceClass.basic,
780+
label: getEnumMemberName(BasicDeviceClass, deviceClass.basic),
780781
},
781782
generic: {
782783
key: deviceClass.generic.key,

0 commit comments

Comments
 (0)