homebridge-tasmota-control 1.7.4 → 1.7.5
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 +34 -34
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -35,39 +35,39 @@ class tasmotaPlatform {
|
|
|
35
35
|
const disableAccessory = device.disableAccessory || false;
|
|
36
36
|
if (disableAccessory) continue;
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
//log config
|
|
47
|
-
const url = `http://${host}/cm?cmnd=`;
|
|
48
|
-
const auth = device.auth || false;
|
|
49
|
-
const user = device.user || '';
|
|
50
|
-
const passwd = device.passwd || '';
|
|
51
|
-
const loadNameFromDevice = device.loadNameFromDevice || false;
|
|
52
|
-
const refreshInterval = (device.refreshInterval ?? 5000) * 1000;
|
|
53
|
-
const enableDebugMode = device.enableDebugMode || false;
|
|
54
|
-
const logLevel = {
|
|
55
|
-
debug: device.enableDebugMode,
|
|
56
|
-
info: !device.disableLogInfo,
|
|
57
|
-
success: !device.disableLogSuccess,
|
|
58
|
-
warn: !device.disableLogWarn,
|
|
59
|
-
error: !device.disableLogError,
|
|
60
|
-
devInfo: !device.disableLogDeviceInfo,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
if (logLevel.debug) log.info(`Device: ${host} ${deviceName}, debug: Did finish launching.`);
|
|
64
|
-
const newConfig = {
|
|
65
|
-
...device,
|
|
66
|
-
user: 'removed',
|
|
67
|
-
passwd: 'removed'
|
|
68
|
-
};
|
|
69
|
-
if (logLevel.debug) log.info(`Device: ${host} ${deviceName}, Config: ${JSON.stringify(newConfig, null, 2)}.`);
|
|
38
|
+
const deviceName = device.name;
|
|
39
|
+
const host = device.host;
|
|
40
|
+
if (!deviceName || !host) {
|
|
41
|
+
log.warn(`Device Name: ${deviceName ? 'OK' : deviceName}, host: ${host ? 'OK' : host}, in config wrong or missing.`);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
70
44
|
|
|
45
|
+
//log config
|
|
46
|
+
const url = `http://${host}/cm?cmnd=`;
|
|
47
|
+
const auth = device.auth || false;
|
|
48
|
+
const user = device.user || '';
|
|
49
|
+
const passwd = device.passwd || '';
|
|
50
|
+
const loadNameFromDevice = device.loadNameFromDevice || false;
|
|
51
|
+
const refreshInterval = (device.refreshInterval ?? 5000) * 1000;
|
|
52
|
+
const enableDebugMode = device.enableDebugMode || false;
|
|
53
|
+
const logLevel = {
|
|
54
|
+
debug: device.enableDebugMode,
|
|
55
|
+
info: !device.disableLogInfo,
|
|
56
|
+
success: !device.disableLogSuccess,
|
|
57
|
+
warn: !device.disableLogWarn,
|
|
58
|
+
error: !device.disableLogError,
|
|
59
|
+
devInfo: !device.disableLogDeviceInfo,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (logLevel.debug) log.info(`Device: ${host} ${deviceName}, debug: Did finish launching.`);
|
|
63
|
+
const newConfig = {
|
|
64
|
+
...device,
|
|
65
|
+
user: 'removed',
|
|
66
|
+
passwd: 'removed'
|
|
67
|
+
};
|
|
68
|
+
if (logLevel.debug) log.info(`Device: ${host} ${deviceName}, Config: ${JSON.stringify(newConfig, null, 2)}.`);
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
71
|
//create impulse generator
|
|
72
72
|
const impulseGenerator = new ImpulseGenerator()
|
|
73
73
|
.on('start', async () => {
|
|
@@ -152,7 +152,7 @@ class tasmotaPlatform {
|
|
|
152
152
|
i++;
|
|
153
153
|
}
|
|
154
154
|
} catch (error) {
|
|
155
|
-
if (logLevel.error) log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
|
|
155
|
+
if (logLevel.error) log.error(`Device: ${host} ${deviceName}, Start impulse generator error: ${error.message ?? error}, trying again.`);
|
|
156
156
|
}
|
|
157
157
|
}).on('state', (state) => {
|
|
158
158
|
if (logLevel.debug) log.info(`Device: ${host} ${deviceName}, Start impulse generator ${state ? 'started' : 'stopped'}.`);
|
|
@@ -161,7 +161,7 @@ class tasmotaPlatform {
|
|
|
161
161
|
//start impulse generator
|
|
162
162
|
await impulseGenerator.start([{ name: 'start', sampling: 60000 }]);
|
|
163
163
|
} catch (error) {
|
|
164
|
-
if (logLevel.error) log.error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}.`);
|
|
164
|
+
if (logLevel.error) log.error(`Device: ${host} ${deviceName}, Did finish launching error: ${error.message ?? error}.`);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
});
|
package/package.json
CHANGED