homebridge-melcloud-control 4.2.2-beta.1 → 4.2.2-beta.11
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/CHANGELOG.md +10 -0
- package/README.md +6 -0
- package/config.schema.json +42 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/deviceata.js +114 -65
- package/src/deviceatw.js +65 -24
- package/src/deviceerv.js +155 -109
- package/src/melcloud.js +8 -12
- package/src/melcloudata.js +11 -10
- package/src/melcloudatw.js +11 -10
- package/src/melclouderv.js +11 -10
package/src/melclouderv.js
CHANGED
|
@@ -25,11 +25,9 @@ class MelCloudErv extends EventEmitter {
|
|
|
25
25
|
this.devicesData = {};
|
|
26
26
|
|
|
27
27
|
//lock flags
|
|
28
|
-
this.locks =
|
|
29
|
-
checkState: false,
|
|
30
|
-
};
|
|
28
|
+
this.locks = true;
|
|
31
29
|
this.impulseGenerator = new ImpulseGenerator()
|
|
32
|
-
.on('checkState', () => this.handleWithLock(
|
|
30
|
+
.on('checkState', () => this.handleWithLock(async () => {
|
|
33
31
|
await this.checkState();
|
|
34
32
|
}))
|
|
35
33
|
.on('state', (state) => {
|
|
@@ -37,16 +35,16 @@ class MelCloudErv extends EventEmitter {
|
|
|
37
35
|
});
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
async handleWithLock(
|
|
41
|
-
if (this.locks
|
|
38
|
+
async handleWithLock(fn) {
|
|
39
|
+
if (this.locks) return;
|
|
42
40
|
|
|
43
|
-
this.locks
|
|
41
|
+
this.locks = true;
|
|
44
42
|
try {
|
|
45
43
|
await fn();
|
|
46
44
|
} catch (error) {
|
|
47
45
|
this.emit('error', `Inpulse generator error: ${error}`);
|
|
48
46
|
} finally {
|
|
49
|
-
this.locks
|
|
47
|
+
this.locks = false;
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
|
|
@@ -260,9 +258,12 @@ class MelCloudErv extends EventEmitter {
|
|
|
260
258
|
}
|
|
261
259
|
|
|
262
260
|
updateData(deviceData) {
|
|
261
|
+
this.lock = true;
|
|
262
|
+
this.emit('deviceState', deviceData);
|
|
263
|
+
|
|
263
264
|
setTimeout(() => {
|
|
264
|
-
this.
|
|
265
|
-
},
|
|
265
|
+
this.lock = false
|
|
266
|
+
}, 3000);
|
|
266
267
|
}
|
|
267
268
|
};
|
|
268
269
|
export default MelCloudErv;
|