homebridge-openwrt-control 0.0.2-beta.3 → 0.0.2-beta.4
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 -17
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -26,8 +26,8 @@ class OpenWrtPlatform {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
api.on('didFinishLaunching', async () => {
|
|
29
|
-
for (const
|
|
30
|
-
const { name, host, port, displayType } =
|
|
29
|
+
for (const deviceConfig of config.devices) {
|
|
30
|
+
const { name, host, port, displayType } =deviceConfig;
|
|
31
31
|
if (!name || !host || !port || !displayType) {
|
|
32
32
|
log.warn(`Device: ${host || 'host missing'}, ${name || 'name missing'}, ${port || 'port missing'}${!displayType ? ', disply type disabled' : ''} in config, will not be published in the Home app`);
|
|
33
33
|
continue;
|
|
@@ -35,25 +35,25 @@ class OpenWrtPlatform {
|
|
|
35
35
|
|
|
36
36
|
//log config
|
|
37
37
|
const logLevel = {
|
|
38
|
-
devInfo:
|
|
39
|
-
success:
|
|
40
|
-
info:
|
|
41
|
-
warn:
|
|
42
|
-
error:
|
|
43
|
-
debug:
|
|
38
|
+
devInfo: deviceConfig.log?.deviceInfo,
|
|
39
|
+
success: deviceConfig.log?.success,
|
|
40
|
+
info: deviceConfig.log?.info,
|
|
41
|
+
warn: deviceConfig.log?.warn,
|
|
42
|
+
error: deviceConfig.log?.error,
|
|
43
|
+
debug: deviceConfig.log?.debug
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
if (logLevel.debug) {
|
|
47
47
|
log.info(`Device: ${host} ${name}, did finish launching.`);
|
|
48
48
|
const safeConfig = {
|
|
49
|
-
...
|
|
49
|
+
...deviceConfig,
|
|
50
50
|
auth: {
|
|
51
|
-
...
|
|
51
|
+
...deviceConfig.auth,
|
|
52
52
|
passwd: 'removed',
|
|
53
53
|
},
|
|
54
54
|
mqtt: {
|
|
55
55
|
auth: {
|
|
56
|
-
...
|
|
56
|
+
...deviceConfig.mqtt?.auth,
|
|
57
57
|
passwd: 'removed',
|
|
58
58
|
}
|
|
59
59
|
},
|
|
@@ -61,13 +61,13 @@ class OpenWrtPlatform {
|
|
|
61
61
|
log.info(`Device: ${host} ${name}, Config: ${JSON.stringify(safeConfig, null, 2)}`);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
const refreshInterval = (
|
|
65
|
-
if (
|
|
66
|
-
if (
|
|
64
|
+
const refreshInterval = (deviceConfig.refreshInterval ?? 5) * 1000;
|
|
65
|
+
if (deviceConfig.accessPoint?.enable) this.devices.push('accessPoint');
|
|
66
|
+
if (deviceConfig.switch?.enable) this.devices.push('switch');
|
|
67
67
|
|
|
68
68
|
if (this.devices.length === 0) return;
|
|
69
69
|
|
|
70
|
-
const openWrt = new OpenWrt(
|
|
70
|
+
const openWrt = new OpenWrt(deviceConfig)
|
|
71
71
|
.on('success', msg => logLevel.success && log.success(`Device: ${host}, ${msg}`))
|
|
72
72
|
.on('info', msg => log.info(`Device: ${host}, ${msg}`))
|
|
73
73
|
.on('debug', msg => log.info(`Device: ${host}, debug: ${msg}`))
|
|
@@ -90,8 +90,8 @@ class OpenWrtPlatform {
|
|
|
90
90
|
// create device instance
|
|
91
91
|
let type;
|
|
92
92
|
switch (device) {
|
|
93
|
-
case 'accessPoint': type = new AccessPoint(api,
|
|
94
|
-
case 'switch': type = new Switch(api,
|
|
93
|
+
case 'accessPoint': type = new AccessPoint(api, deviceConfig, openWrt, openWrtInfo); break;
|
|
94
|
+
case 'switch': type = new Switch(api, deviceConfig, openWrt, openWrtInfo); break;
|
|
95
95
|
default:
|
|
96
96
|
if (logLevel.warn) log.warn(`Device: ${host} ${name}, unknown device: ${device}`);
|
|
97
97
|
return;
|
package/package.json
CHANGED