homebridge-melcloud-control 3.1.3-beta.11 → 3.1.3-beta.12

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.
@@ -186,8 +186,12 @@
186
186
  const pusDeviceTypeErv = deviceType === 3 ? devicesByType.erv.push(device) : false;
187
187
  };
188
188
 
189
+ const ataDevices = pluginConfig[0].accounts[this.deviceIndex].ataDevices ?? [];
190
+ const atwDevices = pluginConfig[0].accounts[this.deviceIndex].atwDevices ?? [];
191
+ const ervDevices = pluginConfig[0].accounts[this.deviceIndex].ervDevices ?? [];
192
+
189
193
  //device ata
190
- for (const device of devicesByType.ata) {
194
+ devicesByType.ata.forEach((device, index) => {
191
195
  const deviceId = device.DeviceID;
192
196
  const deviceType = device.Type;
193
197
  const deviceName = device.DeviceName;
@@ -208,6 +212,11 @@
208
212
  buttonsSensors: []
209
213
  };
210
214
 
215
+ const deviceExists = ataDevices.find(device => device.id === deviceId);
216
+ if (!deviceExists) {
217
+ ataDevices.push(deviceAta);
218
+ };
219
+
211
220
  //presets
212
221
  for (const preset of devicePresets) {
213
222
  const presetId = preset.ID;
@@ -217,16 +226,25 @@
217
226
  preset.name = presetName;
218
227
  preset.displayType == 0;
219
228
  preset.namePrefix = false;
220
- deviceAta.presets.push(preset);
229
+
230
+ let presetExists = false;
231
+ for (const ataDevice of ataDevices) {
232
+ if (ataDevice.presets?.some(preset => preset.id === presetId)) {
233
+ presetExists = true;
234
+ break;
235
+ }
236
+ }
237
+
238
+ if (!presetExists) {
239
+ ataDevices[index].presets.push(preset);
240
+ };
221
241
  };
222
- textAtaPresets = `ATA Presets: ${newDevices.ataPresets.length}`
223
- newDevices.ata.push(deviceAta);
224
- };
225
- pluginConfig[0].accounts[this.deviceIndex].ataDevices = newDevices.ata;
226
- textAta = `ATA: ${newDevices.ata.length}`
242
+ textAtaPresets = `ATA Presets: ${ataDevices.presets.length}`
243
+ });
244
+ textAta = `ATA: ${ataDevices.length}`
227
245
 
228
246
  //device atw
229
- for (const device of devicesByType.atw) {
247
+ devicesByType.atw.forEach((device, index) => {
230
248
  const deviceId = device.DeviceID;
231
249
  const deviceType = device.Type;
232
250
  const deviceName = device.DeviceName;
@@ -253,6 +271,11 @@
253
271
  buttonsSensors: []
254
272
  };
255
273
 
274
+ const deviceExists = ataDevices.find(device => device.id === deviceId);
275
+ if (!deviceExists) {
276
+ ataDevices.push(deviceAta);
277
+ };
278
+
256
279
  //presets
257
280
  for (const preset of devicePresets) {
258
281
  const presetId = preset.ID;
@@ -262,16 +285,25 @@
262
285
  preset.name = presetName;
263
286
  preset.displayType == 0;
264
287
  preset.namePrefix = false;
265
- deviceAtw.presets.push(preset);
288
+
289
+ let presetExists = false;
290
+ for (const atwDevice of atwDevices) {
291
+ if (atwDevice.presets?.some(preset => preset.id === presetId)) {
292
+ presetExists = true;
293
+ break;
294
+ }
295
+ }
296
+
297
+ if (!presetExists) {
298
+ atwDevices[index].presets.push(preset);
299
+ };
266
300
  };
267
- textAtwPresets = `ATW Presets: ${newDevices.atwPresets.length}`
268
- newDevices.ata.push(deviceAtw);
269
- };
270
- pluginConfig[0].accounts[this.deviceIndex].atwDevices = newDevices.atw;
271
- textAtw = `ATW: ${newDevices.atw.length}`
301
+ textAtwPresets = `ATW Presets: ${atwDevices.presets.length}`
302
+ });
303
+ textAtw = `ATW: ${atwDevices.length}`
272
304
 
273
305
  //device erv
274
- for (const device of devicesByType.erv) {
306
+ devicesByType.erv.forEach((device, index) => {
275
307
  const deviceId = device.DeviceID;
276
308
  const deviceType = device.Type;
277
309
  const deviceName = device.DeviceName;
@@ -292,6 +324,11 @@
292
324
  buttonsSensors: []
293
325
  };
294
326
 
327
+ const deviceExists = ataDevices.find(device => device.id === deviceId);
328
+ if (!deviceExists) {
329
+ ataDevices.push(deviceAta);
330
+ };
331
+
295
332
  //presets
296
333
  for (const preset of devicePresets) {
297
334
  const presetId = preset.ID;
@@ -301,13 +338,22 @@
301
338
  preset.name = presetName;
302
339
  preset.displayType == 0;
303
340
  preset.namePrefix = false;
304
- deviceErv.presets.push(preset);
341
+
342
+ let presetExists = false;
343
+ for (const ervDevice of ervDevices) {
344
+ if (ervDevice.presets?.some(preset => preset.id === presetId)) {
345
+ presetExists = true;
346
+ break;
347
+ }
348
+ }
349
+
350
+ if (!presetExists) {
351
+ ervDevices[index].presets.push(preset);
352
+ };
305
353
  };
306
- textErvPresets = `ERV Presets: ${newDevices.ErvPresets.length}`
307
- newDevices.erv.push(deviceErv);
308
- };
309
- pluginConfig[0].accounts[this.deviceIndex].ervDevices = newDevices.erv;
310
- textErv = `ERV: ${newDevices.erv.length}`
354
+ textErvPresets = `ERV Presets: ${ervDevices.presets.length}`
355
+ });
356
+ textErv = `ERV: ${ervDevices.length}`
311
357
 
312
358
  const newDevicesCount = newDevices.ata.length + newDevices.atw.length + newDevices.erv.length ?? 0;
313
359
  const newPresetsCount = newDevices.ataPresets.length + newDevices.atwPresets.length + newDevices.ervPresets.length ?? 0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "3.1.3-beta.11",
4
+ "version": "3.1.3-beta.12",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",