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 +1 -1
- package/src/impulsegenerator.js +11 -12
package/package.json
CHANGED
package/src/impulsegenerator.js
CHANGED
|
@@ -8,7 +8,8 @@ class ImpulseGenerator extends EventEmitter {
|
|
|
8
8
|
|
|
9
9
|
async start(timers) {
|
|
10
10
|
if (this.timersState) {
|
|
11
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
39
|
-
this.state();
|
|
40
|
-
|
|
39
|
+
this.state(false);
|
|
41
40
|
return true
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
state() {
|
|
45
|
-
this.
|
|
46
|
-
|
|
43
|
+
state(state) {
|
|
44
|
+
this.timersState = state;
|
|
45
|
+
this.emit('state', state);
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
export default ImpulseGenerator;
|