homebridge-melcloud-control 3.5.1 → 3.5.2

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.
@@ -8,11 +8,14 @@ class ImpulseGenerator extends EventEmitter {
8
8
 
9
9
  async start(timers) {
10
10
  if (this.timersState) {
11
- await this.stop();
11
+ this.state(true);
12
+ return true;
12
13
  }
13
14
 
14
15
  this.timers = [];
15
16
  for (const timer of timers) {
17
+ this.emit(timer.name);
18
+
16
19
  const newTimer = setInterval(() => {
17
20
  this.emit(timer.name);
18
21
  }, timer.sampling);
@@ -20,28 +23,26 @@ class ImpulseGenerator extends EventEmitter {
20
23
  };
21
24
 
22
25
  //update state
23
- this.timersState = true;
24
- this.state();
25
-
26
+ this.state(true);
26
27
  return true;
27
28
  }
28
29
 
29
30
  async stop() {
30
- if (this.timersState) {
31
- this.timers.forEach(timer => clearInterval(timer));
31
+ if (!this.timersState) {
32
+ this.state(false);
33
+ return true;
32
34
  }
33
35
 
34
36
  //update state
37
+ this.timers.forEach(timer => clearInterval(timer));
35
38
  this.timers = [];
36
- this.timersState = false;
37
- this.state();
38
-
39
- return true;
39
+ this.state(false);
40
+ return true
40
41
  }
41
42
 
42
- state() {
43
- this.emit('state', this.timersState);
44
- return this.timersState;
43
+ state(state) {
44
+ this.timersState = state;
45
+ this.emit('state', state);
45
46
  }
46
47
  }
47
48
  export default ImpulseGenerator;