homebridge-melcloud-control 4.9.2-beta.6 → 4.9.2-beta.7

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": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.9.2-beta.6",
4
+ "version": "4.9.2-beta.7",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -16,6 +16,7 @@ class MelCloudHome extends EventEmitter {
16
16
 
17
17
  this.user = account.user;
18
18
  this.passwd = account.passwd;
19
+ this.logSuccess = account.log?.success;
19
20
  this.logInfo = account.log?.info;
20
21
  this.logWarn = account.log?.warn;
21
22
  this.logError = account.log?.error;
@@ -95,7 +96,7 @@ class MelCloudHome extends EventEmitter {
95
96
  'Cache-Control': 'no-cache',
96
97
  };
97
98
 
98
- if (!this.logDebug) this.emit('debug', `Connecting WebSocket: ${url.slice(0, 60)}...`);
99
+ if (this.logDebug) this.emit('debug', `Connecting WebSocket: ${url.slice(0, 60)}...`);
99
100
 
100
101
  try {
101
102
  const ws = new WebSocket(url, { headers });
@@ -106,7 +107,7 @@ class MelCloudHome extends EventEmitter {
106
107
  try { ws.close(); } catch { /* ignoruj */ }
107
108
  })
108
109
  .on('close', () => {
109
- if (!this.logDebug) this.emit('debug', 'Web socket closed');
110
+ if (this.logDebug) this.emit('debug', 'Web socket closed');
110
111
  this.cleanupSocket();
111
112
  this.scheduleReconnect();
112
113
  })
@@ -118,7 +119,7 @@ class MelCloudHome extends EventEmitter {
118
119
  clearTimeout(this.reconnectTimer);
119
120
  this.reconnectTimer = null;
120
121
  }
121
- if (!this.logDebug) this.emit('debug', 'Web Socket Connected');
122
+ if (this.logSuccess) this.emit('success', 'Web Socket Connected');
122
123
 
123
124
  // Heartbeat co 30s
124
125
  this.heartbeat = setInterval(() => {
@@ -129,12 +130,12 @@ class MelCloudHome extends EventEmitter {
129
130
  }, 30_000);
130
131
  })
131
132
  .on('pong', () => {
132
- if (!this.logDebug) this.emit('debug', 'Web socket received heartbeat');
133
+ if (this.logDebug) this.emit('debug', 'Web socket received heartbeat');
133
134
  })
134
135
  .on('message', (message) => {
135
136
  try {
136
137
  const parsedMessage = JSON.parse(message);
137
- if (!this.logDebug) this.emit('debug', `Web socket incoming message: ${JSON.stringify(parsedMessage, null, 2)}`);
138
+ if (this.logDebug) this.emit('debug', `Web socket incoming message: ${JSON.stringify(parsedMessage, null, 2)}`);
138
139
 
139
140
  // Format: array, pierwszy element ma Data.id
140
141
  const messageData = parsedMessage?.[0]?.Data;
@@ -426,11 +427,10 @@ class MelCloudHome extends EventEmitter {
426
427
  const webSocket = await this.connectSocket().catch(err => {
427
428
  if (this.logError) this.emit('error', `Initial WebSocket connect failed: ${err.message}`);
428
429
  });
429
-
430
- connectInfo.Status = `Connect Success ${webSocket ? ', Web Socket Connected' : ''}`;
431
430
  }
432
431
 
433
432
  connectInfo.State = exchangeRes;
433
+ connectInfo.Status = exchangeRes ? 'Connect Success' : 'Connect Failed';
434
434
 
435
435
  return connectInfo;
436
436
  }