Skip to content

Commit e2fe7e1

Browse files
authored
Merge pull request #298 from tim-hellhake/fix-temperature-unit
Fix temperature unit
2 parents b25c816 + 9e0fd68 commit e2fe7e1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/zigbee2mqtt/zigbee2mqtt-device.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
WRITE_BIT,
2020
parseType,
2121
isReadable,
22+
parseUnit,
2223
} from './zigbee2mqtt-property';
2324
import mqtt from 'mqtt';
2425
import DEBUG_FLAG from '../zb-debug';
@@ -319,7 +320,7 @@ export class Zigbee2MqttDevice extends Device {
319320
description: expose.description,
320321
input: {
321322
type: parseType(expose),
322-
unit: expose.unit,
323+
unit: parseUnit(expose.unit),
323324
enum: expose.values,
324325
minimum: expose.value_min,
325326
maximum: expose.value_max,

src/zigbee2mqtt/zigbee2mqtt-property.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ export function parseType(expose: Expos): PropertyValueType {
4343
return 'string';
4444
}
4545

46+
export function parseUnit(unit?: string): string | undefined {
47+
switch (unit) {
48+
case '°C':
49+
return 'degree celsius';
50+
}
51+
52+
return unit;
53+
}
54+
4655
function isWritable(access: number): boolean {
4756
return (access & WRITE_BIT) != 0;
4857
}
@@ -64,7 +73,7 @@ export class Zigbee2MqttProperty<T extends PropertyValue> extends Property<T> {
6473
title: expose.name,
6574
description: expose.description,
6675
type: parseType(expose),
67-
unit: expose.unit,
76+
unit: parseUnit(expose.unit),
6877
enum: expose.values,
6978
minimum: expose.value_min,
7079
maximum: expose.value_max,

0 commit comments

Comments
 (0)