homebridge-melcloud-control 4.1.2-beta.15 → 4.1.2-beta.16
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 +19 -50
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.16",
|
|
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,50 +235,18 @@ 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
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
capitalizeKeysDeep(value)
|
|
247
|
-
])
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
return obj;
|
|
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
|
-
};
|
|
238
|
+
// Funkcja kapitalizująca klucze obiektu
|
|
239
|
+
const capitalizeKeys = obj =>
|
|
240
|
+
Object.fromEntries(
|
|
241
|
+
Object.entries(obj).map(([key, value]) => [
|
|
242
|
+
key.charAt(0).toUpperCase() + key.slice(1),
|
|
243
|
+
value
|
|
244
|
+
])
|
|
245
|
+
);
|
|
279
246
|
|
|
280
|
-
// Funkcja tworząca
|
|
247
|
+
// Funkcja tworząca finalny obiekt Device
|
|
281
248
|
const createDevice = (device, type) => {
|
|
249
|
+
// Settings już kapitalizowane w nazwach
|
|
282
250
|
const settingsArray = device.Settings || [];
|
|
283
251
|
|
|
284
252
|
const settingsObject = Object.fromEntries(
|
|
@@ -288,20 +256,23 @@ class MelCloud extends EventEmitter {
|
|
|
288
256
|
else if (value === "False") parsedValue = false;
|
|
289
257
|
else if (!isNaN(value) && value !== "") parsedValue = Number(value);
|
|
290
258
|
|
|
291
|
-
|
|
259
|
+
const key = name.charAt(0).toUpperCase() + name.slice(1);
|
|
260
|
+
return [key, parsedValue];
|
|
292
261
|
})
|
|
293
262
|
);
|
|
294
263
|
|
|
264
|
+
// Scal Capabilities + Settings + DeviceType w Device
|
|
295
265
|
const deviceObject = {
|
|
296
|
-
...
|
|
266
|
+
...capitalizeKeys(device.Capabilities || {}),
|
|
297
267
|
...settingsObject,
|
|
298
268
|
DeviceType: type
|
|
299
269
|
};
|
|
300
270
|
|
|
271
|
+
// Usuń stare pola Settings i Capabilities
|
|
301
272
|
const { Settings, Capabilities, Id, GivenDisplayName, ...rest } = device;
|
|
302
273
|
|
|
303
274
|
return {
|
|
304
|
-
...
|
|
275
|
+
...rest,
|
|
305
276
|
Type: type,
|
|
306
277
|
DeviceID: Id,
|
|
307
278
|
DeviceName: GivenDisplayName,
|
|
@@ -311,14 +282,12 @@ class MelCloud extends EventEmitter {
|
|
|
311
282
|
};
|
|
312
283
|
|
|
313
284
|
return [
|
|
314
|
-
...(building.airToAirUnits || []).map(d => createDevice(d, 0)),
|
|
315
|
-
...(building.airToWaterUnits || []).map(d => createDevice(d, 1)),
|
|
316
|
-
...(building.airToVentilationUnits || []).map(d => createDevice(d, 3))
|
|
285
|
+
...(building.airToAirUnits || []).map(d => createDevice(capitalizeKeys(d), 0)),
|
|
286
|
+
...(building.airToWaterUnits || []).map(d => createDevice(capitalizeKeys(d), 1)),
|
|
287
|
+
...(building.airToVentilationUnits || []).map(d => createDevice(capitalizeKeys(d), 3))
|
|
317
288
|
];
|
|
318
289
|
});
|
|
319
290
|
|
|
320
|
-
|
|
321
|
-
|
|
322
291
|
const devicesCount = devices.length;
|
|
323
292
|
if (devicesCount === 0) {
|
|
324
293
|
devicesList.Info = 'No devices found'
|