homebridge-openwrt-control 0.0.2-beta.47 → 0.0.2-beta.48
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 +7 -7
- package/package.json +1 -1
- package/src/accesspoint.js +6 -4
package/index.js
CHANGED
|
@@ -67,7 +67,6 @@ class OpenWrtPlatform {
|
|
|
67
67
|
.on('start', async () => {
|
|
68
68
|
try {
|
|
69
69
|
|
|
70
|
-
const refreshInterval = (deviceConfig.refreshInterval ?? 5) * 1000;
|
|
71
70
|
const openWrt = new OpenWrt(deviceConfig)
|
|
72
71
|
.on('success', msg => logLevel.success && log.success(`Device: ${host}, ${msg}`))
|
|
73
72
|
.on('info', msg => log.info(`Device: ${host} ${name}, ${msg}`))
|
|
@@ -82,6 +81,7 @@ class OpenWrtPlatform {
|
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
// start openwrt impulse generator
|
|
84
|
+
const refreshInterval = (deviceConfig.refreshInterval ?? 5) * 1000;
|
|
85
85
|
await openWrt.impulseGenerator.state(true, [{ name: 'connect', sampling: refreshInterval }], false);
|
|
86
86
|
|
|
87
87
|
const configuredDevices = [];
|
|
@@ -96,10 +96,10 @@ class OpenWrtPlatform {
|
|
|
96
96
|
|
|
97
97
|
if (!DeviceClass) {
|
|
98
98
|
if (logLevel.warn) log.warn(`Device: ${host} ${name}, class not found for: ${device}`);
|
|
99
|
-
|
|
99
|
+
continue;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
const type = new DeviceClass(api, deviceConfig
|
|
102
|
+
const type = new DeviceClass(api, deviceConfig)
|
|
103
103
|
.on('devInfo', msg => logLevel.devInfo && log.info(msg))
|
|
104
104
|
.on('success', msg => logLevel.success && log.success(`Device: ${host} ${name}, ${msg}`))
|
|
105
105
|
.on('info', msg => log.info(`Device: ${host} ${name}, ${msg}`))
|
|
@@ -107,15 +107,15 @@ class OpenWrtPlatform {
|
|
|
107
107
|
.on('warn', msg => log.warn(`Device: ${host} ${name}, ${msg}`))
|
|
108
108
|
.on('error', msg => log.error(`Device: ${host} ${name}, ${msg}`));
|
|
109
109
|
|
|
110
|
-
const accessory = await type.start();
|
|
110
|
+
const accessory = await type.start(openWrt, openWrtInfo);
|
|
111
111
|
if (accessory) {
|
|
112
112
|
api.publishExternalAccessories(PluginName, [accessory]);
|
|
113
113
|
if (logLevel.success) log.success(`Device: ${host} ${name}, Published as external accessory.`);
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
// stop accessory impulse generator
|
|
117
|
-
await impulseGenerator.state(false);
|
|
118
115
|
}
|
|
116
|
+
|
|
117
|
+
// stop accessory impulse generator
|
|
118
|
+
await impulseGenerator.state(false);
|
|
119
119
|
} catch (error) {
|
|
120
120
|
if (logLevel.error) log.error(`Device: ${host} ${name}, Start impulse generator error: ${error.message ?? error}, trying again.`);
|
|
121
121
|
}
|
package/package.json
CHANGED
package/src/accesspoint.js
CHANGED
|
@@ -25,9 +25,7 @@ class AccessPoint extends EventEmitter {
|
|
|
25
25
|
this.mqttConnected = false;
|
|
26
26
|
|
|
27
27
|
//openwrt
|
|
28
|
-
|
|
29
|
-
this.openWrtInfo = openWrtInfo;
|
|
30
|
-
this.ssids = openWrtInfo.ssids;
|
|
28
|
+
|
|
31
29
|
};
|
|
32
30
|
|
|
33
31
|
async externalIntegrations() {
|
|
@@ -185,7 +183,11 @@ class AccessPoint extends EventEmitter {
|
|
|
185
183
|
};
|
|
186
184
|
|
|
187
185
|
//start
|
|
188
|
-
async start() {
|
|
186
|
+
async start(openWrt, openWrtInfo) {
|
|
187
|
+
this.openWrt = openWrt;
|
|
188
|
+
this.openWrtInfo = openWrtInfo;
|
|
189
|
+
this.ssids = openWrtInfo.ssids;
|
|
190
|
+
|
|
189
191
|
try {
|
|
190
192
|
//start external integrations
|
|
191
193
|
if (this.restFul.enable || this.mqtt.enable) await this.externalIntegrations();
|