homebridge-melcloud-control 4.0.0-beta.516 → 4.0.0-beta.518
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 -1
- package/index.js +6 -10
- package/package.json +1 -1
- package/src/melcloud.js +6 -16
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
const newDevices = { ata: [], ataPresets: [], atw: [], atwPresets: [], erv: [], ervPresets: [] };
|
|
242
242
|
const devicesByType = { ata: [], atw: [], erv: [] };
|
|
243
243
|
|
|
244
|
-
response.forEach(d => {
|
|
244
|
+
response.Devices.forEach(d => {
|
|
245
245
|
if (d.Type === 0) devicesByType.ata.push(d);
|
|
246
246
|
if (d.Type === 1) devicesByType.atw.push(d);
|
|
247
247
|
if (d.Type === 3) devicesByType.erv.push(d);
|
package/index.js
CHANGED
|
@@ -59,7 +59,6 @@ class MelCloudPlatform {
|
|
|
59
59
|
debug: account.log?.debug
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
|
|
63
62
|
if (logLevel.debug) {
|
|
64
63
|
log.info(`${accountName}, debug: did finish launching.`);
|
|
65
64
|
const safeConfig = {
|
|
@@ -109,6 +108,7 @@ class MelCloudPlatform {
|
|
|
109
108
|
if (logLevel.warn) log.warn(`${accountName}, ${accountInfo.Info}`);
|
|
110
109
|
return;
|
|
111
110
|
}
|
|
111
|
+
if (logLevel.success) log.success(accountInfo.Info);
|
|
112
112
|
const useFahrenheit = accountInfo.UseFahrenheit;
|
|
113
113
|
|
|
114
114
|
//check devices list
|
|
@@ -125,9 +125,9 @@ class MelCloudPlatform {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
//configured devices
|
|
128
|
-
const ataDevices = account.ataDevices
|
|
129
|
-
const atwDevices = account.atwDevices
|
|
130
|
-
const ervDevices = account.ervDevices
|
|
128
|
+
const ataDevices = (account.ataDevices || []).filter(device => (device.id ?? '0') !== '0');
|
|
129
|
+
const atwDevices = (account.atwDevices || []).filter(device => (device.id ?? '0') !== '0');
|
|
130
|
+
const ervDevices = (account.ervDevices || []).filter(device => (device.id ?? '0') !== '0');
|
|
131
131
|
const devices = [...ataDevices, ...atwDevices, ...ervDevices];
|
|
132
132
|
if (logLevel.debug) log.info(`Found configured devices ATA: ${ataDevices.length}, ATW: ${atwDevices.length}, ERV: ${ervDevices.length}.`);
|
|
133
133
|
|
|
@@ -135,9 +135,7 @@ class MelCloudPlatform {
|
|
|
135
135
|
//chack device from config exist on melcloud
|
|
136
136
|
const displayType = device.displayType > 0;
|
|
137
137
|
const deviceExistInMelCloud = devicesList.Devices.some(dev => dev.DeviceID === device.id);
|
|
138
|
-
if (!deviceExistInMelCloud || !displayType)
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
138
|
+
if (!deviceExistInMelCloud || !displayType) continue;
|
|
141
139
|
|
|
142
140
|
const deviceName = device.name;
|
|
143
141
|
const deviceType = device.type;
|
|
@@ -157,9 +155,7 @@ class MelCloudPlatform {
|
|
|
157
155
|
if (logLevel.debug) log.debug(`Default temperature file created: ${defaultTempsFile}`);
|
|
158
156
|
}
|
|
159
157
|
} catch (error) {
|
|
160
|
-
if (logLevel.error) {
|
|
161
|
-
log.error(`Device: ${host} ${deviceName}, File init error: ${error.message}`);
|
|
162
|
-
}
|
|
158
|
+
if (logLevel.error) log.error(`Device: ${host} ${deviceName}, File init error: ${error.message}`);
|
|
163
159
|
continue;
|
|
164
160
|
}
|
|
165
161
|
}
|
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.518",
|
|
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
|
@@ -115,11 +115,7 @@ class MelCloud extends EventEmitter {
|
|
|
115
115
|
if (device.DeviceID != null) device.DeviceID = String(device.DeviceID);
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
-
if (this.logDebug) {
|
|
119
|
-
const count = allDevices.length;
|
|
120
|
-
this.emit('debug', `Found ${count} devices in building: ${building.Name || 'Unnamed'}`);
|
|
121
|
-
}
|
|
122
|
-
|
|
118
|
+
if (this.logDebug) this.emit('debug', `Found ${allDevices.length} devices in building: ${building.Name || 'Unnamed'}`);
|
|
123
119
|
devicesList.Devices.push(...allDevices);
|
|
124
120
|
}
|
|
125
121
|
|
|
@@ -187,12 +183,10 @@ class MelCloud extends EventEmitter {
|
|
|
187
183
|
this.contextKey = contextKey;
|
|
188
184
|
|
|
189
185
|
accountInfo.State = true;
|
|
190
|
-
accountInfo.Info = 'Connect
|
|
186
|
+
accountInfo.Info = 'Connect to MELCloud Success';
|
|
191
187
|
accountInfo.LoginData = loginData;
|
|
192
188
|
accountInfo.ContextKey = contextKey;
|
|
193
|
-
|
|
194
189
|
await this.functions.saveData(this.accountFile, accountInfo);
|
|
195
|
-
this.emit('success', `Connect to MELCloud Success`);
|
|
196
190
|
|
|
197
191
|
return accountInfo
|
|
198
192
|
} catch (error) {
|
|
@@ -310,7 +304,7 @@ class MelCloud extends EventEmitter {
|
|
|
310
304
|
}
|
|
311
305
|
}
|
|
312
306
|
|
|
313
|
-
async connectToMelCloudHome(
|
|
307
|
+
async connectToMelCloudHome() {
|
|
314
308
|
if (this.logDebug) this.emit('debug', 'Connecting to MELCloud Home');
|
|
315
309
|
const GLOBAL_TIMEOUT = 45000;
|
|
316
310
|
|
|
@@ -436,14 +430,11 @@ class MelCloud extends EventEmitter {
|
|
|
436
430
|
this.contextKey = contextKey;
|
|
437
431
|
|
|
438
432
|
accountInfo.State = true;
|
|
439
|
-
accountInfo.Info = 'Connect
|
|
433
|
+
accountInfo.Info = 'Connect to MELCloud Home Success';
|
|
440
434
|
accountInfo.ContextKey = contextKey;
|
|
441
|
-
|
|
442
435
|
await this.functions.saveData(this.accountFile, accountInfo);
|
|
443
436
|
|
|
444
|
-
if (!refresh) this.emit('success', 'Connect to MELCloud Home Success');
|
|
445
437
|
return accountInfo;
|
|
446
|
-
|
|
447
438
|
} catch (error) {
|
|
448
439
|
throw new Error(`Connect error: ${error.message}`);
|
|
449
440
|
} finally {
|
|
@@ -454,7 +445,6 @@ class MelCloud extends EventEmitter {
|
|
|
454
445
|
}
|
|
455
446
|
}
|
|
456
447
|
|
|
457
|
-
|
|
458
448
|
async checkDevicesList() {
|
|
459
449
|
const TIMEOUT_MS = 30000; // 30 seconds timeout
|
|
460
450
|
try {
|
|
@@ -478,7 +468,7 @@ class MelCloud extends EventEmitter {
|
|
|
478
468
|
}
|
|
479
469
|
}
|
|
480
470
|
|
|
481
|
-
async connect(
|
|
471
|
+
async connect() {
|
|
482
472
|
const TIMEOUT_MS = 60000;
|
|
483
473
|
|
|
484
474
|
try {
|
|
@@ -488,7 +478,7 @@ class MelCloud extends EventEmitter {
|
|
|
488
478
|
case "melcloud":
|
|
489
479
|
return await this.connectToMelCloud();
|
|
490
480
|
case "melcloudhome":
|
|
491
|
-
return await this.connectToMelCloudHome(
|
|
481
|
+
return await this.connectToMelCloudHome();
|
|
492
482
|
default:
|
|
493
483
|
return {};
|
|
494
484
|
}
|