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.
@@ -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('checkState', async () => {
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(lockKey, fn) {
41
- if (this.locks[lockKey]) return;
38
+ async handleWithLock(fn) {
39
+ if (this.locks) return;
42
40
 
43
- this.locks[lockKey] = true;
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[lockKey] = false;
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.emit('deviceState', deviceData);
265
- }, 300);
265
+ this.lock = false
266
+ }, 3000);
266
267
  }
267
268
  };
268
269
  export default MelCloudErv;