Skip to content

Commit

Permalink
fix(config): actually load unit from device config files (#1872)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Feb 23, 2021
1 parent 6f3389c commit 6369f30
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/config/src/Devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions packages/zwave-js/src/lib/commandclass/ConfigurationCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export interface ConfigurationMetadata extends ValueMetadataAny {
min?: ConfigValue;
max?: ConfigValue;
default?: ConfigValue;
unit?: string;
valueSize?: number;
format?: ValueFormat;
name?: string;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 6369f30

Please sign in to comment.