homebridge-melcloud-control 4.3.9-beta.4 → 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.
@@ -211,7 +211,7 @@
211
211
 
212
212
  for (let i = configDevices.length - 1; i >= 0; i--) {
213
213
  const device = configDevices[i];
214
- if (device.id !== "0" && !melcloudIds.includes(device.id)) {
214
+ if (!melcloudIds.includes(device.id)) {
215
215
  removedDevices.push(device);
216
216
  configDevices.splice(i, 1);
217
217
  }
@@ -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) !== "0");
259
- account.atwDevices = account.atwDevices.filter(d => String(d.id) !== "0");
260
- account.ervDevices = account.ervDevices.filter(d => String(d.id) !== "0");
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, typeString, newDevices, newPresets, newSchedules, newScenes) => {
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,13 +276,9 @@
276
276
  deviceInConfig = {
277
277
  id: deviceId,
278
278
  type: device.Type,
279
- typeString,
279
+ deviceTypeString,
280
280
  displayType: 0,
281
- name: device.DeviceName,
282
- presets: [],
283
- schedules: [],
284
- scenes: [],
285
- buttonsSensors: []
281
+ name: device.DeviceName
286
282
  };
287
283
  devicesInConfig.push(deviceInConfig);
288
284
  newDevices.push(deviceInConfig);
@@ -294,10 +290,9 @@
294
290
 
295
291
  // === Process presets ===
296
292
  const presetsInMelCloud = device.Presets || [];
297
- const presetsInConfig = (deviceInConfig.presets ?? []).filter(p => String(p.id) !== "0");
293
+ const presetsInConfig = (deviceInConfig.presets ?? []).filter(p => String(p.id) !== '0');
298
294
  const presetIds = new Set(presetsInConfig.map(p => String(p.id)));
299
295
 
300
- let addedNewPreset = false;
301
296
  presetsInMelCloud.forEach((preset, index) => {
302
297
  const presetId = String(preset.ID);
303
298
  if (!presetIds.has(presetId)) {
@@ -310,20 +305,8 @@
310
305
  presetsInConfig.push(presetObj);
311
306
  newPresets.push(presetObj);
312
307
  presetIds.add(presetId);
313
- addedNewPreset = true;
314
308
  }
315
309
  });
316
-
317
- // === Remove placeholder presets/schedules (id === '0') if new ones were added ===
318
- if (addedNewPreset) {
319
- const beforeCount = presetsInConfig.length;
320
- deviceInConfig.presets = presetsInConfig;
321
- const removedCount = beforeCount - deviceInConfig.presets.length;
322
-
323
- if (removedCount > 0 && removedCount < beforeCount) {
324
- updateInfo('info2', `Removed ${removedCount} placeholder preset from device ${device.DeviceID}`, 'yellow');
325
- }
326
- }
327
310
  }
328
311
 
329
312
  //only for melcloudhome
@@ -331,10 +314,9 @@
331
314
 
332
315
  // === Process schedules ===
333
316
  const schedulesInMelCloud = device.Schedule || [];
334
- const schedulesInConfig = (deviceInConfig.schedules ?? []).filter(s => String(s.id) !== "0");
317
+ const schedulesInConfig = (deviceInConfig.schedules ?? []).filter(s => String(s.id) !== '0');
335
318
  const scheduleIds = new Set(schedulesInConfig.map(s => String(s.id)));
336
319
 
337
- let addedNewSchedule = false;
338
320
  schedulesInMelCloud.forEach((schedule, index) => {
339
321
  const scheduleId = String(schedule.Id);
340
322
  if (!scheduleIds.has(scheduleId)) {
@@ -347,26 +329,13 @@
347
329
  schedulesInConfig.push(scheduleObj);
348
330
  newSchedules.push(scheduleObj);
349
331
  scheduleIds.add(scheduleId);
350
- addedNewSchedule = true;
351
332
  }
352
333
  });
353
334
 
354
- // === Remove placeholder schedules (id === '0') if new ones were added ===
355
- if (addedNewSchedule) {
356
- const beforeCount = schedulesInConfig.length;
357
- deviceInConfig.schedules = schedulesInConfig;
358
- const removedCount = beforeCount - deviceInConfig.schedules.length;
359
-
360
- if (removedCount > 0 && removedCount < beforeCount) {
361
- updateInfo('info2', `Removed ${removedCount} placeholder schedule from device ${device.DeviceID}`, 'yellow');
362
- }
363
- }
364
-
365
335
  // === Process scenes ===
366
- const scenesInConfig = (deviceInConfig.scenes ?? []).filter(s => String(s.id) !== "0");
336
+ const scenesInConfig = (deviceInConfig.scenes ?? []).filter(s => String(s.id) !== '0');
367
337
  const sceneIds = new Set(scenesInConfig.map(s => String(s.id)));
368
338
 
369
- let addedNewScenes = false;
370
339
  scenesInMelCloud.forEach((scene, index) => {
371
340
  const sceneId = String(scene.Id);
372
341
  if (!sceneIds.has(sceneId)) {
@@ -379,20 +348,8 @@
379
348
  scenesInConfig.push(sceneObj);
380
349
  newScenes.push(sceneObj);
381
350
  sceneIds.add(sceneId);
382
- addedNewScenes = true;
383
351
  }
384
352
  });
385
-
386
- // === Remove placeholder scenes (id === '0') if new ones were added ===
387
- if (addedNewScenes) {
388
- const beforeCount = scenesInConfig.length;
389
- deviceInConfig.scenes = scenesInConfig;
390
- const removedCount = beforeCount - deviceInConfig.scenes.length;
391
-
392
- if (removedCount > 0 && removedCount < beforeCount) {
393
- updateInfo('info2', `Removed ${removedCount} placeholder scene from device ${device.DeviceID}`, 'yellow');
394
- }
395
- }
396
353
  }
397
354
  });
398
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",
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",