homebridge-openwrt-control 0.0.2-beta.35 → 0.0.2-beta.37

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.37",
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,16 @@ 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.device', 'status', { "name": "eth0" });
101
+ //const networkInfo = await this.ubusCall('uci', 'get', { config: 'network.lan.macaddr' });
102
+ if (this.logDebug) this.emit('debug', `Network info data: ${JSON.stringify(networkInfo, null, 2)}`);
103
+
100
104
  //const wirelessStatus = await this.ubusCall('network.wireless', 'status');
101
105
  const wirelessStatus = await this.ubusCall('uci', 'get', { config: 'wireless' });
102
106
  if (this.logDebug) this.emit('debug', `Wireless status data: ${JSON.stringify(wirelessStatus, null, 2)}`);
@@ -126,6 +130,7 @@ class OpenWrt extends EventEmitter {
126
130
 
127
131
  openWrtInfo.state = true;
128
132
  openWrtInfo.systemInfo = systemInfo;
133
+ openWrtInfo.networkInfo = networkInfo;
129
134
  openWrtInfo.wirelessStatus = wirelessStatus;
130
135
  //openWrtInfo.wirelessRadios = wirelessRadios;
131
136
  openWrtInfo.ssids = ssids;
@@ -137,6 +142,7 @@ class OpenWrt extends EventEmitter {
137
142
 
138
143
  // emit data
139
144
  this.emit('systemInfo', systemInfo);
145
+ this.emit('networkInfo', networkInfo);
140
146
  this.emit('wirelessStatus', wirelessStatus);
141
147
  //this.emit('wirelessRadios', wirelessRadios);
142
148
  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) => {