homebridge-melcloud-control 4.1.2-beta.6 → 4.1.2-beta.8
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.
- package/package.json +1 -1
- package/src/melcloud.js +9 -3
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.
|
|
4
|
+
"version": "4.1.2-beta.8",
|
|
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
|
@@ -254,30 +254,36 @@ class MelCloud extends EventEmitter {
|
|
|
254
254
|
|
|
255
255
|
// Funkcja tworząca finalny obiekt Device
|
|
256
256
|
const createDevice = (device, type, headers = {}) => {
|
|
257
|
+
// Zabezpieczenie – jeśli Settings to nie tablica, użyj pustej
|
|
257
258
|
const settingsArray = Array.isArray(device.Settings) ? device.Settings : [];
|
|
258
259
|
|
|
260
|
+
// Konwersja tablicy Settings → obiekt z kapitalizowanymi kluczami i typami JS
|
|
259
261
|
const settingsObject = Object.fromEntries(
|
|
260
262
|
settingsArray
|
|
261
|
-
.filter(item => item && typeof item.name === 'string')
|
|
263
|
+
.filter(item => item && typeof item.name === 'string')
|
|
262
264
|
.map(({ name, value }) => {
|
|
263
265
|
let parsedValue = value;
|
|
264
266
|
if (value === "True") parsedValue = true;
|
|
265
267
|
else if (value === "False") parsedValue = false;
|
|
266
|
-
else if (typeof value === 'string' && !isNaN(Number(value)) && value.trim() !== "")
|
|
268
|
+
else if (typeof value === 'string' && !isNaN(Number(value)) && value.trim() !== "")
|
|
269
|
+
parsedValue = Number(value);
|
|
267
270
|
|
|
268
271
|
const key = name.charAt(0).toUpperCase() + name.slice(1);
|
|
269
272
|
return [key, parsedValue];
|
|
270
273
|
})
|
|
271
274
|
);
|
|
272
275
|
|
|
276
|
+
// Połącz Capabilities + Settings + DeviceType
|
|
273
277
|
const deviceObject = {
|
|
274
278
|
...capitalizeKeysDeep(device.Capabilities || {}),
|
|
275
279
|
...settingsObject,
|
|
276
280
|
DeviceType: type
|
|
277
281
|
};
|
|
278
282
|
|
|
283
|
+
// Usuń zbędne pola (Capabilities, Settings), ale zachowaj resztę
|
|
279
284
|
const { Settings, Capabilities, Id, GivenDisplayName, ...rest } = device;
|
|
280
285
|
|
|
286
|
+
// Końcowy obiekt urządzenia
|
|
281
287
|
return {
|
|
282
288
|
...capitalizeKeysDeep(rest),
|
|
283
289
|
Type: type,
|
|
@@ -288,7 +294,7 @@ class MelCloud extends EventEmitter {
|
|
|
288
294
|
};
|
|
289
295
|
};
|
|
290
296
|
|
|
291
|
-
// Mapowanie urządzeń
|
|
297
|
+
// Mapowanie urządzeń z budynku
|
|
292
298
|
return [
|
|
293
299
|
...(building.airToAirUnits || []).map(d => createDevice(capitalizeKeysDeep(d), 0)),
|
|
294
300
|
...(building.airToWaterUnits || []).map(d => createDevice(capitalizeKeysDeep(d), 1)),
|