homebridge-openwrt-control 0.0.2-beta.53 → 0.0.2-beta.54
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/accesspoint.js +36 -35
package/package.json
CHANGED
package/src/accesspoint.js
CHANGED
|
@@ -31,41 +31,6 @@ class AccessPoint extends EventEmitter {
|
|
|
31
31
|
this.client = openWrt;
|
|
32
32
|
this.openWrtInfo = openWrtInfo;
|
|
33
33
|
this.ssids = openWrtInfo.ssids;
|
|
34
|
-
|
|
35
|
-
//openwrt client
|
|
36
|
-
|
|
37
|
-
openWrt.on('openWrtInfo', (openWrtInfo) => {
|
|
38
|
-
this.informationService?.updateCharacteristic(Characteristic.FirmwareRevision, openWrtInfo.systemInfo.release?.version);
|
|
39
|
-
const ssids = openWrtInfo.ssids;
|
|
40
|
-
this.ssids = ssids;
|
|
41
|
-
|
|
42
|
-
// sensors
|
|
43
|
-
for (let i = 0; i < ssids.length; i++) {
|
|
44
|
-
const ssid = ssids[i];
|
|
45
|
-
const name = ssid.name;
|
|
46
|
-
const state = ssid.state;
|
|
47
|
-
const serviceName = this.namePrefix ? `${this.name} ${name}` : name;
|
|
48
|
-
this.services?.[i]
|
|
49
|
-
?.setCharacteristic(Characteristic.ConfiguredName, serviceName)
|
|
50
|
-
.updateCharacteristic(Characteristic.On, state);
|
|
51
|
-
|
|
52
|
-
this.sensorServices?.[i]
|
|
53
|
-
?.setCharacteristic(Characteristic.ConfiguredName, serviceName)
|
|
54
|
-
.updateCharacteristic(Characteristic.ContactSensorState, !state);
|
|
55
|
-
|
|
56
|
-
if (this.logInfo) {
|
|
57
|
-
this.emit('info', `Name: ${ssid.name}`);
|
|
58
|
-
this.emit('info', `State: ${ssid.state}`);
|
|
59
|
-
this.emit('info', `Mode: ${ssid.mode}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
.on('restFul', (path, data) => {
|
|
64
|
-
if (this.restFulConnected) this.restFul1.update(path, data);
|
|
65
|
-
})
|
|
66
|
-
.on('mqtt', (topic, message) => {
|
|
67
|
-
if (this.mqttConnected) this.mqtt1.emit('publish', topic, message);
|
|
68
|
-
});
|
|
69
34
|
};
|
|
70
35
|
|
|
71
36
|
async externalIntegrations() {
|
|
@@ -237,7 +202,43 @@ class AccessPoint extends EventEmitter {
|
|
|
237
202
|
this.emit('devInfo', `SSIDs: ${this.ssids.length}`);
|
|
238
203
|
this.emit('devInfo', `----------------------------------`);
|
|
239
204
|
|
|
205
|
+
//openwrt client
|
|
206
|
+
this.deviceUpdate = new DeviceUpdate(this.config, this.openWrt)
|
|
207
|
+
.on('openWrtInfo', (openWrtInfo) => {
|
|
208
|
+
this.informationService?.updateCharacteristic(Characteristic.FirmwareRevision, openWrtInfo.systemInfo.release?.version);
|
|
209
|
+
const ssids = openWrtInfo.ssids;
|
|
210
|
+
this.ssids = ssids;
|
|
211
|
+
|
|
212
|
+
// sensors
|
|
213
|
+
for (let i = 0; i < ssids.length; i++) {
|
|
214
|
+
const ssid = ssids[i];
|
|
215
|
+
const name = ssid.name;
|
|
216
|
+
const state = ssid.state;
|
|
217
|
+
const serviceName = this.namePrefix ? `${this.name} ${name}` : name;
|
|
218
|
+
this.services?.[i]
|
|
219
|
+
?.setCharacteristic(Characteristic.ConfiguredName, serviceName)
|
|
220
|
+
.updateCharacteristic(Characteristic.On, state);
|
|
221
|
+
|
|
222
|
+
this.sensorServices?.[i]
|
|
223
|
+
?.setCharacteristic(Characteristic.ConfiguredName, serviceName)
|
|
224
|
+
.updateCharacteristic(Characteristic.ContactSensorState, !state);
|
|
225
|
+
|
|
226
|
+
if (this.logInfo) {
|
|
227
|
+
this.emit('info', `Name: ${ssid.name}`);
|
|
228
|
+
this.emit('info', `State: ${ssid.state}`);
|
|
229
|
+
this.emit('info', `Mode: ${ssid.mode}`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
.on('restFul', (path, data) => {
|
|
234
|
+
if (this.restFulConnected) this.restFul1.update(path, data);
|
|
235
|
+
})
|
|
236
|
+
.on('mqtt', (topic, message) => {
|
|
237
|
+
if (this.mqttConnected) this.mqtt1.emit('publish', topic, message);
|
|
238
|
+
});
|
|
240
239
|
|
|
240
|
+
//check state
|
|
241
|
+
await this.deviceUpdate.updateState(this.openWrtInfo);
|
|
241
242
|
|
|
242
243
|
//prepare accessory
|
|
243
244
|
const accessory = await this.prepareAccessory();
|