-
Notifications
You must be signed in to change notification settings - Fork 43
/
lywsd03mmc.js
147 lines (143 loc) · 5.1 KB
/
lywsd03mmc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// requires zigbee2mqtt v1.34+
const {
batteryPercentage,
temperature,
humidity,
enumLookup,
binary,
numeric,
quirkAddEndpointCluster,
} = require('zigbee-herdsman-converters/lib/modernExtend');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const ota = require('zigbee-herdsman-converters/lib/ota');
const dataType = {
boolean: 0x10,
uint8: 0x20,
uint16: 0x21,
int8: 0x28,
int16: 0x29,
enum8: 0x30,
};
const definition = {
zigbeeModel: ['LYWSD03MMC'],
model: 'LYWSD03MMC',
vendor: 'Xiaomi',
description: 'Temperature & humidity sensor with custom firmware',
extend: [
quirkAddEndpointCluster({
endpointID: 1,
outputClusters: [],
inputClusters: [
'genPowerCfg',
'msTemperatureMeasurement',
'msRelativeHumidity',
'hvacUserInterfaceCfg',
],
}),
batteryPercentage(),
temperature({reporting: {min: 10, max: 300, change: 10}, access: 'STATE'}),
humidity({reporting: {min: 10, max: 300, change: 50}, access: 'STATE'}),
enumLookup({
name: 'temperature_display_mode',
lookup: {'celsius': 0, 'fahrenheit': 1},
cluster: 'hvacUserInterfaceCfg',
attribute: 'tempDisplayMode',
description: 'The units of the temperature displayed on the device screen.',
}),
binary({
name: 'show_smiley',
valueOn: ['SHOW', 1],
valueOff: ['HIDE', 0],
cluster: 'hvacUserInterfaceCfg',
attribute: {ID: 0x0010, type: dataType.boolean},
description: 'Whether to show a smiley on the device screen.',
}),
binary({
name: 'enable_display',
valueOn: ['ON', 1],
valueOff: ['OFF', 0],
cluster: 'hvacUserInterfaceCfg',
attribute: {ID: 0x0011, type: dataType.boolean},
description: 'Whether to turn display on/off.',
}),
numeric({
name: 'temperature_calibration',
unit: 'ºC',
cluster: 'msTemperatureMeasurement',
attribute: {ID: 0x0010, type: dataType.int16},
valueMin: -100.0,
valueMax: 100.0,
valueStep: 0.01,
scale: 100,
description: 'The temperature calibration, in 0.01° steps.',
}),
numeric({
name: 'humidity_calibration',
unit: '%',
cluster: 'msRelativeHumidity',
attribute: {ID: 0x0010, type: dataType.int16},
valueMin: -100.0,
valueMax: 100.0,
valueStep: 0.01,
scale: 100,
description: 'The humidity offset is set in 0.01 % steps.',
}),
numeric({
name: 'comfort_temperature_min',
unit: 'ºC',
cluster: 'hvacUserInterfaceCfg',
attribute: {ID: 0x0102, type: dataType.int16},
valueMin: -100.0,
valueMax: 100.0,
scale: 100,
description: 'Comfort parameters/Temperature minimum, in 0.01°C steps.',
}),
numeric({
name: 'comfort_temperature_max',
unit: 'ºC',
cluster: 'hvacUserInterfaceCfg',
attribute: {ID: 0x0103, type: dataType.int16},
valueMin: -100.0,
valueMax: 100.0,
scale: 100,
description: 'Comfort parameters/Temperature maximum, in 0.01°C steps.',
}),
numeric({
name: 'comfort_humidity_min',
unit: '%',
cluster: 'hvacUserInterfaceCfg',
attribute: {ID: 0x0104, type: dataType.uint16},
valueMin: 0.0,
valueMax: 100.0,
scale: 100,
description: 'Comfort parameters/Humidity minimum, in 0.01% steps.',
}),
numeric({
name: 'comfort_humidity_max',
unit: '%',
cluster: 'hvacUserInterfaceCfg',
attribute: {ID: 0x0105, type: dataType.uint16},
valueMin: 0.0,
valueMax: 100.0,
scale: 100,
description: 'Comfort parameters/Humidity maximum, in 0.01% steps.',
}),
],
ota: ota.zigbeeOTA,
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
const bindClusters = ['msTemperatureMeasurement', 'msRelativeHumidity', 'genPowerCfg'];
await reporting.bind(endpoint, coordinatorEndpoint, bindClusters);
await reporting.temperature(endpoint, {min: 10, max: 300, change: 10});
await reporting.humidity(endpoint, {min: 10, max: 300, change: 50});
await reporting.batteryPercentageRemaining(endpoint);
try {
await endpoint.read('hvacThermostat', [0x0010, 0x0011, 0x0102, 0x0103, 0x0104, 0x0105]);
await endpoint.read('msTemperatureMeasurement', [0x0010]);
await endpoint.read('msRelativeHumidity', [0x0010]);
} catch (e) {
/* backward compatibility */
}
},
};
module.exports = definition;