homebridge-melcloud-control 4.0.0-beta.457 → 4.0.0-beta.459
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/homebridge-ui/public/index.html +1 -4
- package/package.json +1 -1
- package/src/melcloud.js +41 -20
|
@@ -230,10 +230,7 @@
|
|
|
230
230
|
|
|
231
231
|
try {
|
|
232
232
|
const account = pluginConfig[0].accounts[this.accountIndex];
|
|
233
|
-
const devicesInMelCloud = await
|
|
234
|
-
homebridge.request('/connect', account),
|
|
235
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error('Connection timeout (30s)')), 30000))
|
|
236
|
-
]);
|
|
233
|
+
const devicesInMelCloud = await homebridge.request('/connect', account);
|
|
237
234
|
|
|
238
235
|
// Initialize devices arrays
|
|
239
236
|
const newDevices = { ata: [], ataPresets: [], atw: [], atwPresets: [], erv: [], ervPresets: [] };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.459",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/melcloud.js
CHANGED
|
@@ -426,30 +426,51 @@ class MelCloud extends EventEmitter {
|
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
async checkDevicesList() {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
429
|
+
const TIMEOUT_MS = 30000; // 30 seconds timeout
|
|
430
|
+
try {
|
|
431
|
+
const devices = await Promise.race([
|
|
432
|
+
(async () => {
|
|
433
|
+
switch (this.accountType) {
|
|
434
|
+
case "melcloud":
|
|
435
|
+
return await this.checkMelcloudDevicesList();
|
|
436
|
+
case "melcloudhome":
|
|
437
|
+
return await this.checkMelcloudHomeDevicesList();
|
|
438
|
+
default:
|
|
439
|
+
return [];
|
|
440
|
+
}
|
|
441
|
+
})(),
|
|
442
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('Device list timeout (30s)')), TIMEOUT_MS))
|
|
443
|
+
]);
|
|
444
|
+
|
|
445
|
+
return devices;
|
|
446
|
+
} catch (err) {
|
|
447
|
+
if (this.logError) this.emit('error', `Device list error: ${err.message}`);
|
|
448
|
+
throw new Error(`Device list error: ${err.message}`);
|
|
439
449
|
}
|
|
440
450
|
}
|
|
441
451
|
|
|
442
452
|
async connect(refresh) {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
+
const TIMEOUT_MS = 30000;
|
|
454
|
+
|
|
455
|
+
try {
|
|
456
|
+
const result = await Promise.race([
|
|
457
|
+
(async () => {
|
|
458
|
+
switch (this.accountType) {
|
|
459
|
+
case "melcloud":
|
|
460
|
+
return await this.connectToMelCloud();
|
|
461
|
+
case "melcloudhome":
|
|
462
|
+
return await this.connectToMelCloudHome(refresh);
|
|
463
|
+
default:
|
|
464
|
+
return {};
|
|
465
|
+
}
|
|
466
|
+
})(),
|
|
467
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('Connection timeout (30s)')), TIMEOUT_MS))
|
|
468
|
+
]);
|
|
469
|
+
|
|
470
|
+
return result;
|
|
471
|
+
} catch (err) {
|
|
472
|
+
if (this.logError) this.emit('error', `Connect error: ${err.message}`);
|
|
473
|
+
throw new Error(`Connect error: ${err.message}`);
|
|
453
474
|
}
|
|
454
475
|
}
|
|
455
476
|
|