Skip to content

Commit

Permalink
fix: ignore when node reports S0/S2 version 0 when CC support is known (
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Sep 28, 2023
1 parent da38c2d commit 68fde4c
Show file tree
Hide file tree
Showing 2 changed files with 442 additions and 16 deletions.
53 changes: 37 additions & 16 deletions packages/cc/src/cc/VersionCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import {
type MessageOrCCLogEntry,
MessagePriority,
type MessageRecord,
SecurityClass,
ValueMetadata,
ZWaveError,
ZWaveErrorCodes,
ZWaveLibraryTypes,
enumValuesToMetadataStates,
getCCName,
securityClassIsS2,
securityClassOrder,
validatePayload,
} from "@zwave-js/core/safe";
import type { ZWaveApplicationHost, ZWaveHost } from "@zwave-js/host/safe";
Expand Down Expand Up @@ -439,24 +442,42 @@ export class VersionCC extends CommandClass {
} else {
// We were lied to - the NIF said this CC is supported, now the node claims it isn't
// Make sure this is not a critical CC, which must be supported though
switch (cc) {
case CommandClasses.Version:
case CommandClasses["Manufacturer Specific"]:
logMessage = ` claims NOT to support CC ${
CommandClasses[cc]
} (${num2hex(cc)}), but it must. Assuming the ${
this.endpointIndex === 0 ? "node" : "endpoint"
} supports version 1...`;
endpoint.addCC(cc, { version: 1 });
break;

default:
logMessage = ` does NOT support CC ${
CommandClasses[cc]
} (${num2hex(cc)})`;
endpoint.removeCC(cc);

if (
cc === CommandClasses.Version
|| cc === CommandClasses["Manufacturer Specific"]
) {
logMessage = ` claims NOT to support CC ${
CommandClasses[cc]
} (${num2hex(cc)}), but it must. Assuming the ${
this.endpointIndex === 0 ? "node" : "endpoint"
} supports version 1...`;
endpoint.addCC(cc, { version: 1 });
} else if (
(cc === CommandClasses.Security
&& node.hasSecurityClass(SecurityClass.S0_Legacy))
|| (cc === CommandClasses["Security 2"]
&& securityClassOrder.some((sc) =>
securityClassIsS2(sc)
&& node.hasSecurityClass(sc)
))
) {
logMessage = ` claims NOT to support CC ${
CommandClasses[cc]
} (${
num2hex(cc)
}), but it is known to support it. Assuming the ${
this.endpointIndex === 0 ? "node" : "endpoint"
} supports version 1...`;
endpoint.addCC(cc, { version: 1 });
} else {
logMessage = ` does NOT support CC ${
CommandClasses[cc]
} (${num2hex(cc)})`;
endpoint.removeCC(cc);
}
}

applHost.controllerLog.logNode(node.id, {
endpoint: this.endpointIndex,
message: logMessage,
Expand Down
Loading

0 comments on commit 68fde4c

Please sign in to comment.