homebridge-openwrt-control 0.0.2-beta.3 → 0.0.2-beta.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.
Files changed (2) hide show
  1. package/index.js +19 -19
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -26,34 +26,34 @@ class OpenWrtPlatform {
26
26
  }
27
27
 
28
28
  api.on('didFinishLaunching', async () => {
29
- for (const config of config.devices) {
30
- const { name, host, port, displayType } = config;
31
- if (!name || !host || !port || !displayType) {
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`);
29
+ for (const deviceConfig of config.devices) {
30
+ const { name, host, port, displayType } =deviceConfig;
31
+ if (!name || !host || !displayType) {
32
+ log.warn(`Device: ${host || 'host missing'}, ${name || 'name missing'}, ${!displayType ? ', disply type disabled' : ''} in config, will not be published in the Home app`);
33
33
  continue;
34
34
  }
35
35
 
36
36
  //log config
37
37
  const logLevel = {
38
- devInfo: config.log?.deviceInfo,
39
- success: config.log?.success,
40
- info: config.log?.info,
41
- warn: config.log?.warn,
42
- error: config.log?.error,
43
- debug: config.log?.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
- ...config,
49
+ ...deviceConfig,
50
50
  auth: {
51
- ...config.auth,
51
+ ...deviceConfig.auth,
52
52
  passwd: 'removed',
53
53
  },
54
54
  mqtt: {
55
55
  auth: {
56
- ...config.mqtt?.auth,
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 = (config.refreshInterval ?? 5) * 1000;
65
- if (config.accessPoint?.enable) this.devices.push('accessPoint');
66
- if (config.switch?.enable) this.devices.push('switch');
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(config)
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, config, openWrt, openWrtInfo); break;
94
- case 'switch': type = new Switch(api, config, openWrt, openWrtInfo); break;
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "OpenWrt Control",
3
3
  "name": "homebridge-openwrt-control",
4
- "version": "0.0.2-beta.3",
4
+ "version": "0.0.2-beta.5",
5
5
  "description": "Homebridge plugin to control OpenWrt flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",