homebridge-melcloud-control 4.7.3-beta.8 → 4.7.3-beta.9

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.
@@ -117,6 +117,8 @@
117
117
 
118
118
  // Tworzenie przycisków
119
119
  accounts.forEach((account, i) => {
120
+ this.account = account;
121
+
120
122
  const button = document.createElement("button");
121
123
  button.type = "button";
122
124
  button.id = `button${i}`;
@@ -233,11 +235,20 @@
233
235
  return map;
234
236
  }
235
237
 
238
+ // Helper to generate summary string
239
+ function summarizeChanges(type, ata, atw, erv) {
240
+ const parts = [];
241
+ if (ata.length) parts.push(`ATA: ${ata.length}`);
242
+ if (atw.length) parts.push(`ATW: ${atw.length}`);
243
+ if (erv.length) parts.push(`ERV: ${erv.length}`);
244
+ return parts.length ? `${type}: ${parts.join(', ')}` : '';
245
+ }
246
+
236
247
  // Login & Sync Logic
237
248
  document.getElementById('logIn').addEventListener('click', async () => {
238
249
  document.getElementById('logIn').disabled = true;
239
250
  const lightingMode = homebridge.userCurrentLightingMode();
240
- const fontColor = lightingMode === 'dark' ? 'white' : 'black';
251
+ const fontColor = lightingMode === 'dark' ? 'black' : 'white';
241
252
 
242
253
  updateInfo('info', 'Connecting to MELCloud', fontColor);
243
254
  updateInfo('info1', '', fontColor);
@@ -402,16 +413,23 @@
402
413
  const removedPresetsCount = removedFromConfig.presets.length;
403
414
  const removedSchedulesCount = removedFromConfig.schedules.length;
404
415
  const removedScenesCount = removedFromConfig.scenes.length;
405
-
406
- if (!newDevicesCount && !newPresetsCount && !newSchedulesCount && !newScenesCount && !removedDevicesCount && !removedPresetsCount && !removedSchedulesCount && !removedScenesCount) {
407
- updateInfo('info', 'No changes detected.', fontColor);
408
- }
409
- if (newDevicesCount || newPresetsCount || newSchedulesCount || newScenesCount) {
410
- updateInfo('info', `Found new ${newDevicesCount ? `devices:` : ''} ${newInMelCloud.ata.length ? `ATA: ${newInMelCloud.ata.length},` : ''} ${newInMelCloud.atw.length ? `ATW: ${newInMelCloud.atw.length},` : ''} ${newInMelCloud.erv.length ? `ERV: ${newInMelCloud.erv.length},` : ''} ${newPresetsCount ? `presets:` : ''} ${newInMelCloud.ataPresets.length ? `ATA: ${newInMelCloud.ataPresets.length},` : ''} ${newInMelCloud.atwPresets.length ? `ATW: ${newInMelCloud.atwPresets.length}, ` : ''} ${newInMelCloud.ervPresets.length ? `ERV: ${newInMelCloud.ervPresets.length},` : ''} ${newSchedulesCount ? `schedules:` : ''} ${newInMelCloud.ataSchedules.length ? `ATA: ${newInMelCloud.ataSchedules.length},` : ''} ${newInMelCloud.atwSchedules.length ? `ATW: ${newInMelCloud.atwSchedules.length},` : ''} ${newInMelCloud.ervSchedules.length ? `ERV: ${newInMelCloud.ervSchedules.length}, ` : ''} ${newScenesCount ? `scenes:` : ''} ${newInMelCloud.ataScenes.length ? `ATA: ${newInMelCloud.ataScenes.length},` : ''} ${newInMelCloud.atwScenes.length ? `ATW: ${newInMelCloud.atwScenes.length},` : ''} ${newInMelCloud.ervScenes.length ? `ERV: ${newInMelCloud.ervScenes.length}` : ''}.`, 'green');
411
- }
412
- if (removedDevicesCount || removedPresetsCount || removedSchedulesCount || removedScenesCount) {
413
- updateInfo('info1', `Removed old ${removedDevicesCount ? `devices:` : ''} ${removedFromConfig.ata.length ? `ATA: ${removedFromConfig.ata.length},` : ''} ${removedFromConfig.atw.length ? `ATW: ${removedFromConfig.atw.length},` : ''} ${removedFromConfig.erv.length ? `ERV: ${removedFromConfig.erv.length},` : ''} ${removedPresetsCount ? `presets: ${removedPresetsCount},` : ''} ${removedSchedulesCount ? `schedules: ${removedSchedulesCount},` : ''} ${removedScenesCount ? `scenes: ${removedScenesCount}` : ''}.`, 'orange');
414
- }
416
+ if (!newDevicesCount && !newPresetsCount && !newSchedulesCount && !newScenesCount && !removedDevicesCount && !removedPresetsCount && !removedSchedulesCount && !removedScenesCount) updateInfo('info', 'No changes detected.', fontColor);
417
+
418
+ // New items
419
+ const newParts = [];
420
+ if (newDevicesCount) newParts.push(summarizeChanges('Devices', newInMelCloud.ata, newInMelCloud.atw, newInMelCloud.erv));
421
+ if (account.type === 'melcloud' && newPresetsCount) newParts.push(summarizeChanges('Presets', newInMelCloud.ataPresets, newInMelCloud.atwPresets, newInMelCloud.ervPresets));
422
+ if (account.type === 'melcloudhome' && newSchedulesCount) newParts.push(summarizeChanges('Schedules', newInMelCloud.ataSchedules, newInMelCloud.atwSchedules, newInMelCloud.ervSchedules));
423
+ if (account.type === 'melcloudhome' && newScenesCount) newParts.push(summarizeChanges('Scenes', newInMelCloud.ataScenes, newInMelCloud.atwScenes, newInMelCloud.ervScenes));
424
+ if (newParts.length) updateInfo('info', `Found new: ${newParts.join('; ')}`, 'green');
425
+
426
+ // Removed items
427
+ const removedParts = [];
428
+ if (removedDevicesCount) removedParts.push(summarizeChanges('Devices', removedFromConfig.ata, removedFromConfig.atw, removedFromConfig.erv));
429
+ if (removedPresetsCount) removedParts.push(`Presets: ${removedPresetsCount}`);
430
+ if (removedSchedulesCount) removedParts.push(`Schedules: ${removedSchedulesCount}`);
431
+ if (removedScenesCount) removedParts.push(`Scenes: ${removedScenesCount}`);
432
+ if (removedParts.length) updateInfo('info1', `Removed old: ${removedParts.join('; ')}`, 'orange');
415
433
 
416
434
  await homebridge.updatePluginConfig(pluginConfig);
417
435
  await homebridge.savePluginConfig();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.7.3-beta.8",
4
+ "version": "4.7.3-beta.9",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",