homebridge-melcloud-control 4.4.1-beta.37 → 4.4.1-beta.39

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.
@@ -346,7 +346,7 @@
346
346
  namePrefix: false
347
347
  };
348
348
  deviceInConfig.scenes.push(sceneObj);
349
- newScenes.push(sceneObj);
349
+ if (index === 0) newScenes.push(sceneObj);
350
350
  }
351
351
  });
352
352
  }
@@ -356,9 +356,9 @@
356
356
  };
357
357
 
358
358
  // Execute device handlers
359
- account.ataDevices = handleDevices(devicesInMelCloudByType.ata, account.ataDevices, "Air Conditioner", newInMelCloud.ata, newInMelCloud.ataPresets, newInMelCloud.ataSchedules, newInMelCloud.ataScenes);
360
- account.atwDevices = handleDevices(devicesInMelCloudByType.atw, account.atwDevices, "Heat Pump", newInMelCloud.atw, newInMelCloud.atwPresets, newInMelCloud.atwSchedules, newInMelCloud.atwScenes);
361
- account.ervDevices = handleDevices(devicesInMelCloudByType.erv, account.ervDevices, "Energy Recovery Ventilation", newInMelCloud.erv, newInMelCloud.ervPresets, newInMelCloud.ervSchedules, newInMelCloud.ervScenes);
359
+ account.ataDevices = handleDevices(devicesInMelCloudByType.ata, account.ataDevices, "Air Conditioner", newInMelCloud.ata, newInMelCloud.ataPresets, newInMelCloud.ataSchedules, newInMelCloud.scenes);
360
+ account.atwDevices = handleDevices(devicesInMelCloudByType.atw, account.atwDevices, "Heat Pump", newInMelCloud.atw, newInMelCloud.atwPresets, newInMelCloud.atwSchedules, newInMelCloud.scenes);
361
+ account.ervDevices = handleDevices(devicesInMelCloudByType.erv, account.ervDevices, "Energy Recovery Ventilation", newInMelCloud.erv, newInMelCloud.ervPresets, newInMelCloud.ervSchedules, newInMelCloud.scenes);
362
362
 
363
363
  // Summary
364
364
  const newDevicesCount = newInMelCloud.ata.length + newInMelCloud.atw.length + newInMelCloud.erv.length;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.4.1-beta.37",
4
+ "version": "4.4.1-beta.39",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/melcloud.js CHANGED
@@ -54,7 +54,7 @@ class MelCloud extends EventEmitter {
54
54
 
55
55
  async checkDevicesList() {
56
56
  try {
57
- const devicesList = { State: false, Info: null, Devices: [], Scenes: [] }
57
+ const devicesList = { State: false, Info: null, Buildings: [], Devices: [], Scenes: [] }
58
58
  if (this.logDebug) this.emit('debug', `Scanning for devices...`);
59
59
  const listDevicesData = await this.client(ApiUrls.Get.ListDevices, { method: 'GET', });
60
60
 
@@ -71,9 +71,6 @@ class MelCloud extends EventEmitter {
71
71
  return devicesList;
72
72
  }
73
73
 
74
- await this.functions.saveData(this.buildingsFile, buildingsList);
75
- if (this.logDebug) this.emit('debug', `Buildings list saved`);
76
-
77
74
  const devices = [];
78
75
  for (const building of buildingsList) {
79
76
  if (!building.Structure) {
@@ -108,7 +105,12 @@ class MelCloud extends EventEmitter {
108
105
 
109
106
  devicesList.State = true;
110
107
  devicesList.Info = `Found ${devicesCount} devices`;
108
+ devicesList.Buildings = buildingsList;
111
109
  devicesList.Devices = devices;
110
+
111
+ await this.functions.saveData(this.buildingsFile, devicesList);
112
+ if (this.logDebug) this.emit('debug', `Buildings list saved`);
113
+
112
114
  this.emit('devicesList', devicesList);
113
115
 
114
116
  return devicesList;
@@ -107,7 +107,7 @@ class MelCloudHome extends EventEmitter {
107
107
 
108
108
  async checkDevicesList() {
109
109
  try {
110
- const devicesList = { State: false, Info: null, Devices: [], Scenes: [] }
110
+ const devicesList = { State: false, Info: null, Buildings: {}, Devices: [], Scenes: [] }
111
111
  if (this.logDebug) this.emit('debug', `Scanning for devices`);
112
112
  const listDevicesData = await this.client(ApiUrls.Home.Get.ListDevices, { method: 'GET' });
113
113
 
@@ -122,9 +122,6 @@ class MelCloudHome extends EventEmitter {
122
122
  return devicesList;
123
123
  }
124
124
 
125
- await this.functions.saveData(this.buildingsFile, userContext);
126
- if (this.logDebug) this.emit('debug', `Buildings list saved`);
127
-
128
125
  const devices = buildingsList.flatMap(building => {
129
126
  // Funkcja kapitalizująca klucze obiektu
130
127
  const capitalizeKeys = obj => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key.charAt(0).toUpperCase() + key.slice(1), value]));
@@ -205,8 +202,13 @@ class MelCloudHome extends EventEmitter {
205
202
 
206
203
  devicesList.State = true;
207
204
  devicesList.Info = `Found ${devicesCount} devices ${scenes.length > 0 ? `and ${scenes.length} scenes` : ''}`;
205
+ devicesList.Buildings = userContext;
208
206
  devicesList.Devices = devices;
209
207
  devicesList.Scenes = scenes;
208
+
209
+ await this.functions.saveData(this.buildingsFile, devicesList);
210
+ if (this.logDebug) this.emit('debug', `Buildings list saved`);
211
+
210
212
  this.emit('devicesList', devicesList);
211
213
 
212
214
  return devicesList;