-
Notifications
You must be signed in to change notification settings - Fork 3
/
UDPORSock.js
110 lines (87 loc) · 3.06 KB
/
UDPORSock.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
var sock = new sockets.udp();
sock.connect("192.168.1.33", 9091);
sock.send("Socket quadras started");
this.bindFunc1 = function (zwayName) {
if (zwayName != "zway") {
return; // you want to bind to default zway instance
}
var devices = global.ZWave[zwayName].zway.devices;
//from here insert your devices
devices[4].SwitchBinary.data.level.bind(function () {
var status = (this.value) ? "on" : "off";
sock.send("ZWay_2," + status);
});
devices[7].SwitchBinary.data.level.bind(function () {
var status = (this.value) ? "on" : "off";
sock.send("ZWay_3," + status);
});
devices[27].SwitchBinary.data.level.bind(function () {
var status = (this.value) ? "on" : "off";
sock.send("ZWay_6," + status);
});
devices[26].SwitchBinary.data.level.bind(function () {
var status = (this.value) ? "on" : "off";
sock.send("ZWay_7," + status);
});
devices[6].SwitchBinary.data.level.bind(function () {
var status = (this.value) ? "on" : "off";
sock.send("ZWay_21," + status);
});
devices[28].SwitchBinary.data.level.bind(function () {
var status = (this.value) ? "on" : "off";
sock.send("ZWay_26," + status);
});
devices[32].SensorBinary.data[1].level.bind(function () {
var status = (this.value) ? "on" : "off";
sock.send("ZWay_32_0_1," + status);
});
devices[19].SensorBinary.data[1].level.bind(function () {
var status = (this.value) ? "on" : "off";
sock.send("ZWay_19_0_1," + status);
});
devices[35].SensorBinary.data[1].level.bind(function () {
var status = (this.value) ? "on" : "off";
sock.send("ZWay_30_0_1," + status);
});
devices[31].instances[1].SensorBinary.data[1].level.bind(function () {
var status = (this.value) ? "on" : "off";
sock.send("ZWay_15_1_1," + status);
});
devices[31].instances[2].SensorBinary.data[1].level.bind(function () {
var status = (this.value) ? "on" : "off";
sock.send("ZWay_15_2_1," + status);
});
devices[31].instances[3].SensorMultilevel.data[1].val.bind(function () {
var status = Math.round(this.value*10)/10;
sock.send("ZWay_15_3_1," + status);
});
devices[31].instances[4].SensorMultilevel.data[1].val.bind(function () {
var status = Math.round(this.value*10)/10;
sock.send("ZWay_15_4_1," + status);
});
devices[31].instances[5].SensorMultilevel.data[1].val.bind(function () {
var status = Math.round(this.value*10)/10;
sock.send("ZWay_15_5_1," + status);
});
devices[31].instances[6].SensorMultilevel.data[1].val.bind(function () {
var status = Math.round(this.value*10)/10;
sock.send("ZWay_15_6_1," + status);
});
devices[6].instances[0].Meter.data[2].val.bind(function () {
var status = this.value;
sock.send("ZWay_21_0_2," + status);
});
//ThermostatMode
devices[33].ThermostatMode.data.mode.bind(function () {
var mode = (this.value);
var status = devices[33].ThermostatMode.data[mode].modeName.value;
sock.send("ZWay_33_0_64," + status);
});
//Last device before this comment
};
// process all active bindings
if (global.ZWave) {
global.ZWave().forEach(this.bindFunc1);
}
// and listen for future ones
global.controller.on("ZWave.register", this.bindFunc1);