homebridge-tasmota-control 1.6.15-beta.26 → 1.6.15-beta.28
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/index.js +4 -6
- package/package.json +1 -1
- package/src/deviceinfo.js +1 -1
- package/src/impulsegenerator.js +12 -10
package/index.js
CHANGED
|
@@ -33,9 +33,7 @@ class tasmotaPlatform {
|
|
|
33
33
|
|
|
34
34
|
//check accessory is enabled
|
|
35
35
|
const disableAccessory = device.disableAccessory || false;
|
|
36
|
-
if (disableAccessory)
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
36
|
+
if (disableAccessory) continue;
|
|
39
37
|
|
|
40
38
|
const deviceName = device.name;
|
|
41
39
|
const host = device.host;
|
|
@@ -53,7 +51,7 @@ class tasmotaPlatform {
|
|
|
53
51
|
const refreshInterval = device.refreshInterval * 1000 || 5000;
|
|
54
52
|
const enableDebugMode = device.enableDebugMode || false;
|
|
55
53
|
const logLevel = {
|
|
56
|
-
debug: enableDebugMode,
|
|
54
|
+
debug: device.enableDebugMode,
|
|
57
55
|
info: !device.disableLogInfo,
|
|
58
56
|
success: !device.disableLogSuccess,
|
|
59
57
|
warn: !device.disableLogWarn,
|
|
@@ -71,7 +69,7 @@ class tasmotaPlatform {
|
|
|
71
69
|
|
|
72
70
|
try {
|
|
73
71
|
//get device info
|
|
74
|
-
const deviceInfo = new DeviceInfo(url, auth, user, passwd, deviceName, loadNameFromDevice, enableDebugMode
|
|
72
|
+
const deviceInfo = new DeviceInfo(url, auth, user, passwd, deviceName, loadNameFromDevice, enableDebugMode)
|
|
75
73
|
.on('debug', (msg) => logLevel.debug && log.info(`Device: ${host} ${deviceName}, debug: ${msg}`))
|
|
76
74
|
.on('warn', (msg) => logLevel.warn && log.warn(`Device: ${host} ${deviceName}, ${msg}`))
|
|
77
75
|
.on('error', (msg) => logLevel.error && log.error(`Device: ${host} ${deviceName}, ${msg}`));
|
|
@@ -106,7 +104,7 @@ class tasmotaPlatform {
|
|
|
106
104
|
}
|
|
107
105
|
});
|
|
108
106
|
} catch (error) {
|
|
109
|
-
log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}`);
|
|
107
|
+
if (logLevel.error) log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}`);
|
|
110
108
|
return;
|
|
111
109
|
}
|
|
112
110
|
|
package/package.json
CHANGED
package/src/deviceinfo.js
CHANGED
|
@@ -3,7 +3,7 @@ import EventEmitter from 'events';
|
|
|
3
3
|
import { ApiCommands, LightKeys, SensorKeys } from './constants.js';
|
|
4
4
|
|
|
5
5
|
class DeviceInfo extends EventEmitter {
|
|
6
|
-
constructor(url, auth, user, passwd, deviceName, loadNameFromDevice, enableDebugMode
|
|
6
|
+
constructor(url, auth, user, passwd, deviceName, loadNameFromDevice, enableDebugMode) {
|
|
7
7
|
super();
|
|
8
8
|
this.name = deviceName
|
|
9
9
|
this.loadNameFromDevice = loadNameFromDevice;
|
package/src/impulsegenerator.js
CHANGED
|
@@ -4,6 +4,7 @@ class ImpulseGenerator extends EventEmitter {
|
|
|
4
4
|
constructor() {
|
|
5
5
|
super();
|
|
6
6
|
this.timersState = false;
|
|
7
|
+
this.timers = [];
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
async start(timers) {
|
|
@@ -12,20 +13,19 @@ class ImpulseGenerator extends EventEmitter {
|
|
|
12
13
|
return true;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
//update state
|
|
16
|
-
const updateState = timers.length > 0 ? this.state(true) : false;
|
|
17
|
-
|
|
18
|
-
//add timers
|
|
19
16
|
this.timers = [];
|
|
17
|
+
|
|
20
18
|
for (const timer of timers) {
|
|
21
19
|
this.emit(timer.name);
|
|
22
20
|
|
|
23
|
-
const
|
|
21
|
+
const interval = setInterval(() => {
|
|
24
22
|
this.emit(timer.name);
|
|
25
23
|
}, timer.sampling);
|
|
26
|
-
|
|
24
|
+
|
|
25
|
+
this.timers.push(interval);
|
|
27
26
|
}
|
|
28
27
|
|
|
28
|
+
this.state(true);
|
|
29
29
|
return true;
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -35,12 +35,13 @@ class ImpulseGenerator extends EventEmitter {
|
|
|
35
35
|
return true;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
for (const timer of this.timers) {
|
|
39
|
+
clearInterval(timer);
|
|
40
|
+
}
|
|
41
41
|
|
|
42
|
+
this.timers = [];
|
|
42
43
|
this.state(false);
|
|
43
|
-
return true
|
|
44
|
+
return true;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
state(state) {
|
|
@@ -48,4 +49,5 @@ class ImpulseGenerator extends EventEmitter {
|
|
|
48
49
|
this.emit('state', state);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
52
|
+
|
|
51
53
|
export default ImpulseGenerator;
|