Skip to content

Commit

Permalink
fix: compatibility with node-zwave-js v14
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Oct 22, 2024
1 parent 348c930 commit 34a90c8
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/lib/endpoint/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum EndpointCommand {
isCCSecure = "endpoint.is_cc_secure",
getCCVersion = "endpoint.get_cc_version",
getNodeUnsafe = "endpoint.get_node_unsafe",
tryGetNode = "endpoint.try_get_node",
setRawConfigParameterValue = "endpoint.set_raw_config_parameter_value",
getRawConfigParameterValue = "endpoint.get_raw_config_parameter_value",
}
6 changes: 6 additions & 0 deletions src/lib/endpoint/incoming_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export interface IncomingCommandEndpointGetNodeUnsafe
command: EndpointCommand.getNodeUnsafe;
}

export interface IncomingCommandEndpointTryGetNode
extends IncomingCommandEndpointBase {
command: EndpointCommand.tryGetNode;
}

export interface IncomingCommandEndpointSetRawConfigParameterValue
extends IncomingCommandEndpointBase {
command: EndpointCommand.setRawConfigParameterValue;
Expand All @@ -75,5 +80,6 @@ export type IncomingMessageEndpoint =
| IncomingCommandEndpointIsCCSecure
| IncomingCommandEndpointGetCCVersion
| IncomingCommandEndpointGetNodeUnsafe
| IncomingCommandEndpointTryGetNode
| IncomingCommandEndpointSetRawConfigParameterValue
| IncomingCommandEndpointGetRawConfigParameterValue;
5 changes: 3 additions & 2 deletions src/lib/endpoint/message_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ export class EndpointMessageHandler implements MessageHandler {
const version = endpoint.getCCVersion(message.commandClass);
return { version };
}
case EndpointCommand.getNodeUnsafe: {
const node = endpoint.getNodeUnsafe();
case EndpointCommand.getNodeUnsafe:
case EndpointCommand.tryGetNode: {
const node = endpoint.tryGetNode();

Check failure on line 97 in src/lib/endpoint/message_handler.ts

View workflow job for this annotation

GitHub Actions / build

Property 'tryGetNode' does not exist on type 'Endpoint'.
return {
node:
node === undefined
Expand Down
1 change: 1 addition & 0 deletions src/lib/endpoint/outgoing_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface EndpointResultTypes {
[EndpointCommand.isCCSecure]: { secure: boolean };
[EndpointCommand.getCCVersion]: { version: number };
[EndpointCommand.getNodeUnsafe]: { node: NodeState | undefined };
[EndpointCommand.tryGetNode]: { node: NodeState | undefined };
[EndpointCommand.setRawConfigParameterValue]: { result?: SupervisionResult };
[EndpointCommand.getRawConfigParameterValue]: {
value: MaybeNotKnown<ConfigValue>;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/forward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export class EventForwarder {
"notification",
(endpoint: Endpoint, ccId: CommandClasses, args: any) => {
// only forward value events for ready nodes
const changedNode = endpoint.getNodeUnsafe();
const changedNode = endpoint.tryGetNode();

Check failure on line 365 in src/lib/forward.ts

View workflow job for this annotation

GitHub Actions / build

Property 'tryGetNode' does not exist on type 'Endpoint'.
if (!changedNode) {
throw new NodeNotFoundError(endpoint.nodeId);
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ export const dumpCommandClass = (
): CommandClassState => ({
id: commandClass.ccId,
name: CommandClasses[commandClass.ccId],
version: commandClass.version,
version: endpoint.getCCVersion(commandClass.ccId),
isSecure: endpoint.isCCSecure(commandClass.ccId),
});

Expand Down

0 comments on commit 34a90c8

Please sign in to comment.