homebridge-tasmota-control 1.2.0 → 1.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tasmota Control",
3
3
  "name": "homebridge-tasmota-control",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -8,7 +8,8 @@ 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 = [];
@@ -22,28 +23,26 @@ class ImpulseGenerator extends EventEmitter {
22
23
  };
23
24
 
24
25
  //update state
25
- this.timersState = true;
26
- this.state();
27
-
26
+ this.state(true);
28
27
  return true;
29
28
  }
30
29
 
31
30
  async stop() {
32
- if (this.timersState) {
33
- this.timers.forEach(timer => clearInterval(timer));
31
+ if (!this.timersState) {
32
+ this.state(false);
33
+ return true;
34
34
  }
35
35
 
36
36
  //update state
37
+ this.timers.forEach(timer => clearInterval(timer));
37
38
  this.timers = [];
38
- this.timersState = false;
39
- this.state();
40
-
39
+ this.state(false);
41
40
  return true
42
41
  }
43
42
 
44
- state() {
45
- this.emit('state', this.timersState);
46
- return this.timersState;
43
+ state(state) {
44
+ this.timersState = state;
45
+ this.emit('state', state);
47
46
  }
48
47
  }
49
48
  export default ImpulseGenerator;