From 6369f30c4dc9b353552b4d786d451561bfc6cab1 Mon Sep 17 00:00:00 2001 From: AlCalzone Date: Tue, 23 Feb 2021 18:29:15 +0100 Subject: [PATCH] fix(config): actually load unit from device config files (#1872) --- packages/config/src/Devices.ts | 13 +++++++++++++ .../src/lib/commandclass/ConfigurationCC.ts | 2 ++ 2 files changed, 15 insertions(+) diff --git a/packages/config/src/Devices.ts b/packages/config/src/Devices.ts index fd06165b963f..bfdc79f8bef7 100644 --- a/packages/config/src/Devices.ts +++ b/packages/config/src/Devices.ts @@ -636,6 +636,18 @@ Parameter #${parameterNumber} has a non-boolean property unsigned`, } this.unsigned = definition.unsigned === true; + if ( + definition.unit != undefined && + typeof definition.unit !== "string" + ) { + throwInvalidConfig( + "devices", + `packages/config/config/devices/${parent.filename}: +Parameter #${parameterNumber} has a non-string unit`, + ); + } + this.unit = definition.unit; + if (typeof definition.readOnly !== "boolean") { throwInvalidConfig( "devices", @@ -704,6 +716,7 @@ Parameter #${parameterNumber}: options is malformed!`, public readonly maxValue: number; public readonly unsigned?: boolean; public readonly defaultValue: number; + public readonly unit?: string; public readonly readOnly: boolean; public readonly writeOnly: boolean; public readonly allowManualEntry: boolean; diff --git a/packages/zwave-js/src/lib/commandclass/ConfigurationCC.ts b/packages/zwave-js/src/lib/commandclass/ConfigurationCC.ts index baa94338321c..89de3dbf4ab9 100644 --- a/packages/zwave-js/src/lib/commandclass/ConfigurationCC.ts +++ b/packages/zwave-js/src/lib/commandclass/ConfigurationCC.ts @@ -79,6 +79,7 @@ export interface ConfigurationMetadata extends ValueMetadataAny { min?: ConfigValue; max?: ConfigValue; default?: ConfigValue; + unit?: string; valueSize?: number; format?: ValueFormat; name?: string; @@ -803,6 +804,7 @@ alters capabilities: ${!!properties.altersCapabilities}`; min: info.minValue, max: info.maxValue, default: info.defaultValue, + unit: info.unit, format: info.unsigned ? ValueFormat.UnsignedInteger : ValueFormat.SignedInteger,