homebridge-melcloud-control 4.4.1-beta.42 → 4.4.1-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 +24 -26
- package/package.json +1 -1
|
@@ -205,13 +205,12 @@
|
|
|
205
205
|
});
|
|
206
206
|
|
|
207
207
|
// Generic remove function
|
|
208
|
-
function removeStaleEntities(configEntities, MelcloudEntities, getConfigId, getMelcloudId
|
|
208
|
+
function removeStaleEntities(configEntities, MelcloudEntities, getConfigId, getMelcloudId) {
|
|
209
209
|
const serverIds = new Set((MelcloudEntities ?? []).map(item => String(getMelcloudId(item))));
|
|
210
210
|
const removedEntities = [];
|
|
211
211
|
|
|
212
212
|
for (let i = configEntities.length - 1; i >= 0; i--) {
|
|
213
213
|
const entity = configEntities[i];
|
|
214
|
-
if (filterFn && !filterFn(entity)) continue; // jeśli nie dotyczy tego urządzenia, pomiń
|
|
215
214
|
const entityId = String(getConfigId(entity));
|
|
216
215
|
|
|
217
216
|
if (!serverIds.has(entityId)) {
|
|
@@ -223,6 +222,13 @@
|
|
|
223
222
|
return removedEntities;
|
|
224
223
|
}
|
|
225
224
|
|
|
225
|
+
function getScenesForDevice(unitId, scenesInMelCloud) {
|
|
226
|
+
return (scenesInMelCloud ?? []).filter(scene => {
|
|
227
|
+
const allSettings = [...(scene.AtaSceneSettings ?? []), ...(scene.AtwSceneSettings ?? []), ...(scene.ErvSceneSettings ?? [])];
|
|
228
|
+
return allSettings.some(s => String(s.UnitId) === String(unitId));
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
226
232
|
|
|
227
233
|
// Update info on page
|
|
228
234
|
function updateInfo(id, text, color) {
|
|
@@ -233,22 +239,6 @@
|
|
|
233
239
|
}
|
|
234
240
|
}
|
|
235
241
|
|
|
236
|
-
// Map UnitId → Scenes for quick lookup
|
|
237
|
-
function mapUnitIdToScenes(scenesInMelCloud) {
|
|
238
|
-
const map = new Map();
|
|
239
|
-
|
|
240
|
-
(scenesInMelCloud ?? []).forEach(scene => {
|
|
241
|
-
const allSceneSettings = [...(scene.AtaSceneSettings ?? []), ...(scene.AtwSceneSettings ?? []), ...(scene.ErvSceneSettings ?? [])];
|
|
242
|
-
allSceneSettings.forEach(setting => {
|
|
243
|
-
const unitId = String(setting.UnitId);
|
|
244
|
-
if (!map.has(unitId)) map.set(unitId, []);
|
|
245
|
-
map.get(unitId).push(scene);
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
return map;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
242
|
// Login & Sync Logic
|
|
253
243
|
document.getElementById('logIn').addEventListener('click', async () => {
|
|
254
244
|
homebridge.showSpinner();
|
|
@@ -287,10 +277,8 @@
|
|
|
287
277
|
const removedFromConfigAta = removeStaleEntities(account.ataDevices, devicesInMelCloudByType.ata, d => d.id, d => d.DeviceID);
|
|
288
278
|
const removedFromConfigAtw = removeStaleEntities(account.atwDevices, devicesInMelCloudByType.atw, d => d.id, d => d.DeviceID);
|
|
289
279
|
const removedFromConfigErv = removeStaleEntities(account.ervDevices, devicesInMelCloudByType.erv, d => d.id, d => d.DeviceID);
|
|
290
|
-
const removedFromConfig = { ataPresets: [], atwPresets: [], ervPresets: [], ataSchedules: [], atwSchedules: [], ervSchedules: [], scenes: [] };
|
|
291
280
|
|
|
292
|
-
|
|
293
|
-
const unitIdToScenes = mapUnitIdToScenes(scenesInMelCloud);
|
|
281
|
+
const removedFromConfig = { ataPresets: [], atwPresets: [], ervPresets: [], ataSchedules: [], atwSchedules: [], ervSchedules: [], scenes: [] };
|
|
294
282
|
|
|
295
283
|
// Generic device handler (obsługuje urządzenia, presety, harmonogramy i sceny)
|
|
296
284
|
const handleDevices = (devicesInMelCloud, devicesInConfig, deviceTypeString, newDevices, newPresets, newSchedules, newScenes) => {
|
|
@@ -351,14 +339,24 @@
|
|
|
351
339
|
|
|
352
340
|
// SCENES
|
|
353
341
|
deviceInConfig.scenes = deviceInConfig.scenes ?? [];
|
|
354
|
-
const scenesForDevice = unitIdToScenes.get(deviceId) ?? [];
|
|
355
342
|
|
|
356
|
-
//
|
|
357
|
-
|
|
343
|
+
// tylko sceny MELCloud należące do tego urządzenia
|
|
344
|
+
const scenesInMelCloudForDevice = getScenesForDevice(deviceId, scenesInMelCloud);
|
|
345
|
+
|
|
346
|
+
// USUWANIE: scena istnieje globalnie, ale nie należy już do tego urządzenia
|
|
347
|
+
removedFromConfig.scenes.push(
|
|
348
|
+
...removeStaleEntities(
|
|
349
|
+
deviceInConfig.scenes,
|
|
350
|
+
scenesInMelCloudForDevice,
|
|
351
|
+
s => s.id,
|
|
352
|
+
s => s.Id
|
|
353
|
+
)
|
|
354
|
+
);
|
|
358
355
|
|
|
359
|
-
//
|
|
356
|
+
// DODAWANIE: brakujące sceny dla urządzenia
|
|
360
357
|
const existingSceneIds = new Set(deviceInConfig.scenes.map(s => String(s.id)));
|
|
361
|
-
|
|
358
|
+
|
|
359
|
+
scenesInMelCloudForDevice.forEach((scene, index) => {
|
|
362
360
|
const sceneId = String(scene.Id);
|
|
363
361
|
if (!existingSceneIds.has(sceneId)) {
|
|
364
362
|
const sceneObj = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.4.1-beta.
|
|
4
|
+
"version": "4.4.1-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",
|