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: idle unknown notification variables #6980

Merged
merged 1 commit into from
Jul 5, 2024
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
25 changes: 24 additions & 1 deletion packages/zwave-js/src/lib/node/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5041,7 +5041,7 @@ protocol version: ${this.protocolVersion}`;
);

if (notificationConfig) {
// This is a known notification (status or event)
// This is a notification (status or event) with a known type
const notificationName = notificationConfig.name;

this.driver.controllerLog.logNode(this.id, {
Expand All @@ -5059,6 +5059,27 @@ protocol version: ${this.protocolVersion}`;
);
};

const setUnknownStateIdle = (prevValue?: number) => {
// Find the value for the unknown notification variable bucket
const unknownNotificationVariableValueId = NotificationCCValues
.unknownNotificationVariable(
command.notificationType!,
notificationName,
).endpoint(command.endpointIndex);
const currentValue = this.valueDB.getValue(
unknownNotificationVariableValueId,
);
// ... and if it exists
if (currentValue == undefined) return;
// ... reset it to idle
if (prevValue == undefined || currentValue === prevValue) {
this.valueDB.setValue(
unknownNotificationVariableValueId,
0, /* idle */
);
}
};

const value = command.notificationEvent!;
if (value === 0) {
// Generic idle notification, this contains a value to be reset
Expand All @@ -5068,6 +5089,7 @@ protocol version: ${this.protocolVersion}`;
) {
// The target value is the first byte of the event parameters
setStateIdle(command.eventParameters[0]);
setUnknownStateIdle(command.eventParameters[0]);
} else {
// Reset all values to idle
const nonIdleValues = this.valueDB
Expand All @@ -5082,6 +5104,7 @@ protocol version: ${this.protocolVersion}`;
for (const v of nonIdleValues) {
setStateIdle(v.value as number);
}
setUnknownStateIdle();
}
return;
}
Expand Down