homebridge-melcloud-control 3.9.2-beta.1 → 3.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/impulsegenerator.js +13 -11
- package/src/mqtt.js +2 -2
- package/src/restful.js +2 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "3.9.
|
|
4
|
+
"version": "3.9.3",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/impulsegenerator.js
CHANGED
|
@@ -4,6 +4,7 @@ class ImpulseGenerator extends EventEmitter {
|
|
|
4
4
|
constructor() {
|
|
5
5
|
super();
|
|
6
6
|
this.timersState = false;
|
|
7
|
+
this.timers = [];
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
async start(timers) {
|
|
@@ -12,20 +13,19 @@ class ImpulseGenerator extends EventEmitter {
|
|
|
12
13
|
return true;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
//update state
|
|
16
|
-
const updateState = timers.length > 0 ? this.state(true) : false;
|
|
17
|
-
|
|
18
|
-
//add timers
|
|
19
16
|
this.timers = [];
|
|
17
|
+
|
|
20
18
|
for (const timer of timers) {
|
|
21
19
|
this.emit(timer.name);
|
|
22
20
|
|
|
23
|
-
const
|
|
21
|
+
const interval = setInterval(() => {
|
|
24
22
|
this.emit(timer.name);
|
|
25
23
|
}, timer.sampling);
|
|
26
|
-
this.timers.push(newTimer);
|
|
27
|
-
};
|
|
28
24
|
|
|
25
|
+
this.timers.push(interval);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this.state(true);
|
|
29
29
|
return true;
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -35,12 +35,13 @@ class ImpulseGenerator extends EventEmitter {
|
|
|
35
35
|
return true;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
for (const timer of this.timers) {
|
|
39
|
+
clearInterval(timer);
|
|
40
|
+
}
|
|
41
41
|
|
|
42
|
+
this.timers = [];
|
|
42
43
|
this.state(false);
|
|
43
|
-
return true
|
|
44
|
+
return true;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
state(state) {
|
|
@@ -48,4 +49,5 @@ class ImpulseGenerator extends EventEmitter {
|
|
|
48
49
|
this.emit('state', state);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
52
|
+
|
|
51
53
|
export default ImpulseGenerator;
|
package/src/mqtt.js
CHANGED
|
@@ -27,7 +27,7 @@ class Mqtt extends EventEmitter {
|
|
|
27
27
|
this.mqttClient.on('message', (topic, message) => {
|
|
28
28
|
try {
|
|
29
29
|
const obj = JSON.parse(message.toString());
|
|
30
|
-
|
|
30
|
+
if (config.debug) this.emit('debug', `MQTT Received topic: ${topic}, message: ${JSON.stringify(obj, null, 2)}`);
|
|
31
31
|
const key = Object.keys(obj)[0];
|
|
32
32
|
const value = Object.values(obj)[0];
|
|
33
33
|
this.emit('set', key, value);
|
|
@@ -43,7 +43,7 @@ class Mqtt extends EventEmitter {
|
|
|
43
43
|
const fullTopic = `${config.prefix}/${topic}`;
|
|
44
44
|
const publishMessage = JSON.stringify(message, null, 2);
|
|
45
45
|
await this.mqttClient.publish(fullTopic, publishMessage);
|
|
46
|
-
|
|
46
|
+
if (config.debug) this.emit('debug', `MQTT Publish topic: ${fullTopic}, message: ${publishMessage}`);
|
|
47
47
|
} catch (error) {
|
|
48
48
|
this.emit('warn', `MQTT Publish error: ${error}`);
|
|
49
49
|
};
|
package/src/restful.js
CHANGED
|
@@ -53,9 +53,7 @@ class RestFul extends EventEmitter {
|
|
|
53
53
|
this.emit('set', key, value);
|
|
54
54
|
this.update(key, value);
|
|
55
55
|
|
|
56
|
-
if (this.restFulDebug) {
|
|
57
|
-
this.emit('debug', `RESTFul post data: ${JSON.stringify(obj, null, 2)}`);
|
|
58
|
-
}
|
|
56
|
+
if (this.restFulDebug) this.emit('debug', `RESTFul post data: ${JSON.stringify(obj, null, 2)}`);
|
|
59
57
|
|
|
60
58
|
res.json({ success: true, received: obj });
|
|
61
59
|
} catch (error) {
|
|
@@ -81,9 +79,7 @@ class RestFul extends EventEmitter {
|
|
|
81
79
|
return;
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
if (this.restFulDebug) {
|
|
85
|
-
this.emit('debug', `RESTFul update path: ${path}, data: ${JSON.stringify(data)}`);
|
|
86
|
-
}
|
|
82
|
+
if (this.restFulDebug) this.emit('debug', `RESTFul update path: ${path}, data: ${JSON.stringify(data)}`);
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
85
|
|