Skip to content

Commit

Permalink
fix: treat meta and options separately
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Oct 24, 2023
1 parent 4ebae63 commit 8d951b9
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions packages/zwave-js/src/lib/node/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1034,11 +1034,12 @@ export class ZWaveNode extends Endpoint
let valueOptions: Required<CCValueOptions> | undefined;
let meta: ValueMetadata | undefined;
if (definedCCValues) {
valueDefinition = Object.values(definedCCValues).find((v) =>
v?.is(valueId)
);
if (valueDefinition && typeof valueDefinition !== "function") {
meta = valueDefinition.meta;
valueDefinition = Object.values(definedCCValues)
.find((v) => v?.is(valueId));
if (valueDefinition) {
if (typeof valueDefinition !== "function") {
meta = valueDefinition.meta;
}
valueOptions = valueDefinition.options;
}
}
Expand All @@ -1047,15 +1048,9 @@ export class ZWaveNode extends Endpoint
return {
// The priority for returned metadata is valueDB > defined value > Any (default)
...(existingMetadata ?? meta ?? ValueMetadata.Any),
// For static values, don't allow overriding these flags with dynamic metadata
stateful: (typeof valueDefinition === "function"
? existingMetadata?.stateful
: valueOptions?.stateful)
?? defaultCCValueOptions.stateful,
secret: (typeof valueDefinition === "function"
? existingMetadata?.secret
: valueOptions?.secret)
?? defaultCCValueOptions.secret,
// Don't allow overriding these flags:
stateful: valueOptions?.stateful ?? defaultCCValueOptions.stateful,
secret: valueOptions?.secret ?? defaultCCValueOptions.secret,
};
}

Expand Down

0 comments on commit 8d951b9

Please sign in to comment.