homebridge-melcloud-control 4.1.2-beta.45 → 4.1.2-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.
@@ -266,6 +266,17 @@
266
266
  const deviceId = String(device.DeviceID);
267
267
  let deviceInConfig = configDevicesMap.get(deviceId);
268
268
 
269
+ // === Remove placeholder devices with id '0' before adding new ===
270
+ const beforeDevicesCount = devicesInConfig.length;
271
+ devicesInConfig = devicesInConfig.filter(d => String(d.id) !== '0');
272
+ if (devicesInConfig.length !== beforeDevicesCount) {
273
+ updateInfo('info2', `Removed placeholder devices with id '0'`, 'yellow');
274
+
275
+ // Rebuild map after filtering
276
+ configDevicesMap.clear();
277
+ devicesInConfig.forEach(dev => configDevicesMap.set(String(dev.id), dev));
278
+ }
279
+
269
280
  // === Create device if missing ===
270
281
  if (!deviceInConfig) {
271
282
  deviceInConfig = {
@@ -313,16 +324,19 @@
313
324
  const removedCount = beforeCount - deviceInConfig[typeKey1].length;
314
325
 
315
326
  if (removedCount > 0 && removedCount < beforeCount) {
316
- updateInfo('info', `Removed ${removedCount} placeholder ${typeKey1} from device ${device.DeviceID}`, 'yellow');
327
+ updateInfo('info2', `Removed ${removedCount} placeholder ${typeKey1} from device ${device.DeviceID}`, 'yellow');
317
328
  }
318
329
  }
319
330
  });
331
+
332
+ // Return filtered devicesInConfig to make sure upstream code uses it
333
+ return devicesInConfig;
334
+
320
335
  } catch (error) {
321
- updateInfo('info', `Error while processing device: ${error.message || error}`, 'red');
336
+ updateInfo('info', `Error while processing device: ${JSON.stringify(error)}`, 'red');
322
337
  }
323
338
  };
324
339
 
325
-
326
340
  handleDevices(devicesByType.ata, account.ataDevices, "Air Conditioner", newDevices.ata, newDevices.ataPresets);
327
341
  handleDevices(devicesByType.atw, account.atwDevices, "Heat Pump", newDevices.atw, newDevices.atwPresets);
328
342
  handleDevices(devicesByType.erv, account.ervDevices, "Energy Recovery Ventilation", newDevices.erv, newDevices.ervPresets);
@@ -347,8 +361,7 @@
347
361
  document.getElementById('logIn').className = "btn btn-secondary";
348
362
 
349
363
  } catch (error) {
350
- updateInfo('info', 'Connect error.', 'yellow');
351
- updateInfo('info1', `${JSON.stringify(error)}`, 'red');
364
+ updateInfo('info', `Connect error ${JSON.stringify(error)}`, 'red');
352
365
  document.getElementById('logIn').className = "btn btn-secondary";
353
366
  } finally {
354
367
  homebridge.hideSpinner();
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.45",
4
+ "version": "4.1.2-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",