homebridge-melcloud-control 4.0.0-beta.53 → 4.0.0-beta.55
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 +8 -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.
|
|
4
|
+
"version": "4.0.0-beta.55",
|
|
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 poprawnym typem
|
|
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
|
|
236
|
+
// Scal Capabilities + Settings w Device + dodaj DeviceType
|
|
240
237
|
const deviceObject = {
|
|
241
238
|
...Object.fromEntries(
|
|
242
239
|
Object.entries(device.Capabilities || {}).map(([key, value]) => [
|
|
@@ -244,11 +241,15 @@ class MelCloud extends EventEmitter {
|
|
|
244
241
|
value
|
|
245
242
|
])
|
|
246
243
|
),
|
|
247
|
-
...settingsObject
|
|
244
|
+
...settingsObject,
|
|
245
|
+
DeviceType: device.Type
|
|
248
246
|
};
|
|
249
247
|
|
|
248
|
+
// Usuń stare pola Settings i Capabilities
|
|
249
|
+
const { Settings, settings, Capabilities, ...rest } = device;
|
|
250
|
+
|
|
250
251
|
return {
|
|
251
|
-
...
|
|
252
|
+
...rest,
|
|
252
253
|
DeviceID: device.Id,
|
|
253
254
|
DeviceName: device.GivenDisplayName,
|
|
254
255
|
Device: deviceObject
|
|
@@ -256,7 +257,6 @@ class MelCloud extends EventEmitter {
|
|
|
256
257
|
});
|
|
257
258
|
|
|
258
259
|
|
|
259
|
-
|
|
260
260
|
await this.functions.saveData(this.devicesFile, devices);
|
|
261
261
|
if (this.logDebug) this.emit('debug', `${devicesCount} devices saved`);
|
|
262
262
|
|