homebridge-melcloud-control 4.0.0-beta.52 → 4.0.0-beta.53
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 +28 -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.53",
|
|
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
|
@@ -217,26 +217,46 @@ class MelCloud extends EventEmitter {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
const devices = allDevices.map(device => {
|
|
220
|
-
const settingsArray = device.Settings || device.settings || [];
|
|
220
|
+
const settingsArray = device.Settings || device.settings || [];
|
|
221
221
|
|
|
222
222
|
// Konwersja tablicy [{ name, value }] → { Name: Value }
|
|
223
223
|
const settingsObject = Object.fromEntries(
|
|
224
|
-
settingsArray.map(({ name, value }) =>
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
224
|
+
settingsArray.map(({ name, value }) => {
|
|
225
|
+
let parsedValue = value;
|
|
226
|
+
|
|
227
|
+
// Zamiana boolean stringów
|
|
228
|
+
if (value === "True") parsedValue = true;
|
|
229
|
+
else if (value === "False") parsedValue = false;
|
|
230
|
+
// Zamiana na number, jeśli da się sparsować
|
|
231
|
+
else if (!isNaN(value) && value !== "") parsedValue = Number(value);
|
|
232
|
+
|
|
233
|
+
// Kapitalizacja klucza
|
|
234
|
+
const key = name.charAt(0).toUpperCase() + name.slice(1);
|
|
235
|
+
return [key, parsedValue];
|
|
236
|
+
})
|
|
228
237
|
);
|
|
229
238
|
|
|
239
|
+
// Scal Capabilities i Settings w Device
|
|
240
|
+
const deviceObject = {
|
|
241
|
+
...Object.fromEntries(
|
|
242
|
+
Object.entries(device.Capabilities || {}).map(([key, value]) => [
|
|
243
|
+
key.charAt(0).toUpperCase() + key.slice(1),
|
|
244
|
+
value
|
|
245
|
+
])
|
|
246
|
+
),
|
|
247
|
+
...settingsObject
|
|
248
|
+
};
|
|
249
|
+
|
|
230
250
|
return {
|
|
231
|
-
...device,
|
|
251
|
+
...device,
|
|
232
252
|
DeviceID: device.Id,
|
|
233
253
|
DeviceName: device.GivenDisplayName,
|
|
234
|
-
|
|
235
|
-
Device: device.Capabilities
|
|
254
|
+
Device: deviceObject
|
|
236
255
|
};
|
|
237
256
|
});
|
|
238
257
|
|
|
239
258
|
|
|
259
|
+
|
|
240
260
|
await this.functions.saveData(this.devicesFile, devices);
|
|
241
261
|
if (this.logDebug) this.emit('debug', `${devicesCount} devices saved`);
|
|
242
262
|
|