homebridge-openwrt-control 0.0.2-beta.35 → 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.
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.35",
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,7 +122,7 @@ 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
 
@@ -203,6 +203,8 @@ class AccessPoint extends EventEmitter {
203
203
  this.openWrt.on('systemInfo', (info) => {
204
204
  this.informationService?.updateCharacteristic(Characteristic.FirmwareRevision, info.release?.version);
205
205
  })
206
+ .on('networkInfo', async (info) => {
207
+ })
206
208
  .on('wirelessStatus', async (status) => {
207
209
  })
208
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) => {