Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent route health checks to sleeping nodes #4373

Merged
merged 2 commits into from
Mar 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions packages/zwave-js/src/lib/node/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4114,7 +4114,20 @@ ${formatLifelineHealthCheckSummary(summary)}`,
}

const otherNode = this.driver.controller.nodes.getOrThrow(targetNodeId);
if (
if (otherNode.canSleep) {
throw new ZWaveError(
"Nodes which can sleep are not a valid target for a route health check!",
ZWaveErrorCodes.CC_NotSupported,
);
} else if (
this.canSleep &&
!this.supportsCC(CommandClasses.Powerlevel)
) {
throw new ZWaveError(
"Route health checks require that nodes which can sleep support Powerlevel CC!",
ZWaveErrorCodes.CC_NotSupported,
);
} else if (
!this.supportsCC(CommandClasses.Powerlevel) &&
!otherNode.supportsCC(CommandClasses.Powerlevel)
) {
Expand Down Expand Up @@ -4239,8 +4252,11 @@ ${formatLifelineHealthCheckSummary(summary)}`,
}
}

// And do the same with the other node
if (otherNode.supportsCC(CommandClasses.Powerlevel)) {
// And do the same with the other node - unless the current node is a sleeping node, then this doesn't make sense
if (
!this.canSleep &&
otherNode.supportsCC(CommandClasses.Powerlevel)
) {
try {
const powerlevel = await discreteBinarySearch(
Powerlevel["Normal Power"], // minimum reduction
Expand Down