homebridge-melcloud-control 4.9.2-beta.3 → 4.9.2-beta.4

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.3",
4
+ "version": "4.9.2-beta.4",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -420,19 +420,18 @@ class MelCloudHome extends EventEmitter {
420
420
 
421
421
  // ── Buduje connectInfo po udanym token exchange ───────────────────────────
422
422
 
423
- buildConnectInfo(connectInfo, exchangeRes) {
423
+ async buildConnectInfo(connectInfo, exchangeRes) {
424
424
  if (exchangeRes) {
425
425
  // ensureClient() tworzy client jeśli nie istnieje.
426
426
  // attachTokenInterceptors() dodaje interceptory tylko przy pierwszym wywołaniu.
427
427
  this.ensureClient();
428
428
  this.attachTokenInterceptors();
429
429
  this.emit('client', this.client);
430
+ await this.connectSocket().catch(err => {
431
+ if (this.logError) this.emit('error', `Initial WebSocket connect failed: ${err.message}`);
432
+ });
430
433
  }
431
434
 
432
- this.connectSocket().catch(err => {
433
- if (this.logError) this.emit('error', `Initial WebSocket connect failed: ${err.message}`);
434
- });
435
-
436
435
  connectInfo.State = exchangeRes;
437
436
  connectInfo.Status = `Connect Success${this.socketConnected ? ', Web Socket Connected' : ''}`;
438
437
 
@@ -640,7 +639,7 @@ class MelCloudHome extends EventEmitter {
640
639
  if (authCode) {
641
640
  if (this.logDebug) this.emit('debug', 'Re-login with existing session (skipping credentials)');
642
641
  const exchangeRes = await this.exchangeCodeForTokens(client, authCode, codeVerifier);
643
- return this.buildConnectInfo(connectInfo, exchangeRes);
642
+ return await this.buildConnectInfo(connectInfo, exchangeRes);
644
643
  }
645
644
 
646
645
  // ── Step 3: Wyślij dane logowania do Cognito ──────────────────────
@@ -773,7 +772,7 @@ class MelCloudHome extends EventEmitter {
773
772
 
774
773
  // ── Step 6: Wymień kod na tokeny ──────────────────────────────────
775
774
  const exchangeRes = await this.exchangeCodeForTokens(client, authCode, codeVerifier);
776
- return this.buildConnectInfo(connectInfo, exchangeRes);
775
+ return await this.buildConnectInfo(connectInfo, exchangeRes);
777
776
 
778
777
  } catch (error) {
779
778
  throw new Error(`Connect error: ${error.message}`);