homebridge-melcloud-control 4.1.2-beta.67 → 4.1.2-beta.69

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,9 +255,9 @@
255
255
  if (d.Type === 3) devicesByType.erv.push(d);
256
256
  });
257
257
 
258
- account.ataDevices ??= [];
259
- account.atwDevices ??= [];
260
- account.ervDevices ??= [];
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, devicesByType.ata);
263
263
  const removedAtw = removeStaleDevices(account.atwDevices, devicesByType.atw);
@@ -265,14 +265,13 @@
265
265
 
266
266
  const handleDevices = (devicesInMelCloud, devicesInConfig, typeString, newArr, newPresets) => {
267
267
  try {
268
- const configDevicesMap = new Map(devicesInConfig.map(dev => [String(dev.id), dev]));
268
+ const configDevicesMap = new Map(devicesInConfig.map(dev => [dev.id, dev]));
269
269
  const isMelcloud = account.type === 'melcloud';
270
270
 
271
271
  const idKey = isMelcloud ? 'ID' : 'Id';
272
272
  const typeKey = isMelcloud ? 'Presets' : 'Schedule';
273
273
  const typeKey1 = isMelcloud ? 'presets' : 'schedules';
274
274
 
275
- let addedNewDevice = false;
276
275
  devicesInMelCloud.forEach(device => {
277
276
  const deviceId = String(device.DeviceID);
278
277
  let deviceInConfig = configDevicesMap.get(deviceId);
@@ -292,27 +291,13 @@
292
291
  devicesInConfig.push(deviceInConfig);
293
292
  newArr.push(deviceInConfig);
294
293
  configDevicesMap.set(deviceId, deviceInConfig);
295
- addedNewDevice = true;
296
- }
297
-
298
- // === Remove placeholder devices (id === '0') if new ones were added ===
299
- if (addedNewDevice) {
300
- const beforeCount = devicesInConfig.length;
301
- deviceInConfig = devicesInConfig.filter(d => String(d.id) !== '0');
302
- const removedCount = beforeCount - deviceInConfig.length;
303
-
304
- if (removedCount > 0 && removedCount < beforeCount) {
305
- updateInfo('info1', `Removed ${removedCount} placeholder from device ${device.DeviceID}`, 'yellow');
306
- }
307
294
  }
308
295
 
309
296
  // === Process presets/schedules ===
310
297
  const presets = device[typeKey] || [];
311
- const presetsInConfig = deviceInConfig[typeKey1] || [];
298
+ const presetsInConfig = (deviceInConfig[typeKey1] || []).filter(p => String(p.id) !== '0');
312
299
  const presetIds = new Set(presetsInConfig.map(p => String(p.id)));
313
300
 
314
- let addedNewPreset = false;
315
-
316
301
  presets.forEach((preset, index) => {
317
302
  const presetId = String(preset[idKey]);
318
303
  if (!presetIds.has(presetId)) {
@@ -325,20 +310,8 @@
325
310
  presetsInConfig.push(presetObj);
326
311
  newPresets.push(presetObj);
327
312
  presetIds.add(presetId);
328
- addedNewPreset = true;
329
313
  }
330
314
  });
331
-
332
- // === Remove placeholder presets/schedules (id === '0') if new ones were added ===
333
- if (addedNewPreset) {
334
- const beforeCount = presetsInConfig.length;
335
- deviceInConfig[typeKey1] = presetsInConfig.filter(p => String(p.id) !== '0');
336
- const removedCount = beforeCount - deviceInConfig[typeKey1].length;
337
-
338
- if (removedCount > 0 && removedCount < beforeCount) {
339
- updateInfo('info2', `Removed ${removedCount} placeholder ${typeKey1} from device ${device.DeviceID}`, 'yellow');
340
- }
341
- }
342
315
  });
343
316
 
344
317
  // Return filtered devicesInConfig to make sure upstream code uses it
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.1.2-beta.67",
4
+ "version": "4.1.2-beta.69",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",