Skip to content

Commit

Permalink
Add missing node commands (#468)
Browse files Browse the repository at this point in the history
* Add missing node commands

* remove is_controller_node command
  • Loading branch information
raman325 committed Dec 22, 2021
1 parent 48df12f commit 4a0e7ef
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 3 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,24 @@ interface {
}
```

#### [Get value](https://zwave-js.github.io/node-zwave-js/#/api/node?id=getvalue)

[compatible with schema version: 14+]

```ts
interface {
messageId: string;
command: "node.get_value";
nodeId: number;
valueId: {
commandClass: CommandClasses;
endpoint?: number;
property: string | number;
propertyKey?: string | number;
};
}
```

#### [Begin Firmware Update](https://zwave-js.github.io/node-zwave-js/#/api/node?id=beginfirmwareupdate)

[compatible with schema version: 5+]
Expand Down Expand Up @@ -458,6 +476,19 @@ interface {
}
```

#### [Interview command class](https://zwave-js.github.io/node-zwave-js/#/api/node?id=interviewcc)

[compatible with schema version: 14+]

```ts
interface {
messageId: string;
nodeId: number;
command: "node.interview_cc";
commandClass: CommandClasses;
}
```

#### [Refresh command class values](https://zwave-js.github.io/node-zwave-js/#/api/node?id=refreshccvalues)

[compatible with schema version: 4+]
Expand Down Expand Up @@ -556,6 +587,18 @@ interface {
}
```

#### [Get endpoint count](https://zwave-js.github.io/node-zwave-js/#/api/node?id=getendpointcount)

[compatible with schema version: 14+]

```ts
interface {
messageId: string;
nodeId: number;
command: "node.get_endpoint_count";
}
```

### Endpoint level commands

#### [Invoke a Command Classes API method](https://zwave-js.github.io/node-zwave-js/#/api/endpoint?id=invokeccapi)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export const version = require("../../package.json").version;
export const minSchemaVersion = 0;

// maximal/current schema version the server supports
export const maxSchemaVersion = 13;
export const maxSchemaVersion = 14;
3 changes: 3 additions & 0 deletions src/lib/node/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ export enum NodeCommand {
testPowerlevel = "node.test_powerlevel",
checkLifelineHealth = "node.check_lifeline_health",
checkRouteHealth = "node.check_route_health",
getValue = "node.get_value",
getEndpointCount = "node.get_endpoint_count",
interviewCC = "node.interview_cc",
}
20 changes: 19 additions & 1 deletion src/lib/node/incoming_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ export interface IncomingCommandCheckRouteHealth
rounds?: number;
}

export interface IncomingCommandGetValue extends IncomingCommandNodeBase {
command: NodeCommand.getValue;
valueId: ValueID;
}

export interface IncomingCommandGetEndpointCount
extends IncomingCommandNodeBase {
command: NodeCommand.getEndpointCount;
}

export interface IncomingCommandInterviewCC extends IncomingCommandNodeBase {
command: NodeCommand.interviewCC;
commandClass: CommandClasses;
}

export type IncomingMessageNode =
| IncomingCommandNodeSetValue
| IncomingCommandNodeRefreshInfo
Expand All @@ -135,4 +150,7 @@ export type IncomingMessageNode =
| IncomingCommandGetHighestSecurityClass
| IncomingCommandTestPowerlevel
| IncomingCommandCheckLifelineHealth
| IncomingCommandCheckRouteHealth;
| IncomingCommandCheckRouteHealth
| IncomingCommandGetValue
| IncomingCommandGetEndpointCount
| IncomingCommandInterviewCC;
12 changes: 11 additions & 1 deletion src/lib/node/message_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class NodeMessageHandler {
client: Client
): Promise<NodeResultTypes[NodeCommand]> {
const { nodeId, command } = message;
let value: any;
let firmwareFile: Buffer;
let actualFirmware: Firmware;
let summary: LifelineHealthCheckSummary | RouteHealthCheckSummary;
Expand Down Expand Up @@ -78,7 +79,7 @@ export class NodeMessageHandler {
const capabilities = await node.getFirmwareUpdateCapabilities();
return { capabilities };
case NodeCommand.pollValue:
const value = await node.pollValue<any>(message.valueId);
value = await node.pollValue<any>(message.valueId);
return { value };
case NodeCommand.setRawConfigParameterValue:
await node.commandClasses.Configuration.set(
Expand Down Expand Up @@ -155,6 +156,15 @@ export class NodeMessageHandler {
}
);
return { summary };
case NodeCommand.getValue:
value = node.getValue<any>(message.valueId);
return { value };
case NodeCommand.getEndpointCount:
const count = node.getEndpointCount();
return { count };
case NodeCommand.interviewCC:
node.interviewCC(message.commandClass);
return {};
default:
throw new UnknownCommandError(command);
}
Expand Down
3 changes: 3 additions & 0 deletions src/lib/node/outgoing_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ export interface NodeResultTypes {
[NodeCommand.testPowerlevel]: { framesAcked: number };
[NodeCommand.checkLifelineHealth]: { summary: LifelineHealthCheckSummary };
[NodeCommand.checkRouteHealth]: { summary: RouteHealthCheckSummary };
[NodeCommand.getValue]: { value?: any };
[NodeCommand.getEndpointCount]: { count: number };
[NodeCommand.interviewCC]: Record<string, never>;
}

0 comments on commit 4a0e7ef

Please sign in to comment.