forked from Koenkk/zigbee-herdsman-converters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (26 loc) · 775 Bytes
/
index.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
'use strict';
const devices = require('./devices');
const toZigbee = require('./converters/toZigbee');
const fromZigbee = require('./converters/fromZigbee');
const byZigbeeModel = new Map();
for (const device of devices) {
for (const zigbeeModel of device.zigbeeModel) {
byZigbeeModel.set(zigbeeModel.toLowerCase(), device);
}
}
module.exports = {
devices,
findByZigbeeModel: (model) => {
if (!model) {
return null;
}
model = model.toLowerCase();
let device = byZigbeeModel.get(model);
if (!device) {
device = byZigbeeModel.get(model.replace(/\0.*$/g, '').trim());
}
return device;
},
toZigbeeConverters: toZigbee,
fromZigbeeConverters: fromZigbee,
};