/
temperature.js
37 lines (30 loc) · 1016 Bytes
/
temperature.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
'use strict';
const Parameter = require('./parameter');
const Maxim = require('./maxim');
const Bosch = require('./bosch');
const Plantower = require('./plantower');
const Xiaomi = require('./xiaomi');
class Temperature extends Parameter {
constructor(model, persistent, location, options = null) {
super('temperature', persistent, location, 1);
switch(model) {
case 'DS18B20':
this.sensor = new Maxim(model);
break;
case 'BME280':
case 'BMP280':
this.sensor = new Bosch(model, options);
break;
case 'PMS5003T':
case 'PMS5003ST':
this.sensor = new Plantower(model, options);
break;
case 'AirPurifier2':
this.sensor = new Xiaomi(model, options);
break;
default:
throw new Error('unsupport device model ' + model);
}
}
}
module.exports = Temperature;