homebridge-melcloud-control 4.1.2-beta.20 → 4.1.2-beta.3
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/homebridge-ui/public/index.html +2 -0
- package/package.json +1 -1
- package/src/deviceata.js +9 -10
- package/src/deviceatw.js +2 -3
- package/src/deviceerv.js +1 -1
- package/src/melcloud.js +12 -31
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.3",
|
|
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/deviceata.js
CHANGED
|
@@ -683,9 +683,8 @@ class DeviceAta extends EventEmitter {
|
|
|
683
683
|
if (this.presets.length > 0) {
|
|
684
684
|
if (this.logDebug) this.emit('debug', `Prepare presets services`);
|
|
685
685
|
this.presetsServices = [];
|
|
686
|
-
const presetsIdKey = this.accountType === 'melcloud' ? 'ID' : 'Id';
|
|
687
686
|
this.presets.forEach((preset, i) => {
|
|
688
|
-
const presetData = presetsOnServer.find(p => p
|
|
687
|
+
const presetData = presetsOnServer.find(p => p.ID === preset.id);
|
|
689
688
|
|
|
690
689
|
//get preset name
|
|
691
690
|
const name = preset.name;
|
|
@@ -766,7 +765,7 @@ class DeviceAta extends EventEmitter {
|
|
|
766
765
|
})
|
|
767
766
|
.onSet(async (state) => {
|
|
768
767
|
try {
|
|
769
|
-
const
|
|
768
|
+
const key = this.accountType === 'melcloud' ? 'FanSpeed' : 'SetFanSpeed';
|
|
770
769
|
let effectiveFlags = null;
|
|
771
770
|
switch (mode) {
|
|
772
771
|
case 0: //POWER ON,OFF
|
|
@@ -1018,7 +1017,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1018
1017
|
|
|
1019
1018
|
//keys
|
|
1020
1019
|
const presetsKey = this.accountType === 'melcloud' ? 'Presets' : 'Schedule';
|
|
1021
|
-
const presetsIdKey =
|
|
1020
|
+
const presetsIdKey = account.type === 'melcloud' ? 'ID' : 'Id';
|
|
1022
1021
|
const setTempKey = this.accountType === 'melcloud' ? 'SetTemperature' : 'SetPoint';
|
|
1023
1022
|
const fanKey = this.accountType === 'melcloud' ? 'FanSpeed' : 'SetFanSpeed';
|
|
1024
1023
|
const tempStepKey = this.accountType === 'melcloud' ? 'TemperatureIncrement' : 'HasHalfDegreeIncrements';
|
|
@@ -1035,12 +1034,12 @@ class DeviceAta extends EventEmitter {
|
|
|
1035
1034
|
const presetsOnServer = deviceData[presetsKey] ?? [];
|
|
1036
1035
|
|
|
1037
1036
|
//protection
|
|
1038
|
-
const frostProtectionEnabled = deviceData.FrostProtection?.
|
|
1039
|
-
const frostProtectionActive = deviceData.FrostProtection?.
|
|
1040
|
-
const overheatProtectionEnabled = deviceData.OverheatProtection?.
|
|
1041
|
-
const overheatProtectionActive = deviceData.OverheatProtection?.
|
|
1042
|
-
const holidayModeEnabled = deviceData.HolidayMode?.
|
|
1043
|
-
const holidayModeActive = deviceData.HolidayMode?.
|
|
1037
|
+
const frostProtectionEnabled = deviceData.FrostProtection?.enabled;
|
|
1038
|
+
const frostProtectionActive = deviceData.FrostProtection?.active;
|
|
1039
|
+
const overheatProtectionEnabled = deviceData.OverheatProtection?.enabled;
|
|
1040
|
+
const overheatProtectionActive = deviceData.OverheatProtection?.active;
|
|
1041
|
+
const holidayModeEnabled = deviceData.HolidayMode?.enabled;
|
|
1042
|
+
const holidayModeActive = deviceData.HolidayMode?.active;
|
|
1044
1043
|
const scheduleEnabled = deviceData.ScheduleEnabled;
|
|
1045
1044
|
|
|
1046
1045
|
//device control
|
package/src/deviceatw.js
CHANGED
|
@@ -1055,9 +1055,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
1055
1055
|
if (this.presets.length > 0) {
|
|
1056
1056
|
if (this.logDebug) this.emit('debug', `Prepare presets services`);
|
|
1057
1057
|
this.presetsServices = [];
|
|
1058
|
-
const presetsIdKey = this.accountType === 'melcloud' ? 'ID' : 'Id';
|
|
1059
1058
|
this.presets.forEach((preset, i) => {
|
|
1060
|
-
const presetData = presetsOnServer.find(p => p
|
|
1059
|
+
const presetData = presetsOnServer.find(p => p.ID === preset.id);
|
|
1061
1060
|
|
|
1062
1061
|
//get preset name
|
|
1063
1062
|
const name = preset.name;
|
|
@@ -1332,7 +1331,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1332
1331
|
|
|
1333
1332
|
//keys
|
|
1334
1333
|
const presetsKey = this.accountType === 'melcloud' ? 'Presets' : 'Schedule';
|
|
1335
|
-
const presetsIdKey =
|
|
1334
|
+
const presetsIdKey = account.type === 'melcloud' ? 'ID' : 'Id';
|
|
1336
1335
|
const tempStepKey = this.accountType === 'melcloud' ? 'TemperatureIncrement' : 'HasHalfDegreeIncrements';
|
|
1337
1336
|
const errorKey = this.accountType === 'melcloud' ? 'HasError' : 'IsInError';
|
|
1338
1337
|
|
package/src/deviceerv.js
CHANGED
|
@@ -877,7 +877,7 @@ class DeviceErv extends EventEmitter {
|
|
|
877
877
|
|
|
878
878
|
//keys
|
|
879
879
|
const presetsKey = this.accountType === 'melcloud' ? 'Presets' : 'Schedule';
|
|
880
|
-
const presetsIdKey =
|
|
880
|
+
const presetsIdKey = account.type === 'melcloud' ? 'ID' : 'Id';
|
|
881
881
|
const fanKey = this.accountType === 'melcloud' ? 'FanSpeed' : 'SetFanSpeed';
|
|
882
882
|
const tempStepKey = this.accountType === 'melcloud' ? 'TemperatureIncrement' : 'HasHalfDegreeIncrements';
|
|
883
883
|
const errorKey = this.accountType === 'melcloud' ? 'HasError' : 'IsInError';
|
package/src/melcloud.js
CHANGED
|
@@ -236,18 +236,11 @@ class MelCloud extends EventEmitter {
|
|
|
236
236
|
|
|
237
237
|
const devices = buildingsList.flatMap(building => {
|
|
238
238
|
// Funkcja kapitalizująca klucze obiektu
|
|
239
|
-
|
|
240
|
-
Object.fromEntries(
|
|
241
|
-
Object.entries(obj).map(([key, value]) => [
|
|
242
|
-
key.charAt(0).toUpperCase() + key.slice(1),
|
|
243
|
-
value
|
|
244
|
-
])
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
// Rekurencyjna kapitalizacja kluczy w obiekcie lub tablicy
|
|
239
|
+
// Rekurencyjna funkcja kapitalizująca klucze w całym obiekcie (łącznie z tablicami)
|
|
248
240
|
const capitalizeKeysDeep = obj => {
|
|
249
|
-
if (Array.isArray(obj))
|
|
250
|
-
|
|
241
|
+
if (Array.isArray(obj)) {
|
|
242
|
+
return obj.map(item => capitalizeKeysDeep(item));
|
|
243
|
+
} else if (obj && typeof obj === 'object' && obj.constructor === Object) {
|
|
251
244
|
return Object.fromEntries(
|
|
252
245
|
Object.entries(obj).map(([key, value]) => [
|
|
253
246
|
key.charAt(0).toUpperCase() + key.slice(1),
|
|
@@ -259,8 +252,7 @@ class MelCloud extends EventEmitter {
|
|
|
259
252
|
};
|
|
260
253
|
|
|
261
254
|
// Funkcja tworząca finalny obiekt Device
|
|
262
|
-
const createDevice = (device, type) => {
|
|
263
|
-
// Settings już kapitalizowane w nazwach
|
|
255
|
+
const createDevice = (device, type, headers = {}) => {
|
|
264
256
|
const settingsArray = device.Settings || [];
|
|
265
257
|
|
|
266
258
|
const settingsObject = Object.fromEntries(
|
|
@@ -268,34 +260,23 @@ class MelCloud extends EventEmitter {
|
|
|
268
260
|
let parsedValue = value;
|
|
269
261
|
if (value === "True") parsedValue = true;
|
|
270
262
|
else if (value === "False") parsedValue = false;
|
|
271
|
-
else if (!isNaN(value) && value !== "") parsedValue = Number(value);
|
|
263
|
+
else if (!isNaN(Number(value)) && value.trim() !== "") parsedValue = Number(value);
|
|
272
264
|
|
|
273
265
|
const key = name.charAt(0).toUpperCase() + name.slice(1);
|
|
274
266
|
return [key, parsedValue];
|
|
275
267
|
})
|
|
276
268
|
);
|
|
277
269
|
|
|
278
|
-
// Scal Capabilities + Settings + DeviceType w Device
|
|
279
270
|
const deviceObject = {
|
|
280
|
-
...
|
|
271
|
+
...capitalizeKeysDeep(device.Capabilities || {}),
|
|
281
272
|
...settingsObject,
|
|
282
273
|
DeviceType: type
|
|
283
274
|
};
|
|
284
275
|
|
|
285
|
-
// Kapitalizacja brakujących obiektów/tablic
|
|
286
|
-
if (device.FrostProtection) device.FrostProtection = { ...capitalizeKeys(device.FrostProtection || {}) };
|
|
287
|
-
if (device.OverheatProtection) device.OverheatProtection = { ...capitalizeKeys(device.OverheatProtection || {}) };
|
|
288
|
-
if (device.HolidayMode) device.HolidayMode = { ...capitalizeKeys(device.HolidayMode || {}) };
|
|
289
|
-
|
|
290
|
-
if (Array.isArray(device.Schedule)) {
|
|
291
|
-
device.Schedule = device.Schedule.map(capitalizeKeysDeep);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// Usuń stare pola Settings i Capabilities
|
|
295
276
|
const { Settings, Capabilities, Id, GivenDisplayName, ...rest } = device;
|
|
296
277
|
|
|
297
278
|
return {
|
|
298
|
-
...rest,
|
|
279
|
+
...capitalizeKeysDeep(rest),
|
|
299
280
|
Type: type,
|
|
300
281
|
DeviceID: Id,
|
|
301
282
|
DeviceName: GivenDisplayName,
|
|
@@ -304,14 +285,14 @@ class MelCloud extends EventEmitter {
|
|
|
304
285
|
};
|
|
305
286
|
};
|
|
306
287
|
|
|
288
|
+
// Mapowanie urządzeń
|
|
307
289
|
return [
|
|
308
|
-
...(building.airToAirUnits || []).map(d => createDevice(
|
|
309
|
-
...(building.airToWaterUnits || []).map(d => createDevice(
|
|
310
|
-
...(building.airToVentilationUnits || []).map(d => createDevice(
|
|
290
|
+
...(building.airToAirUnits || []).map(d => createDevice(capitalizeKeysDeep(d), 0)),
|
|
291
|
+
...(building.airToWaterUnits || []).map(d => createDevice(capitalizeKeysDeep(d), 1)),
|
|
292
|
+
...(building.airToVentilationUnits || []).map(d => createDevice(capitalizeKeysDeep(d), 3))
|
|
311
293
|
];
|
|
312
294
|
});
|
|
313
295
|
|
|
314
|
-
|
|
315
296
|
const devicesCount = devices.length;
|
|
316
297
|
if (devicesCount === 0) {
|
|
317
298
|
devicesList.Info = 'No devices found'
|