homebridge-melcloud-control 4.2.3-beta.45 → 4.2.3-beta.46
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.
|
@@ -246,10 +246,11 @@
|
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
// Initialize devices arrays
|
|
249
|
-
const newDevices = { ata: [], ataPresets: [], atw: [], atwPresets: [], erv: [], ervPresets: [] };
|
|
249
|
+
const newDevices = { ata: [], ataPresets: [], atw: [], atwPresets: [], erv: [], ervPresets: [], scenes: [] };
|
|
250
250
|
const devicesByType = { ata: [], atw: [], erv: [] };
|
|
251
251
|
|
|
252
252
|
response.Devices.forEach(d => {
|
|
253
|
+
d.Scenes = response.Scenes ?? [];
|
|
253
254
|
if (d.Type === 0) devicesByType.ata.push(d);
|
|
254
255
|
if (d.Type === 1) devicesByType.atw.push(d);
|
|
255
256
|
if (d.Type === 3) devicesByType.erv.push(d);
|
|
@@ -263,7 +264,7 @@
|
|
|
263
264
|
const removedAtw = removeStaleDevices(account.atwDevices, devicesByType.atw);
|
|
264
265
|
const removedErv = removeStaleDevices(account.ervDevices, devicesByType.erv);
|
|
265
266
|
|
|
266
|
-
const handleDevices = (devicesInMelCloud, devicesInConfig, typeString, newArr, newPresets) => {
|
|
267
|
+
const handleDevices = (devicesInMelCloud, devicesInConfig, typeString, newArr, newPresets, newScenes) => {
|
|
267
268
|
try {
|
|
268
269
|
const configDevicesMap = new Map(devicesInConfig.map(dev => [String(dev.id), dev]));
|
|
269
270
|
const isMelcloud = account.type === 'melcloud';
|
|
@@ -286,6 +287,7 @@
|
|
|
286
287
|
name: device.DeviceName,
|
|
287
288
|
presets: [],
|
|
288
289
|
schedules: [],
|
|
290
|
+
scenes: [],
|
|
289
291
|
buttonsSensors: []
|
|
290
292
|
};
|
|
291
293
|
devicesInConfig.push(deviceInConfig);
|
|
@@ -326,6 +328,41 @@
|
|
|
326
328
|
updateInfo('info2', `Removed ${removedCount} placeholder ${typeKey1} from device ${device.DeviceID}`, 'yellow');
|
|
327
329
|
}
|
|
328
330
|
}
|
|
331
|
+
|
|
332
|
+
// === Process scenes ===
|
|
333
|
+
const scenes = device.Scenes || [];
|
|
334
|
+
const scenesInConfig = deviceInConfig.Scenes || [];
|
|
335
|
+
const scenesIds = new Set(scenesInConfig.map(s => String(s.id)));
|
|
336
|
+
|
|
337
|
+
let addedNewScenes = false;
|
|
338
|
+
|
|
339
|
+
scenes.forEach((scene, index) => {
|
|
340
|
+
const sceneId = String(scene.id);
|
|
341
|
+
if (!scenesIds.has(sceneId)) {
|
|
342
|
+
const sceneObj = {
|
|
343
|
+
id: sceneId,
|
|
344
|
+
displayType: 0,
|
|
345
|
+
name: scene.Name || `Scene ${index}`,
|
|
346
|
+
namePrefix: false
|
|
347
|
+
};
|
|
348
|
+
scenesInConfig.push(sceneObj);
|
|
349
|
+
newScenes.push(sceneObj);
|
|
350
|
+
scenesIds.add(sceneObj);
|
|
351
|
+
addedNewScenes = true;
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// === Remove placeholder scenes (id === '0') if new ones were added ===
|
|
356
|
+
if (addedNewScenes) {
|
|
357
|
+
const beforeCount = scenesInConfig.length;
|
|
358
|
+
deviceInConfig.Scenes = scenesInConfig.filter(s => String(s.id) !== '0');
|
|
359
|
+
const removedCount = beforeCount - deviceInConfig.Scenes.length;
|
|
360
|
+
|
|
361
|
+
if (removedCount > 0 && removedCount < beforeCount) {
|
|
362
|
+
updateInfo('info2', `Removed ${removedCount} placeholder scene from device ${device.DeviceID}`, 'yellow');
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
329
366
|
});
|
|
330
367
|
|
|
331
368
|
// Return filtered devicesInConfig to make sure upstream code uses it
|
|
@@ -336,12 +373,13 @@
|
|
|
336
373
|
}
|
|
337
374
|
};
|
|
338
375
|
|
|
339
|
-
account.ataDevices = handleDevices(devicesByType.ata, account.ataDevices, "Air Conditioner", newDevices.ata, newDevices.ataPresets);
|
|
340
|
-
account.atwDevices = handleDevices(devicesByType.atw, account.atwDevices, "Heat Pump", newDevices.atw, newDevices.atwPresets);
|
|
341
|
-
account.ervDevices = handleDevices(devicesByType.erv, account.ervDevices, "Energy Recovery Ventilation", newDevices.erv, newDevices.ervPresets);
|
|
376
|
+
account.ataDevices = handleDevices(devicesByType.ata, account.ataDevices, "Air Conditioner", newDevices.ata, newDevices.ataPresets, newDevices.scenes);
|
|
377
|
+
account.atwDevices = handleDevices(devicesByType.atw, account.atwDevices, "Heat Pump", newDevices.atw, newDevices.atwPresets, newDevices.scenes);
|
|
378
|
+
account.ervDevices = handleDevices(devicesByType.erv, account.ervDevices, "Energy Recovery Ventilation", newDevices.erv, newDevices.ervPresets, newDevices.scenes);
|
|
342
379
|
|
|
343
380
|
const newDevicesCount = newDevices.ata.length + newDevices.atw.length + newDevices.erv.length;
|
|
344
381
|
const newPresetsCount = newDevices.ataPresets.length + newDevices.atwPresets.length + newDevices.ervPresets.length;
|
|
382
|
+
const newScenesCount = newDevices.scenes.length;
|
|
345
383
|
const removedDevicesCount = removedAta.length + removedAtw.length + removedErv.length;
|
|
346
384
|
|
|
347
385
|
if (!newDevicesCount && !newPresetsCount && !removedDevicesCount) {
|
|
@@ -349,8 +387,8 @@
|
|
|
349
387
|
} else {
|
|
350
388
|
if (newDevicesCount)
|
|
351
389
|
updateInfo('info', `Found new devices: ATA: ${newDevices.ata.length}, ATW: ${newDevices.atw.length}, ERV: ${newDevices.erv.length}.`, 'green');
|
|
352
|
-
if (newPresetsCount)
|
|
353
|
-
updateInfo('info1', `Found new ${account.type === 'melcloud' ? 'presets' : 'schedules'}: ATA: ${newDevices.ataPresets.length}, ATW: ${newDevices.atwPresets.length}, ERV: ${newDevices.ervPresets.length}.`, 'green');
|
|
390
|
+
if (newPresetsCount || newScenesCount)
|
|
391
|
+
updateInfo('info1', `Found new ${account.type === 'melcloud' ? 'presets' : 'schedules'}: ATA: ${newDevices.ataPresets.length}, ATW: ${newDevices.atwPresets.length}, ERV: ${newDevices.ervPresets.length}, Scenes: ${newDevices.scenes.length}.`, 'green');
|
|
354
392
|
if (removedDevicesCount)
|
|
355
393
|
updateInfo('info2', `Removed devices: ATA: ${removedAta.length}, ATW: ${removedAtw.length}, ERV: ${removedErv.length}.`, 'orange');
|
|
356
394
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.2.3-beta.
|
|
4
|
+
"version": "4.2.3-beta.46",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|