From 876890bd71b0f494b9e63f5a686ac1956e5c02ae Mon Sep 17 00:00:00 2001 From: Dominic Griesel Date: Tue, 23 Feb 2021 18:12:53 +0100 Subject: [PATCH 1/2] fix(config): actually load unit from device config files --- 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..2db2f0979fa3 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 !== "boolean" + ) { + 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, From 2479193d6b312ca657a9d34d63a08c63be9568f8 Mon Sep 17 00:00:00 2001 From: Dominic Griesel Date: Tue, 23 Feb 2021 18:20:53 +0100 Subject: [PATCH 2/2] fix: typo --- packages/config/src/Devices.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config/src/Devices.ts b/packages/config/src/Devices.ts index 2db2f0979fa3..bfdc79f8bef7 100644 --- a/packages/config/src/Devices.ts +++ b/packages/config/src/Devices.ts @@ -638,7 +638,7 @@ Parameter #${parameterNumber} has a non-boolean property unsigned`, if ( definition.unit != undefined && - typeof definition.unit !== "boolean" + typeof definition.unit !== "string" ) { throwInvalidConfig( "devices",