Skip to content

Commit

Permalink
fix: set key property for meter and sensor scales correctly (#7031)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Jul 19, 2024
1 parent 5db04cf commit 936dec0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions packages/cc/src/cc/HumidityControlSetpointCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ZWaveError,
ZWaveErrorCodes,
encodeFloatWithScale,
getNamedScaleGroup,
getNamedScale,
getUnknownScale,
parseBitMask,
parseFloatWithScale,
Expand Down Expand Up @@ -103,9 +103,8 @@ export const HumidityControlSetpointCCValues = Object.freeze({
}),
});

const humidityScale = getNamedScaleGroup("humidity");
function getScale(scale: number): Scale {
return (humidityScale as any)[scale] ?? getUnknownScale(scale);
return getNamedScale("humidity", scale as any) ?? getUnknownScale(scale);
}
function getSetpointUnit(scale: number): string {
return getScale(scale).unit ?? "";
Expand Down
6 changes: 3 additions & 3 deletions packages/cc/src/cc/ThermostatSetpointCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ZWaveErrorCodes,
encodeBitMask,
encodeFloatWithScale,
getNamedScaleGroup,
getNamedScale,
getUnknownScale,
parseBitMask,
parseFloatWithScale,
Expand Down Expand Up @@ -73,9 +73,9 @@ const thermostatSetpointTypeMap = [
0x0f,
];

const temperatureScale = getNamedScaleGroup("temperature");
function getScale(scale: number): Scale {
return (temperatureScale as any)[scale] ?? getUnknownScale(scale);
return getNamedScale("temperature", scale as any)
?? getUnknownScale(scale);
}
function getSetpointUnit(scale: number): string {
return getScale(scale).unit ?? "";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/registries/Meters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function getMeterScale<
if (!scaleDef) return;

return {
key: type,
key: scale,
...scaleDef,
} satisfies MeterScale as any;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/registries/Sensors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ export function getSensorScale<
if (!scaleDef) return;

return {
key: type,
key: scale,
...scaleDef,
} satisfies Scale as any;
}
Expand Down

0 comments on commit 936dec0

Please sign in to comment.