homebridge-openwrt-control 0.0.2-beta.30 → 0.0.2-beta.32
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 +17 -18
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -66,23 +66,25 @@ class OpenWrtPlatform {
|
|
|
66
66
|
if (deviceConfig.switch?.enable) configuredDevices.push('switch');
|
|
67
67
|
if (configuredDevices.length === 0) return;
|
|
68
68
|
|
|
69
|
-
const openWrt = new OpenWrt(deviceConfig)
|
|
70
|
-
.on('success', msg => logLevel.success && log.success(`Device: ${host}, ${msg}`))
|
|
71
|
-
.on('info', msg => log.info(`Device: ${host} ${name}, ${msg}`))
|
|
72
|
-
.on('debug', msg => log.info(`Device: ${host} ${name}, debug: ${msg}`))
|
|
73
|
-
.on('warn', msg => log.warn(`Device: ${host} ${name}, ${msg}`))
|
|
74
|
-
.on('error', msg => log.error(`Device: ${host} ${name}, ${msg}`))
|
|
75
|
-
|
|
76
|
-
const openWrtInfo = await openWrt.connect();
|
|
77
|
-
if (!openWrtInfo.state) {
|
|
78
|
-
if (logLevel.warn) log.warn(`Device: ${host} ${name}, no data received`);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
69
|
try {
|
|
83
|
-
|
|
70
|
+
const openWrt = new OpenWrt(deviceConfig)
|
|
71
|
+
.on('success', msg => logLevel.success && log.success(`Device: ${host}, ${msg}`))
|
|
72
|
+
.on('info', msg => log.info(`Device: ${host} ${name}, ${msg}`))
|
|
73
|
+
.on('debug', msg => log.info(`Device: ${host} ${name}, debug: ${msg}`))
|
|
74
|
+
.on('warn', msg => log.warn(`Device: ${host} ${name}, ${msg}`))
|
|
75
|
+
.on('error', msg => log.error(`Device: ${host} ${name}, ${msg}`))
|
|
76
|
+
|
|
77
|
+
const openWrtInfo = await openWrt.connect();
|
|
78
|
+
if (!openWrtInfo.state) {
|
|
79
|
+
if (logLevel.warn) log.warn(`Device: ${host} ${name}, no data received`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
84
82
|
|
|
85
|
-
|
|
83
|
+
// start openwrt impulse generator
|
|
84
|
+
await openWrt.impulseGenerator.state(true, [{ name: 'connect', sampling: refreshInterval }], false);
|
|
85
|
+
|
|
86
|
+
// create impulse generator for every device
|
|
87
|
+
for (const device of configuredDevices) {
|
|
86
88
|
const impulseGenerator = new ImpulseGenerator()
|
|
87
89
|
.on('start', async () => {
|
|
88
90
|
try {
|
|
@@ -124,9 +126,6 @@ class OpenWrtPlatform {
|
|
|
124
126
|
// start accessory impulse generator
|
|
125
127
|
await impulseGenerator.state(true, [{ name: 'start', sampling: 120000 }]);
|
|
126
128
|
}
|
|
127
|
-
|
|
128
|
-
// start openwrt impulse generator
|
|
129
|
-
await openWrt.impulseGenerator.state(true, [{ name: 'connect', sampling: refreshInterval }], false);
|
|
130
129
|
} catch (error) {
|
|
131
130
|
if (logLevel.error) log.error(`Device: ${host} ${name}, Did finish launching error: ${error.message ?? error}`);
|
|
132
131
|
}
|
package/package.json
CHANGED