homebridge-openwrt-control 0.0.2-beta.20 → 0.0.2-beta.22

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/package.json +1 -1
  2. package/src/openwrt.js +4 -3
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.20",
4
+ "version": "0.0.2-beta.22",
5
5
  "description": "Homebridge plugin to control OpenWrt flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/openwrt.js CHANGED
@@ -24,7 +24,7 @@ class OpenWrt extends EventEmitter {
24
24
 
25
25
  this.functions = new Functions();
26
26
  this.axiosInstance = axios.create({
27
- baseURL: `http://${config.host}/ubus'`,
27
+ baseURL: `http://${config.host}/ubus`,
28
28
  timeout: 5000,
29
29
  headers: {
30
30
  "Content-Type": "application/json"
@@ -59,7 +59,6 @@ class OpenWrt extends EventEmitter {
59
59
  return this.sessionId;
60
60
  }
61
61
 
62
- this.emit('debug', `Login: ${this.user} ${this.passwd}`)
63
62
  const response = await this.axiosInstance.post('', {
64
63
  jsonrpc: '2.0',
65
64
  id: 1,
@@ -67,6 +66,8 @@ class OpenWrt extends EventEmitter {
67
66
  params: ['00000000000000000000000000000000', 'session', 'login', { username: this.user, password: this.passwd }]
68
67
  });
69
68
 
69
+ this.emit('debug', `Login: ${response}`)
70
+
70
71
  const result = response.data?.result?.[1];
71
72
  if (!result?.ubus_rpc_session) {
72
73
  throw new Error('ubus login failed');
@@ -101,7 +102,7 @@ class OpenWrt extends EventEmitter {
101
102
 
102
103
  try {
103
104
  const systemInfo = await this.ubusCall('system', 'board');
104
- if (this.logDebug) this.emit('debug', `System info data: ${JSON.stringify(systemInfo, null, 2)}`);
105
+ if (!this.logDebug) this.emit('debug', `System info data: ${JSON.stringify(systemInfo, null, 2)}`);
105
106
 
106
107
  const wirelessStatus = await this.ubusCall('network.wireless', 'status');
107
108
  if (this.logDebug) this.emit('debug', `Wireless status data: ${JSON.stringify(wirelessStatus, null, 2)}`);