homebridge-melcloud-control 4.10.8 → 4.10.9-beta.0

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.
@@ -271,7 +271,10 @@
271
271
  try {
272
272
  const account = this.account;
273
273
  const accountTypeMelcloud = account.type === 'melcloud';
274
- const melCloudDevicesData = await homebridge.request('/connect', account);
274
+ const connectTimeout = new Promise((_, reject) =>
275
+ setTimeout(() => reject(new Error('Connection timed out — please try again')), 160_000)
276
+ );
277
+ const melCloudDevicesData = await Promise.race([homebridge.request('/connect', account), connectTimeout]);
275
278
 
276
279
  if (!melCloudDevicesData.State) {
277
280
  updateInfo('info', melCloudDevicesData.Status, 'red');
@@ -13,17 +13,24 @@ class PluginUiServer extends HomebridgePluginUiServer {
13
13
  this.ready();
14
14
  };
15
15
 
16
+ withTimeout(promise, ms, label) {
17
+ const timer = new Promise((_, reject) =>
18
+ setTimeout(() => reject(new Error(`${label} timed out after ${ms / 1000}s`)), ms)
19
+ );
20
+ return Promise.race([promise, timer]);
21
+ }
22
+
16
23
  async start(account) {
17
24
  const melCloudClass = account.type === 'melcloud' ? new MelCloud(account) : new MelCloudHome(account);
18
25
 
19
26
  try {
20
- const melCloudAccountData = await melCloudClass.connect();
27
+ const melCloudAccountData = await this.withTimeout(melCloudClass.connect(), 90_000, 'connect');
21
28
  if (!melCloudAccountData.State) return melCloudAccountData;
22
29
 
23
- const melCloudDevicesData = await melCloudClass.checkDevicesList();
30
+ const melCloudDevicesData = await this.withTimeout(melCloudClass.checkDevicesList(), 60_000, 'checkDevicesList');
24
31
  return melCloudDevicesData;
25
32
  } catch (error) {
26
- throw new Error(error);
33
+ throw new Error(error.message ?? error);
27
34
  }
28
35
  }
29
36
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.10.8",
4
+ "version": "4.10.9-beta.0",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -35,7 +35,7 @@
35
35
  "node": "^20 || ^22 || ^24 || ^25 || ^26"
36
36
  },
37
37
  "dependencies": {
38
- "@homebridge/plugin-ui-utils": "^2.2.3",
38
+ "@homebridge/plugin-ui-utils": "^2.2.4",
39
39
  "mqtt": "^5.15.1",
40
40
  "axios": "^1.16.1",
41
41
  "axios-cookiejar-support": "^7.0.0",