homebridge-melcloud-control 4.0.0-beta.53 → 4.0.0-beta.54

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 +6 -8
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.53",
4
+ "version": "4.0.0-beta.54",
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
@@ -219,24 +219,21 @@ class MelCloud extends EventEmitter {
219
219
  const devices = allDevices.map(device => {
220
220
  const settingsArray = device.Settings || device.settings || [];
221
221
 
222
- // Konwersja tablicy [{ name, value }] → { Name: Value }
222
+ // Konwersja tablicy [{ name, value }] → { Name: Value } z typami
223
223
  const settingsObject = Object.fromEntries(
224
224
  settingsArray.map(({ name, value }) => {
225
225
  let parsedValue = value;
226
226
 
227
- // Zamiana boolean stringów
228
227
  if (value === "True") parsedValue = true;
229
228
  else if (value === "False") parsedValue = false;
230
- // Zamiana na number, jeśli da się sparsować
231
229
  else if (!isNaN(value) && value !== "") parsedValue = Number(value);
232
230
 
233
- // Kapitalizacja klucza
234
231
  const key = name.charAt(0).toUpperCase() + name.slice(1);
235
232
  return [key, parsedValue];
236
233
  })
237
234
  );
238
235
 
239
- // Scal Capabilities i Settings w Device
236
+ // Scal Capabilities + Settings w Device
240
237
  const deviceObject = {
241
238
  ...Object.fromEntries(
242
239
  Object.entries(device.Capabilities || {}).map(([key, value]) => [
@@ -247,16 +244,17 @@ class MelCloud extends EventEmitter {
247
244
  ...settingsObject
248
245
  };
249
246
 
247
+ // Usuń stare pola Settings i Capabilities
248
+ const { Settings, settings, Capabilities, ...rest } = device;
249
+
250
250
  return {
251
- ...device,
251
+ ...rest,
252
252
  DeviceID: device.Id,
253
253
  DeviceName: device.GivenDisplayName,
254
254
  Device: deviceObject
255
255
  };
256
256
  });
257
257
 
258
-
259
-
260
258
  await this.functions.saveData(this.devicesFile, devices);
261
259
  if (this.logDebug) this.emit('debug', `${devicesCount} devices saved`);
262
260