homebridge-melcloud-control 3.1.2 → 3.1.3-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.
- package/homebridge-ui/public/index.html +45 -3
- package/index.js +9 -3
- package/package.json +1 -1
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
};
|
|
188
188
|
|
|
189
189
|
//get device info fom devices ata
|
|
190
|
-
devicesByType.ata.forEach((device, index) => {
|
|
190
|
+
devicesByType.ata.forEach(async (device, index) => {
|
|
191
191
|
const deviceId = device.DeviceID;
|
|
192
192
|
const deviceType = device.Type;
|
|
193
193
|
const deviceTypeText = "Air Conditioner";
|
|
@@ -212,6 +212,7 @@
|
|
|
212
212
|
|
|
213
213
|
const ataDevicesExist = pluginConfig[0].accounts[this.deviceIndex].ataDevices ?? false;
|
|
214
214
|
const ataDevices = ataDevicesExist ? pluginConfig[0].accounts[this.deviceIndex].ataDevices : pluginConfig[0].accounts[this.deviceIndex].ataDevices = [];
|
|
215
|
+
|
|
215
216
|
const ataDeviceIdExist = ataDevices.some(device => device.id === deviceId);
|
|
216
217
|
const pushTypeAta = ataDeviceIdExist ? false : ataDevices.push(deviceAta);
|
|
217
218
|
const pushNewDevice = ataDeviceIdExist ? false : newDevices.ata.push(device);
|
|
@@ -236,10 +237,15 @@
|
|
|
236
237
|
const presetsCount = newDevices.ataPresets.length;
|
|
237
238
|
textAtaPresets = `ATA Presets: ${presetsCount}`
|
|
238
239
|
};
|
|
240
|
+
|
|
241
|
+
//compare presets
|
|
242
|
+
const presetsOnMelCloud = devicePresets;
|
|
243
|
+
const presetsAtaInConfig = pluginConfig[0].accounts[this.deviceIndex].ataDevices[index].presets;
|
|
244
|
+
presetsAtaInConfig = syncArrays(presetsOnMelCloud, presetsAtaInConfig);
|
|
239
245
|
});
|
|
240
246
|
|
|
241
247
|
//get device info fom devices atw
|
|
242
|
-
devicesByType.atw.forEach((device, index) => {
|
|
248
|
+
devicesByType.atw.forEach(async (device, index) => {
|
|
243
249
|
const deviceId = device.DeviceID;
|
|
244
250
|
const deviceType = device.Type;
|
|
245
251
|
const deviceTypeText = "Heat Pump";
|
|
@@ -293,10 +299,14 @@
|
|
|
293
299
|
const presetsCount = newDevices.atwPresets.length;
|
|
294
300
|
textAtwPresets = `ATW Presets: ${presetsCount}`
|
|
295
301
|
};
|
|
302
|
+
|
|
303
|
+
const presetsOnMelCloud = devicePresets;
|
|
304
|
+
const presetsAtwInConfig = pluginConfig[0].accounts[this.deviceIndex].atwDevices[index].presets;
|
|
305
|
+
presetsAtwInConfig = syncArrays(presetsOnMelCloud, presetsAtwInConfig);
|
|
296
306
|
});
|
|
297
307
|
|
|
298
308
|
//get device info fom devices erv
|
|
299
|
-
devicesByType.erv.forEach((device, index) => {
|
|
309
|
+
devicesByType.erv.forEach(async (device, index) => {
|
|
300
310
|
const deviceId = device.DeviceID;
|
|
301
311
|
const deviceType = device.Type;
|
|
302
312
|
const deviceTypeText = "Energy Recovery Ventilation";
|
|
@@ -344,8 +354,23 @@
|
|
|
344
354
|
const presetsCount = newDevices.ervPresets.length;
|
|
345
355
|
textErvPresets = `ERV Presets: ${presetsCount}`
|
|
346
356
|
};
|
|
357
|
+
|
|
358
|
+
const presetsOnMelCloud = devicePresets;
|
|
359
|
+
const presetsErvInConfig = pluginConfig[0].accounts[this.deviceIndex].ervDevices[index].presets;
|
|
360
|
+
presetsErvInConfig = await syncArrays(presetsOnMelCloud, presetsErvInConfig);
|
|
347
361
|
});
|
|
348
362
|
|
|
363
|
+
//compare arrays and update array in config
|
|
364
|
+
const devicesOnMelCloud = devices;
|
|
365
|
+
const devicesAtaInConfig = pluginConfig[0].accounts[this.deviceIndex].ataDevices;
|
|
366
|
+
devicesAtaInConfig = await syncArrays(devicesOnMelCloud, devicesAtaInConfig);
|
|
367
|
+
|
|
368
|
+
const devicesAtwInConfig = pluginConfig[0].accounts[this.deviceIndex].atwDevices;
|
|
369
|
+
devicesAtwInConfig = await syncArrays(devicesOnMelCloud, devicesAtwInConfig);
|
|
370
|
+
|
|
371
|
+
const devicesErvInConfig = pluginConfig[0].accounts[this.deviceIndex].ervDevices;
|
|
372
|
+
devicesErvInConfig = await syncArrays(devicesOnMelCloud, devicesErvInConfig);
|
|
373
|
+
|
|
349
374
|
const newDevicesCount = newDevices.ata.length + newDevices.atw.length + newDevices.erv.length ?? 0;
|
|
350
375
|
const newPresetsCount = newDevices.ataPresets.length + newDevices.atwPresets.length + newDevices.ervPresets.length ?? 0;
|
|
351
376
|
if (newDevicesCount === 0 && newPresetsCount === 0) {
|
|
@@ -389,6 +414,23 @@
|
|
|
389
414
|
break;
|
|
390
415
|
};
|
|
391
416
|
|
|
417
|
+
async function syncArrays(devicesOnMelCloud, devicesInConfig) {
|
|
418
|
+
// Create a Set of IDs from devicesOnMelCloud for quick lookup
|
|
419
|
+
const devicesOnMelCloudId = new Set(devicesOnMelCloud.map(device => device.DeviceID));
|
|
420
|
+
|
|
421
|
+
// Filter devicesInConfig to keep only objects that exist in devicesOnMelCloud
|
|
422
|
+
devicesInConfig = devicesInConfig.filter(device => devicesOnMelCloudId.has(device.DeviceID));
|
|
423
|
+
|
|
424
|
+
// Add objects from devicesOnMelCloud to devicesInConfig that do not exist in devicesInConfig
|
|
425
|
+
devicesOnMelCloud.forEach(device => {
|
|
426
|
+
if (!devicesInConfig.some(item => item.id === device.id)) {
|
|
427
|
+
devicesInConfig.push(device);
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
return devicesInConfig;
|
|
432
|
+
}
|
|
433
|
+
|
|
392
434
|
homebridge.hideSpinner();
|
|
393
435
|
} catch (e) {
|
|
394
436
|
document.getElementById('info').innerHTML = 'Please try again.';
|
package/index.js
CHANGED
|
@@ -105,7 +105,9 @@ class MelCloudPlatform {
|
|
|
105
105
|
|
|
106
106
|
//Air Conditioner
|
|
107
107
|
for (const device of account.ataDevices) {
|
|
108
|
-
|
|
108
|
+
//chack device from config exist on melcloud
|
|
109
|
+
const deviceExistInMelCloud = devices.some(dev => dev.DeviceID === device.id);
|
|
110
|
+
if (!deviceExistInMelCloud || device.displayMode === 0) {
|
|
109
111
|
continue;
|
|
110
112
|
};
|
|
111
113
|
|
|
@@ -142,7 +144,9 @@ class MelCloudPlatform {
|
|
|
142
144
|
|
|
143
145
|
//Heat Pump
|
|
144
146
|
for (const device of account.atwDevices) {
|
|
145
|
-
|
|
147
|
+
//chack device from config exist on melcloud
|
|
148
|
+
const deviceExistInMelCloud = devices.some(dev => dev.DeviceID === device.id);
|
|
149
|
+
if (!deviceExistInMelCloud || device.displayMode === 0) {
|
|
146
150
|
continue;
|
|
147
151
|
};
|
|
148
152
|
|
|
@@ -180,7 +184,9 @@ class MelCloudPlatform {
|
|
|
180
184
|
|
|
181
185
|
//Energy Recovery Ventilation
|
|
182
186
|
for (const device of account.ervDevices) {
|
|
183
|
-
|
|
187
|
+
//chack device from config exist on melcloud
|
|
188
|
+
const deviceExistInMelCloud = devices.some(dev => dev.DeviceID === device.id);
|
|
189
|
+
if (!deviceExistInMelCloud || device.displayMode === 0) {
|
|
184
190
|
continue;
|
|
185
191
|
};
|
|
186
192
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.3-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",
|