Skip to content

Commit

Permalink
fix: skip Basic CC interview if the device class must not support it
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Jul 8, 2024
1 parent a14af6a commit b770d7c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/cc/src/cc/VersionCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ export class VersionCC extends CommandClass {
direction: "outbound",
});
// Basic CC is not included in the NIF, so it won't be returned by endpoint.getCCs() at this point
{
if (applHost.maySupportBasicCC(node.id)) {
const cc = CommandClasses.Basic;
// Skip the query of endpoint CCs that are also supported by the root device
if (this.endpointIndex === 0 || node.getCCVersion(cc) === 0) {
Expand Down
3 changes: 3 additions & 0 deletions packages/host/src/ZWaveHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export interface ZWaveApplicationHost extends ZWaveHost {
/** Readonly access to all node instances known to the host */
nodes: ReadonlyThrowingMap<number, IZWaveNode>;

/** Whether a node or endpoint may support the Basic CC */
maySupportBasicCC(nodeId: number, endpointIndex?: number): boolean;

/** Whether the node with the given ID is the controller */
isControllerNode(nodeId: number): boolean;

Expand Down
3 changes: 3 additions & 0 deletions packages/host/src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ export function createTestingHost(
schedulePoll: (_nodeId, _valueId, _options) => {
return false;
},
maySupportBasicCC: (_nodeId, _endpointIndex) => {
return true;
},
};
return ret;
}
12 changes: 12 additions & 0 deletions packages/zwave-js/src/lib/driver/Driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,18 @@ export class Driver extends TypedEventEmitter<DriverEventCallbacks>
return this.controller.nodes.get(nodeId)?.deviceConfig;
}

/**
* **!!! INTERNAL !!!**
*
* Not intended to be used by applications
*/
public maySupportBasicCC(nodeId: number, endpointIndex?: number): boolean {
const deviceClass = this.controller.nodes.get(nodeId)?.getEndpoint(
endpointIndex ?? 0,
)?.deviceClass;
return deviceClass?.specific.maySupportBasicCC ?? true;
}

public getHighestSecurityClass(
nodeId: number,
): MaybeNotKnown<SecurityClass> {
Expand Down

0 comments on commit b770d7c

Please sign in to comment.