-
Notifications
You must be signed in to change notification settings - Fork 50
/
HomeMaticRegaRequestTestDriver.js
executable file
·63 lines (51 loc) · 1.59 KB
/
HomeMaticRegaRequestTestDriver.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
var isInTest = typeof global.it === 'function'
function HomeMaticRegaRequestTestDriver (log, ccuip) {
this.log = log
this.ccuIP = ccuip
this.timeout = 120
this.data = 0
if (!isInTest) {
this.log.warn('Rega Dummy Class for Tests only it looks like i am running in production mode.')
}
}
HomeMaticRegaRequestTestDriver.prototype = {
script: function (script, callback) {
if (this.platform.homebridge !== undefined) {
this.platform.homebridge.values['lastScript'] = script
}
callback()
},
getValue: function (channel, datapoint, callback) {
if (this.platform.homebridge !== undefined) {
this.log.debug('Rega Query %s', channel + '.' + datapoint)
if (callback !== undefined) { callback(this.platform.homebridge.values[channel + '.' + datapoint]) }
} else {
let result = 0
callback(result)
}
},
setValue: function (channel, datapoint, value) {
this.log.debug('Set Rega Called %s.%s - %s', channel, datapoint, value)
if (this.platform.homebridge !== undefined) {
if (typeof value === 'object') {
value = value['explicitDouble']
}
this.platform.homebridge.values[channel + '.' + datapoint] = value
}
},
setVariable: function (channel, value) {
},
getVariable: function (channel, callback) {
this.log.warn('getback %s', this.data)
callback(this.data)
},
isInt: function (n) {
return Number(n) === n && n % 1 === 0
},
isFloat: function (n) {
return n === Number(n) && n % 1 !== 0
}
}
module.exports = {
HomeMaticRegaRequestTestDriver: HomeMaticRegaRequestTestDriver
}