homebridge-melcloud-control 4.0.0-beta.51 → 4.0.0-beta.52

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/melcloud.js +26 -11
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.0.0-beta.51",
4
+ "version": "4.0.0-beta.52",
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
@@ -196,10 +196,12 @@ class MelCloud extends EventEmitter {
196
196
 
197
197
  const allDevices = buildingsList.flatMap(building => {
198
198
  const capitalizeKeys = obj =>
199
- Object.fromEntries(Object.entries(obj).map(([key, value]) => [
200
- key.charAt(0).toUpperCase() + key.slice(1),
201
- value
202
- ]));
199
+ Object.fromEntries(
200
+ Object.entries(obj).map(([key, value]) => [
201
+ key.charAt(0).toUpperCase() + key.slice(1),
202
+ value
203
+ ])
204
+ );
203
205
 
204
206
  return [
205
207
  ...(building.airToAirUnits || []).map(device => ({ ...capitalizeKeys(device), Type: 0 })),
@@ -214,13 +216,26 @@ class MelCloud extends EventEmitter {
214
216
  return null;
215
217
  }
216
218
 
217
- const devices = allDevices.map(device => ({
218
- ...device, // zachowuje wszystkie pola z allDevices
219
- DeviceID: device.Id,
220
- DeviceName: device.GivenDisplayName,
221
- Settings: Object.fromEntries((device.Settings || []).map(({ Name, Value }) => [Name, Value])),
222
- Device: device.Capabilities
223
- }));
219
+ const devices = allDevices.map(device => {
220
+ const settingsArray = device.Settings || device.settings || []; // obsługa różnych nazw
221
+
222
+ // Konwersja tablicy [{ name, value }] → { Name: Value }
223
+ const settingsObject = Object.fromEntries(
224
+ settingsArray.map(({ name, value }) => [
225
+ name.charAt(0).toUpperCase() + name.slice(1),
226
+ value
227
+ ])
228
+ );
229
+
230
+ return {
231
+ ...device, // zachowuje wszystko z allDevices
232
+ DeviceID: device.Id,
233
+ DeviceName: device.GivenDisplayName,
234
+ Settings: settingsObject,
235
+ Device: device.Capabilities
236
+ };
237
+ });
238
+
224
239
 
225
240
  await this.functions.saveData(this.devicesFile, devices);
226
241
  if (this.logDebug) this.emit('debug', `${devicesCount} devices saved`);