forked from gadget-monk/homebridge-poolcontroller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
52 lines (42 loc) · 1.17 KB
/
utils.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
var Characteristic;
const F2C = (fahrenheit) => {
return (fahrenheit - 32) * 5 / 9;
}
const C2F = (celsius) => {
return Math.round(celsius * 9 / 5 + 32);
}
const HeatingState = (heatStatus, myCharacteristic) => {
Characteristic = myCharacteristic
if (heatStatus.val==0)
return Characteristic.CurrentHeatingCoolingState.OFF
else
return Characteristic.CurrentHeatingCoolingState.HEAT
}
const HeatingMode = (heatMode, myCharacteristic) => {
Characteristic = myCharacteristic
if (heatMode.val==1)
return Characteristic.TargetHeatingCoolingState.OFF
else
return Characteristic.TargetHeatingCoolingState.HEAT
}
/*
const HK_State = (HK_HeatStatus, myCharacteristic) => {
Characteristic = myCharacteristic
if (HK_HeatStatus==Characteristic.CurrentHeatingCoolingState.OFF)
return 0
else
return 1
}
*/
const HK_Mode = (HK_HeatMode, myCharacteristic) => {
Characteristic = myCharacteristic
if (HK_HeatMode==Characteristic.TargetHeatingCoolingState.OFF)
return 1
else
return 2
}
exports.F2C = F2C
exports.C2F = C2F
exports.HeatingState = HeatingState
exports.HeatingMode = HeatingMode
exports.HK_Mode = HK_Mode