From cc02f5bd347a6ba26a5f935cf73f8b164a3a893c Mon Sep 17 00:00:00 2001 From: AlCalzone Date: Tue, 24 Oct 2023 11:16:54 +0200 Subject: [PATCH] fix: preserve `stateful` and `secret` flags for dynamic CC values (#6457) --- packages/zwave-js/src/lib/node/Node.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/zwave-js/src/lib/node/Node.ts b/packages/zwave-js/src/lib/node/Node.ts index 6bbbb7163c4c..543c26eccd09 100644 --- a/packages/zwave-js/src/lib/node/Node.ts +++ b/packages/zwave-js/src/lib/node/Node.ts @@ -1031,21 +1031,21 @@ export class ZWaveNode extends Endpoint let valueOptions: Required | 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, };