homebridge-melcloud-control 4.3.9-beta.5 → 4.3.9-beta.6
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.
|
@@ -255,15 +255,15 @@
|
|
|
255
255
|
if (device.Type === 3) devicesInMelCloudByType.erv.push(device);
|
|
256
256
|
});
|
|
257
257
|
|
|
258
|
-
account.ataDevices = (account.ataDevices ?? []).filter(d => String(d.id) !==
|
|
259
|
-
account.atwDevices = (account.atwDevices ?? []).filter(d => String(d.id) !==
|
|
260
|
-
account.ervDevices = (account.ervDevices ?? []).filter(d => String(d.id) !==
|
|
258
|
+
account.ataDevices = (account.ataDevices ?? []).filter(d => String(d.id) !== '0');
|
|
259
|
+
account.atwDevices = (account.atwDevices ?? []).filter(d => String(d.id) !== '0');
|
|
260
|
+
account.ervDevices = (account.ervDevices ?? []).filter(d => String(d.id) !== '0');
|
|
261
261
|
|
|
262
262
|
const removedAta = removeStaleDevices(account.ataDevices, devicesInMelCloudByType.ata);
|
|
263
263
|
const removedAtw = removeStaleDevices(account.atwDevices, devicesInMelCloudByType.atw);
|
|
264
264
|
const removedErv = removeStaleDevices(account.ervDevices, devicesInMelCloudByType.erv);
|
|
265
265
|
|
|
266
|
-
const handleDevices = (devicesInMelCloud, devicesInConfig,
|
|
266
|
+
const handleDevices = (devicesInMelCloud, devicesInConfig, deviceTypeString, newDevices, newPresets, newSchedules, newScenes) => {
|
|
267
267
|
try {
|
|
268
268
|
const configDevicesMap = new Map(devicesInConfig.map(dev => [String(dev.id), dev]));
|
|
269
269
|
|
|
@@ -276,7 +276,7 @@
|
|
|
276
276
|
deviceInConfig = {
|
|
277
277
|
id: deviceId,
|
|
278
278
|
type: device.Type,
|
|
279
|
-
|
|
279
|
+
deviceTypeString,
|
|
280
280
|
displayType: 0,
|
|
281
281
|
name: device.DeviceName
|
|
282
282
|
};
|
|
@@ -290,10 +290,9 @@
|
|
|
290
290
|
|
|
291
291
|
// === Process presets ===
|
|
292
292
|
const presetsInMelCloud = device.Presets || [];
|
|
293
|
-
const presetsInConfig = (deviceInConfig.presets ?? []).filter(p => String(p.id) !==
|
|
293
|
+
const presetsInConfig = (deviceInConfig.presets ?? []).filter(p => String(p.id) !== '0');
|
|
294
294
|
const presetIds = new Set(presetsInConfig.map(p => String(p.id)));
|
|
295
295
|
|
|
296
|
-
let addedNewPreset = false;
|
|
297
296
|
presetsInMelCloud.forEach((preset, index) => {
|
|
298
297
|
const presetId = String(preset.ID);
|
|
299
298
|
if (!presetIds.has(presetId)) {
|
|
@@ -306,20 +305,8 @@
|
|
|
306
305
|
presetsInConfig.push(presetObj);
|
|
307
306
|
newPresets.push(presetObj);
|
|
308
307
|
presetIds.add(presetId);
|
|
309
|
-
addedNewPreset = true;
|
|
310
308
|
}
|
|
311
309
|
});
|
|
312
|
-
|
|
313
|
-
// === Remove placeholder presets/schedules (id === '0') if new ones were added ===
|
|
314
|
-
if (addedNewPreset) {
|
|
315
|
-
const beforeCount = presetsInConfig.length;
|
|
316
|
-
deviceInConfig.presets = presetsInConfig;
|
|
317
|
-
const removedCount = beforeCount - deviceInConfig.presets.length;
|
|
318
|
-
|
|
319
|
-
if (removedCount > 0 && removedCount < beforeCount) {
|
|
320
|
-
updateInfo('info2', `Removed ${removedCount} placeholder preset from device ${device.DeviceID}`, 'yellow');
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
310
|
}
|
|
324
311
|
|
|
325
312
|
//only for melcloudhome
|
|
@@ -327,10 +314,9 @@
|
|
|
327
314
|
|
|
328
315
|
// === Process schedules ===
|
|
329
316
|
const schedulesInMelCloud = device.Schedule || [];
|
|
330
|
-
const schedulesInConfig = (deviceInConfig.schedules ?? []).filter(s => String(s.id) !==
|
|
317
|
+
const schedulesInConfig = (deviceInConfig.schedules ?? []).filter(s => String(s.id) !== '0');
|
|
331
318
|
const scheduleIds = new Set(schedulesInConfig.map(s => String(s.id)));
|
|
332
319
|
|
|
333
|
-
let addedNewSchedule = false;
|
|
334
320
|
schedulesInMelCloud.forEach((schedule, index) => {
|
|
335
321
|
const scheduleId = String(schedule.Id);
|
|
336
322
|
if (!scheduleIds.has(scheduleId)) {
|
|
@@ -343,26 +329,13 @@
|
|
|
343
329
|
schedulesInConfig.push(scheduleObj);
|
|
344
330
|
newSchedules.push(scheduleObj);
|
|
345
331
|
scheduleIds.add(scheduleId);
|
|
346
|
-
addedNewSchedule = true;
|
|
347
332
|
}
|
|
348
333
|
});
|
|
349
334
|
|
|
350
|
-
// === Remove placeholder schedules (id === '0') if new ones were added ===
|
|
351
|
-
if (addedNewSchedule) {
|
|
352
|
-
const beforeCount = schedulesInConfig.length;
|
|
353
|
-
deviceInConfig.schedules = schedulesInConfig;
|
|
354
|
-
const removedCount = beforeCount - deviceInConfig.schedules.length;
|
|
355
|
-
|
|
356
|
-
if (removedCount > 0 && removedCount < beforeCount) {
|
|
357
|
-
updateInfo('info2', `Removed ${removedCount} placeholder schedule from device ${device.DeviceID}`, 'yellow');
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
335
|
// === Process scenes ===
|
|
362
|
-
const scenesInConfig = (deviceInConfig.scenes ?? []).filter(s => String(s.id) !==
|
|
336
|
+
const scenesInConfig = (deviceInConfig.scenes ?? []).filter(s => String(s.id) !== '0');
|
|
363
337
|
const sceneIds = new Set(scenesInConfig.map(s => String(s.id)));
|
|
364
338
|
|
|
365
|
-
let addedNewScenes = false;
|
|
366
339
|
scenesInMelCloud.forEach((scene, index) => {
|
|
367
340
|
const sceneId = String(scene.Id);
|
|
368
341
|
if (!sceneIds.has(sceneId)) {
|
|
@@ -375,20 +348,8 @@
|
|
|
375
348
|
scenesInConfig.push(sceneObj);
|
|
376
349
|
newScenes.push(sceneObj);
|
|
377
350
|
sceneIds.add(sceneId);
|
|
378
|
-
addedNewScenes = true;
|
|
379
351
|
}
|
|
380
352
|
});
|
|
381
|
-
|
|
382
|
-
// === Remove placeholder scenes (id === '0') if new ones were added ===
|
|
383
|
-
if (addedNewScenes) {
|
|
384
|
-
const beforeCount = scenesInConfig.length;
|
|
385
|
-
deviceInConfig.scenes = scenesInConfig;
|
|
386
|
-
const removedCount = beforeCount - deviceInConfig.scenes.length;
|
|
387
|
-
|
|
388
|
-
if (removedCount > 0 && removedCount < beforeCount) {
|
|
389
|
-
updateInfo('info2', `Removed ${removedCount} placeholder scene from device ${device.DeviceID}`, 'yellow');
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
353
|
}
|
|
393
354
|
});
|
|
394
355
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.3.9-beta.
|
|
4
|
+
"version": "4.3.9-beta.6",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|