homebridge-melcloud-control 4.1.2-beta.14 → 4.1.2-beta.15
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 +33 -29
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.15",
|
|
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
|
@@ -235,6 +235,7 @@ class MelCloud extends EventEmitter {
|
|
|
235
235
|
if (this.logDebug) this.emit('debug', `Buildings list saved`);
|
|
236
236
|
|
|
237
237
|
const devices = buildingsList.flatMap(building => {
|
|
238
|
+
// Rekurencyjna kapitalizacja wszystkich kluczy w obiekcie/tablicy
|
|
238
239
|
const capitalizeKeysDeep = obj => {
|
|
239
240
|
if (Array.isArray(obj)) {
|
|
240
241
|
return obj.map(capitalizeKeysDeep);
|
|
@@ -249,8 +250,35 @@ class MelCloud extends EventEmitter {
|
|
|
249
250
|
return obj;
|
|
250
251
|
};
|
|
251
252
|
|
|
253
|
+
// Funkcja kapitalizująca tylko wybrane pola w głównym obiekcie
|
|
254
|
+
const capitalizeSelectedFields = obj => {
|
|
255
|
+
const copy = { ...obj };
|
|
256
|
+
|
|
257
|
+
if (copy.frostProtection) {
|
|
258
|
+
copy.FrostProtection = capitalizeKeysDeep(copy.frostProtection);
|
|
259
|
+
delete copy.frostProtection;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (copy.overheatProtection) {
|
|
263
|
+
copy.OverheatProtection = capitalizeKeysDeep(copy.overheatProtection);
|
|
264
|
+
delete copy.overheatProtection;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (copy.holidayMode) {
|
|
268
|
+
copy.HolidayMode = capitalizeKeysDeep(copy.holidayMode);
|
|
269
|
+
delete copy.holidayMode;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (Array.isArray(copy.schedule)) {
|
|
273
|
+
copy.Schedule = copy.schedule.map(capitalizeKeysDeep);
|
|
274
|
+
delete copy.schedule;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return copy;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
// Funkcja tworząca pojedyncze urządzenie
|
|
252
281
|
const createDevice = (device, type) => {
|
|
253
|
-
// Settings już kapitalizowane w nazwach
|
|
254
282
|
const settingsArray = device.Settings || [];
|
|
255
283
|
|
|
256
284
|
const settingsObject = Object.fromEntries(
|
|
@@ -260,46 +288,20 @@ class MelCloud extends EventEmitter {
|
|
|
260
288
|
else if (value === "False") parsedValue = false;
|
|
261
289
|
else if (!isNaN(value) && value !== "") parsedValue = Number(value);
|
|
262
290
|
|
|
263
|
-
|
|
264
|
-
return [key, parsedValue];
|
|
291
|
+
return [name.charAt(0).toUpperCase() + name.slice(1), parsedValue];
|
|
265
292
|
})
|
|
266
293
|
);
|
|
267
294
|
|
|
268
|
-
// Scal Capabilities + Settings + DeviceType w Device
|
|
269
295
|
const deviceObject = {
|
|
270
296
|
...capitalizeKeysDeep(device.Capabilities || {}),
|
|
271
297
|
...settingsObject,
|
|
272
298
|
DeviceType: type
|
|
273
299
|
};
|
|
274
300
|
|
|
275
|
-
// Usuń stare pola Settings i Capabilities
|
|
276
301
|
const { Settings, Capabilities, Id, GivenDisplayName, ...rest } = device;
|
|
277
302
|
|
|
278
|
-
// Kapitalizacja wybranych pól z głównego obiektu
|
|
279
|
-
const capitalizedNested = { ...rest };
|
|
280
|
-
|
|
281
|
-
if (capitalizedNested.frostProtection) {
|
|
282
|
-
capitalizedNested.FrostProtection = capitalizeKeysDeep(capitalizedNested.frostProtection);
|
|
283
|
-
delete capitalizedNested.frostProtection;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (capitalizedNested.overheatProtection) {
|
|
287
|
-
capitalizedNested.OverheatProtection = capitalizeKeysDeep(capitalizedNested.overheatProtection);
|
|
288
|
-
delete capitalizedNested.overheatProtection;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (capitalizedNested.holidayMode) {
|
|
292
|
-
capitalizedNested.HolidayMode = capitalizeKeysDeep(capitalizedNested.holidayMode);
|
|
293
|
-
delete capitalizedNested.holidayMode;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (Array.isArray(capitalizedNested.schedule)) {
|
|
297
|
-
capitalizedNested.Schedule = capitalizedNested.schedule.map(capitalizeKeysDeep);
|
|
298
|
-
delete capitalizedNested.schedule;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
303
|
return {
|
|
302
|
-
...
|
|
304
|
+
...capitalizeSelectedFields(rest),
|
|
303
305
|
Type: type,
|
|
304
306
|
DeviceID: Id,
|
|
305
307
|
DeviceName: GivenDisplayName,
|
|
@@ -315,6 +317,8 @@ class MelCloud extends EventEmitter {
|
|
|
315
317
|
];
|
|
316
318
|
});
|
|
317
319
|
|
|
320
|
+
|
|
321
|
+
|
|
318
322
|
const devicesCount = devices.length;
|
|
319
323
|
if (devicesCount === 0) {
|
|
320
324
|
devicesList.Info = 'No devices found'
|