Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): actually load unit from device config files #1872

Merged
merged 2 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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