homebridge-melcloud-control 4.1.2-beta.42 → 4.1.2-beta.44
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 +42 -31
- package/package.json +1 -1
|
@@ -254,44 +254,55 @@
|
|
|
254
254
|
const removedErv = removeStaleDevices(account.ervDevices, devicesByType.erv);
|
|
255
255
|
|
|
256
256
|
const handleDevices = (devicesInMelCloud, devicesInConfig, typeString, newArr, newPresets) => {
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
if (!devicesInConfig.some(dev => String(dev.id) === device.DeviceID)) {
|
|
270
|
-
devicesInConfig.push(deviceObj);
|
|
271
|
-
newArr.push(deviceObj);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const deviceInConfig = devicesInConfig.find(dev => String(dev.id) === device.DeviceID);
|
|
275
|
-
if (deviceInConfig) {
|
|
276
|
-
const idKey = account.type === 'melcloud' ? 'ID' : 'Id';
|
|
277
|
-
const typeKey = account.type === 'melcloud' ? 'Presets' : 'Schedules';
|
|
278
|
-
const presets = device[typeKey] || [];
|
|
279
|
-
presets.forEach((preset, index) => {
|
|
280
|
-
const presetObj = {
|
|
281
|
-
id: preset[idKey],
|
|
257
|
+
try {
|
|
258
|
+
const configDevicesMap = new Map(devicesInConfig.map(dev => [String(dev.id), dev]));
|
|
259
|
+
|
|
260
|
+
devicesInMelCloud.forEach(device => {
|
|
261
|
+
const deviceId = String(device.DeviceID);
|
|
262
|
+
let deviceInConfig = configDevicesMap.get(deviceId);
|
|
263
|
+
|
|
264
|
+
if (!deviceInConfig) {
|
|
265
|
+
deviceInConfig = {
|
|
266
|
+
id: device.DeviceID,
|
|
267
|
+
type: device.Type,
|
|
268
|
+
typeString,
|
|
282
269
|
displayType: 0,
|
|
283
|
-
name:
|
|
284
|
-
|
|
270
|
+
name: device.DeviceName,
|
|
271
|
+
presets: [],
|
|
272
|
+
schedules: [],
|
|
273
|
+
buttonsSensors: []
|
|
285
274
|
};
|
|
275
|
+
devicesInConfig.push(deviceInConfig);
|
|
276
|
+
newArr.push(deviceInConfig);
|
|
277
|
+
configDevicesMap.set(deviceId, deviceInConfig);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const idKey = account.type === 'melcloud' ? 'ID' : 'Id';
|
|
281
|
+
const typeKey = account.type === 'melcloud' ? 'Presets' : 'Schedule';
|
|
282
|
+
const typeKey1 = account.type === 'melcloud' ? 'presets' : 'schedules';
|
|
283
|
+
const presets = device[typeKey] || [];
|
|
286
284
|
|
|
287
|
-
|
|
288
|
-
|
|
285
|
+
const presetsInConfig = deviceInConfig[typeKey1] || [];
|
|
286
|
+
const presetIds = new Set(presetsInConfig.map(p => String(p.id)));
|
|
287
|
+
|
|
288
|
+
presets.forEach((preset, index) => {
|
|
289
|
+
const presetId = String(preset[idKey]);
|
|
290
|
+
if (!presetIds.has(presetId)) {
|
|
291
|
+
const presetObj = {
|
|
292
|
+
id: presetId,
|
|
293
|
+
displayType: 0,
|
|
294
|
+
name: preset.NumberDescription || `Schedule ${index}`,
|
|
295
|
+
namePrefix: false
|
|
296
|
+
};
|
|
289
297
|
presetsInConfig.push(presetObj);
|
|
290
298
|
newPresets.push(presetObj);
|
|
299
|
+
presetIds.add(presetId);
|
|
291
300
|
}
|
|
292
301
|
});
|
|
293
|
-
}
|
|
294
|
-
})
|
|
302
|
+
});
|
|
303
|
+
} catch (error) {
|
|
304
|
+
updateInfo('info1', `Error while processing device: ${error.message || error}`, 'red');
|
|
305
|
+
}
|
|
295
306
|
};
|
|
296
307
|
|
|
297
308
|
handleDevices(devicesByType.ata, account.ataDevices, "Air Conditioner", newDevices.ata, newDevices.ataPresets);
|
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.44",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|