Skip to content

Commit

Permalink
fix: preserve stateful and secret flags for dynamic CC values (#6457
Browse files Browse the repository at this point in the history
)
  • Loading branch information
AlCalzone authored Oct 24, 2023
1 parent fc17adf commit cc02f5b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/zwave-js/src/lib/node/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1031,21 +1031,21 @@ export class ZWaveNode extends Endpoint
let valueOptions: Required<CCValueOptions> | undefined;
let meta: ValueMetadata | undefined;
if (definedCCValues) {
const value = Object.values(definedCCValues).find((v) =>
v?.is(valueId)
);
if (value && typeof value !== "function") {
meta = value.meta;
const value = Object.values(definedCCValues)
.find((v) => v?.is(valueId));
if (value) {
if (typeof value !== "function") {
meta = value.meta;
}
valueOptions = value.options;
}
}

// The priority for returned metadata is valueDB > defined value > Any (default)
const existingMetadata = this._valueDB.getMetadata(valueId);
return {
...(this._valueDB.getMetadata(valueId)
?? meta
?? ValueMetadata.Any),
// Don't allow overriding these flags:
// The priority for returned metadata is valueDB > defined value > Any (default)
...(existingMetadata ?? meta ?? ValueMetadata.Any),
// ...except for these flags, which are taken from defined values:
stateful: valueOptions?.stateful ?? defaultCCValueOptions.stateful,
secret: valueOptions?.secret ?? defaultCCValueOptions.secret,
};
Expand Down

0 comments on commit cc02f5b

Please sign in to comment.