homebridge-openwrt-control 0.0.2-beta.34 → 0.0.2-beta.36

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.
@@ -13,7 +13,7 @@
13
13
  "type": "array",
14
14
  "items": {
15
15
  "type": "object",
16
- "title": "Network",
16
+ "title": "Device",
17
17
  "properties": {
18
18
  "name": {
19
19
  "title": "Name",
package/index.js CHANGED
@@ -93,7 +93,11 @@ class OpenWrtPlatform {
93
93
  const DeviceClasses = { accessPoint: AccessPoint, switch: Switch };
94
94
  const DeviceClass = DeviceClasses[device];
95
95
 
96
- if (!DeviceClass) return;
96
+ if (!DeviceClass) {
97
+ if (logLevel.warn) log.warn(`Device: ${host} ${name}, class not found for: ${device}`);
98
+ return;
99
+ }
100
+
97
101
  const type = new DeviceClass(api, deviceConfig, openWrt, openWrtInfo)
98
102
  .on('devInfo', msg => logLevel.devInfo && log.info(msg))
99
103
  .on('success', msg => logLevel.success && log.success(`Device: ${host} ${name}, ${msg}`))
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.34",
4
+ "version": "0.0.2-beta.36",
5
5
  "description": "Homebridge plugin to control OpenWrt flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -66,8 +66,8 @@ class AccessPoint extends EventEmitter {
66
66
  this.mqtt1 = new Mqtt({
67
67
  host: this.mqtt.host,
68
68
  port: this.mqtt.port || 1883,
69
- clientId: this.mqtt.clientId ? `${this.savedInfo.manufacturer}_${this.mqtt.clientId}_${Math.random().toString(16).slice(3)}` : `${this.savedInfo.manufacturer}_${Math.random().toString(16).slice(3)}`,
70
- prefix: this.mqtt.prefix ? `${this.savedInfo.manufacturer}/${this.mqtt.prefix}/${this.name}` : `${this.savedInfo.manufacturer}/${this.name}`,
69
+ clientId: this.mqtt.clientId ? `${this.openWrtInfo.systemInfo.release.distribution || 'OpenWrt'}_${this.mqtt.clientId}_${Math.random().toString(16).slice(3)}` : `${this.openWrtInfo.systemInfo.release.distribution || 'OpenWrt'}_${Math.random().toString(16).slice(3)}`,
70
+ prefix: this.mqtt.prefix ? `${this.openWrtInfo.systemInfo.release.distribution || 'OpenWrt'}/${this.mqtt.prefix}/${this.name}` : `${this.openWrtInfo.systemInfo.release.distribution || 'OpenWrt'}/${this.name}`,
71
71
  user: this.mqtt.auth?.user,
72
72
  passwd: this.mqtt.auth?.passwd,
73
73
  logWarn: this.logWarn,
@@ -122,18 +122,17 @@ class AccessPoint extends EventEmitter {
122
122
  //prepare accessory
123
123
  if (this.logDebug) this.emit('debug', `prepare accessory`);
124
124
  const accessoryName = this.name;
125
- const accessoryUUID = AccessoryUUID.generate(`${this.host}${this.openWrtInfo.systemInfo.hostname}`);
125
+ const accessoryUUID = AccessoryUUID.generate(this.host + this.openWrtInfo.systemInfo.system);
126
126
  const accessoryCategory = Categories.AIRPORT;
127
127
  const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
128
128
 
129
129
  //prepare information service
130
130
  if (this.logDebug) this.emit('debug', `prepare information service`);
131
- accessory.getService(Service.AccessoryInformation)
131
+ this.informationService = accessory.getService(Service.AccessoryInformation)
132
132
  .setCharacteristic(Characteristic.Manufacturer, this.openWrtInfo.systemInfo.release.distribution || 'OpenWrt')
133
133
  .setCharacteristic(Characteristic.Model, this.openWrtInfo.systemInfo.model)
134
134
  .setCharacteristic(Characteristic.SerialNumber, this.openWrtInfo.systemInfo.system)
135
- .setCharacteristic(Characteristic.FirmwareRevision, this.openWrtInfo.systemInfo.release?.version)
136
- .setCharacteristic(Characteristic.ConfiguredName, accessoryName);
135
+ .setCharacteristic(Characteristic.FirmwareRevision, this.openWrtInfo.systemInfo.release?.version);
137
136
 
138
137
  if (this.logDebug) this.emit('debug', `prepare service`);
139
138
 
@@ -204,6 +203,8 @@ class AccessPoint extends EventEmitter {
204
203
  this.openWrt.on('systemInfo', (info) => {
205
204
  this.informationService?.updateCharacteristic(Characteristic.FirmwareRevision, info.release?.version);
206
205
  })
206
+ .on('networkInfo', async (info) => {
207
+ })
207
208
  .on('wirelessStatus', async (status) => {
208
209
  })
209
210
  .on('wirelessRadios', async (radios) => {
package/src/openwrt.js CHANGED
@@ -91,12 +91,15 @@ class OpenWrt extends EventEmitter {
91
91
  }
92
92
 
93
93
  async connect() {
94
- const openWrtInfo = { state: false, systemInfo: {}, wirelessStatus: {}, wirelessRadios: [], ssids: [] }
94
+ const openWrtInfo = { state: false, systemInfo: {}, networkInfo: {}, wirelessStatus: {}, wirelessRadios: [], ssids: [] }
95
95
 
96
96
  try {
97
97
  const systemInfo = await this.ubusCall('system', 'board');
98
98
  if (this.logDebug) this.emit('debug', `System info data: ${JSON.stringify(systemInfo, null, 2)}`);
99
99
 
100
+ const networkInfo = await this.ubusCall('network.interface.lan', 'status');
101
+ if (this.logDebug) this.emit('debug', `Network info data: ${JSON.stringify(networkInfo, null, 2)}`);
102
+
100
103
  //const wirelessStatus = await this.ubusCall('network.wireless', 'status');
101
104
  const wirelessStatus = await this.ubusCall('uci', 'get', { config: 'wireless' });
102
105
  if (this.logDebug) this.emit('debug', `Wireless status data: ${JSON.stringify(wirelessStatus, null, 2)}`);
@@ -126,6 +129,7 @@ class OpenWrt extends EventEmitter {
126
129
 
127
130
  openWrtInfo.state = true;
128
131
  openWrtInfo.systemInfo = systemInfo;
132
+ openWrtInfo.networkInfo = networkInfo;
129
133
  openWrtInfo.wirelessStatus = wirelessStatus;
130
134
  //openWrtInfo.wirelessRadios = wirelessRadios;
131
135
  openWrtInfo.ssids = ssids;
@@ -137,6 +141,7 @@ class OpenWrt extends EventEmitter {
137
141
 
138
142
  // emit data
139
143
  this.emit('systemInfo', systemInfo);
144
+ this.emit('networkInfo', networkInfo);
140
145
  this.emit('wirelessStatus', wirelessStatus);
141
146
  //this.emit('wirelessRadios', wirelessRadios);
142
147
  this.emit('ssids', ssids);
package/src/switch.js CHANGED
@@ -66,8 +66,8 @@ class Switch extends EventEmitter {
66
66
  this.mqtt1 = new Mqtt({
67
67
  host: this.mqtt.host,
68
68
  port: this.mqtt.port || 1883,
69
- clientId: this.mqtt.clientId ? `${this.savedInfo.manufacturer}_${this.mqtt.clientId}_${Math.random().toString(16).slice(3)}` : `${this.savedInfo.manufacturer}_${Math.random().toString(16).slice(3)}`,
70
- prefix: this.mqtt.prefix ? `${this.savedInfo.manufacturer}/${this.mqtt.prefix}/${this.name}` : `${this.savedInfo.manufacturer}/${this.name}`,
69
+ clientId: this.mqtt.clientId ? `${this.openWrtInfo.systemInfo.release.distribution || 'OpenWrt'}_${this.mqtt.clientId}_${Math.random().toString(16).slice(3)}` : `${this.openWrtInfo.systemInfo.release.distribution || 'OpenWrt'}_${Math.random().toString(16).slice(3)}`,
70
+ prefix: this.mqtt.prefix ? `${this.openWrtInfo.systemInfo.release.distribution || 'OpenWrt'}/${this.mqtt.prefix}/${this.name}` : `${this.openWrtInfo.systemInfo.release.distribution || 'OpenWrt'}/${this.name}`,
71
71
  user: this.mqtt.auth?.user,
72
72
  passwd: this.mqtt.auth?.passwd,
73
73
  logWarn: this.logWarn,
@@ -122,7 +122,7 @@ class Switch extends EventEmitter {
122
122
  //prepare accessory
123
123
  if (this.logDebug) this.emit('debug', `prepare accessory`);
124
124
  const accessoryName = this.name;
125
- const accessoryUUID = AccessoryUUID.generate(`${this.host}${this.openWrtInfo.systemInfo.hostname}`);
125
+ const accessoryUUID = AccessoryUUID.generate(this.host + this.openWrtInfo.systemInfo.system);
126
126
  const accessoryCategory = Categories.AIRPORT;
127
127
  const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
128
128
 
@@ -205,6 +205,8 @@ class Switch extends EventEmitter {
205
205
  this.openWrt.on('systemInfo', (info) => {
206
206
  this.informationService?.updateCharacteristic(Characteristic.FirmwareRevision, info.release?.version);
207
207
  })
208
+ .on('networkInfo', async (info) => {
209
+ })
208
210
  .on('wirelessStatus', async (status) => {
209
211
  })
210
212
  .on('wirelessRadios', async (radios) => {