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

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.
@@ -272,7 +272,6 @@
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,17 +291,16 @@
292
291
  devicesInConfig.push(deviceInConfig);
293
292
  newArr.push(deviceInConfig);
294
293
  configDevicesMap.set(deviceId, deviceInConfig);
295
- addedNewDevice = true;
296
294
  }
297
295
 
298
296
  // === Remove placeholder devices (id === '0') if new ones were added ===
299
- if (addedNewDevice) {
297
+ if (devicesInConfig.length > 1 && devicesInConfig.some(d => String(d.id) === '0')) {
300
298
  const beforeCount = devicesInConfig.length;
301
299
  deviceInConfig = devicesInConfig.filter(d => String(d.id) !== '0');
302
300
  const removedCount = beforeCount - deviceInConfig.length;
303
301
 
304
302
  if (removedCount > 0 && removedCount < beforeCount) {
305
- updateInfo('info1', `Removed ${removedCount} placeholder from device ${device.DeviceID}`, 'yellow');
303
+ updateInfo('info1', `Removed ${removedCount} ${typeString} with id === 0 from config`, 'yellow');
306
304
  }
307
305
  }
308
306
 
@@ -311,8 +309,6 @@
311
309
  const presetsInConfig = deviceInConfig[typeKey1] || [];
312
310
  const presetIds = new Set(presetsInConfig.map(p => String(p.id)));
313
311
 
314
- let addedNewPreset = false;
315
-
316
312
  presets.forEach((preset, index) => {
317
313
  const presetId = String(preset[idKey]);
318
314
  if (!presetIds.has(presetId)) {
@@ -325,18 +321,17 @@
325
321
  presetsInConfig.push(presetObj);
326
322
  newPresets.push(presetObj);
327
323
  presetIds.add(presetId);
328
- addedNewPreset = true;
329
324
  }
330
325
  });
331
326
 
332
327
  // === Remove placeholder presets/schedules (id === '0') if new ones were added ===
333
- if (addedNewPreset) {
328
+ if (presetsInConfig.length > 1 && presetsInConfig.some(p => String(p.id) === '0')) {
334
329
  const beforeCount = presetsInConfig.length;
335
330
  deviceInConfig[typeKey1] = presetsInConfig.filter(p => String(p.id) !== '0');
336
331
  const removedCount = beforeCount - deviceInConfig[typeKey1].length;
337
332
 
338
333
  if (removedCount > 0 && removedCount < beforeCount) {
339
- updateInfo('info2', `Removed ${removedCount} placeholder ${typeKey1} from device ${device.DeviceID}`, 'yellow');
334
+ updateInfo('info2', `Removed ${removedCount} ${typeKey1} with id === 0 from ${typeString} id: ${device.DeviceID}`, 'yellow');
340
335
  }
341
336
  }
342
337
  });
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.68",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",