homebridge-melcloud-control 4.1.2-beta.12 → 4.1.2-beta.14
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 +39 -39
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.14",
|
|
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,43 +235,20 @@ 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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
value
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const capitalizeNestedFields = device => {
|
|
249
|
-
const copy = { ...device };
|
|
250
|
-
|
|
251
|
-
if (copy.frostProtection && typeof copy.frostProtection === 'object') {
|
|
252
|
-
copy.FrostProtection = capitalizeKeys(copy.frostProtection);
|
|
253
|
-
delete copy.frostProtection;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (copy.overheatProtection && typeof copy.overheatProtection === 'object') {
|
|
257
|
-
copy.OverheatProtection = capitalizeKeys(copy.overheatProtection);
|
|
258
|
-
delete copy.overheatProtection;
|
|
238
|
+
const capitalizeKeysDeep = obj => {
|
|
239
|
+
if (Array.isArray(obj)) {
|
|
240
|
+
return obj.map(capitalizeKeysDeep);
|
|
241
|
+
} else if (obj && typeof obj === 'object') {
|
|
242
|
+
return Object.fromEntries(
|
|
243
|
+
Object.entries(obj).map(([key, value]) => [
|
|
244
|
+
key.charAt(0).toUpperCase() + key.slice(1),
|
|
245
|
+
capitalizeKeysDeep(value)
|
|
246
|
+
])
|
|
247
|
+
);
|
|
259
248
|
}
|
|
260
|
-
|
|
261
|
-
if (copy.holidayMode && typeof copy.holidayMode === 'object') {
|
|
262
|
-
copy.HolidayMode = capitalizeKeys(copy.holidayMode);
|
|
263
|
-
delete copy.holidayMode;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (Array.isArray(copy.schedule)) {
|
|
267
|
-
copy.Schedule = copy.schedule.map(item => capitalizeKeys(item));
|
|
268
|
-
delete copy.schedule;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
return copy;
|
|
249
|
+
return obj;
|
|
272
250
|
};
|
|
273
251
|
|
|
274
|
-
// Funkcja tworząca finalny obiekt Device
|
|
275
252
|
const createDevice = (device, type) => {
|
|
276
253
|
// Settings już kapitalizowane w nazwach
|
|
277
254
|
const settingsArray = device.Settings || [];
|
|
@@ -290,7 +267,7 @@ class MelCloud extends EventEmitter {
|
|
|
290
267
|
|
|
291
268
|
// Scal Capabilities + Settings + DeviceType w Device
|
|
292
269
|
const deviceObject = {
|
|
293
|
-
...
|
|
270
|
+
...capitalizeKeysDeep(device.Capabilities || {}),
|
|
294
271
|
...settingsObject,
|
|
295
272
|
DeviceType: type
|
|
296
273
|
};
|
|
@@ -298,8 +275,31 @@ class MelCloud extends EventEmitter {
|
|
|
298
275
|
// Usuń stare pola Settings i Capabilities
|
|
299
276
|
const { Settings, Capabilities, Id, GivenDisplayName, ...rest } = device;
|
|
300
277
|
|
|
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
301
|
return {
|
|
302
|
-
...
|
|
302
|
+
...capitalizedNested,
|
|
303
303
|
Type: type,
|
|
304
304
|
DeviceID: Id,
|
|
305
305
|
DeviceName: GivenDisplayName,
|
|
@@ -309,9 +309,9 @@ class MelCloud extends EventEmitter {
|
|
|
309
309
|
};
|
|
310
310
|
|
|
311
311
|
return [
|
|
312
|
-
...(building.airToAirUnits || []).map(d => createDevice(
|
|
313
|
-
...(building.airToWaterUnits || []).map(d => createDevice(
|
|
314
|
-
...(building.airToVentilationUnits || []).map(d => createDevice(
|
|
312
|
+
...(building.airToAirUnits || []).map(d => createDevice(d, 0)),
|
|
313
|
+
...(building.airToWaterUnits || []).map(d => createDevice(d, 1)),
|
|
314
|
+
...(building.airToVentilationUnits || []).map(d => createDevice(d, 3))
|
|
315
315
|
];
|
|
316
316
|
});
|
|
317
317
|
|