homebridge-melcloud-control 3.1.3-beta.10 → 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,18 +226,25 @@
217
226
  preset.name = presetName;
218
227
  preset.displayType == 0;
219
228
  preset.namePrefix = false;
220
- newDevices.ataPresets.push(preset);
221
- };
222
- deviceAta.presets = newDevices.ataPresets;
223
- textAtaPresets = `ATA Presets: ${newDevices.ataPresets.length}`
224
229
 
225
- newDevices.ata.push(deviceAta);
226
- };
227
- pluginConfig[0].accounts[this.deviceIndex].ataDevices = newDevices.ata;
228
- textAta = `ATA: ${newDevices.ata.length}`
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
+ };
241
+ };
242
+ textAtaPresets = `ATA Presets: ${ataDevices.presets.length}`
243
+ });
244
+ textAta = `ATA: ${ataDevices.length}`
229
245
 
230
246
  //device atw
231
- for (const device of devicesByType.atw) {
247
+ devicesByType.atw.forEach((device, index) => {
232
248
  const deviceId = device.DeviceID;
233
249
  const deviceType = device.Type;
234
250
  const deviceName = device.DeviceName;
@@ -255,6 +271,11 @@
255
271
  buttonsSensors: []
256
272
  };
257
273
 
274
+ const deviceExists = ataDevices.find(device => device.id === deviceId);
275
+ if (!deviceExists) {
276
+ ataDevices.push(deviceAta);
277
+ };
278
+
258
279
  //presets
259
280
  for (const preset of devicePresets) {
260
281
  const presetId = preset.ID;
@@ -264,18 +285,25 @@
264
285
  preset.name = presetName;
265
286
  preset.displayType == 0;
266
287
  preset.namePrefix = false;
267
- newDevices.atwPresets.push(preset);
268
- };
269
- textAtwPresets = `ATW Presets: ${newDevices.atwPresets.length}`
270
288
 
271
- deviceAtw.presets = deviceAtw.atwPresets;
272
- newDevices.ata.push(deviceAtw);
273
- };
274
- pluginConfig[0].accounts[this.deviceIndex].atwDevices = newDevices.atw;
275
- textAtw = `ATW: ${newDevices.atw.length}`
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
+ };
300
+ };
301
+ textAtwPresets = `ATW Presets: ${atwDevices.presets.length}`
302
+ });
303
+ textAtw = `ATW: ${atwDevices.length}`
276
304
 
277
305
  //device erv
278
- for (const device of devicesByType.erv) {
306
+ devicesByType.erv.forEach((device, index) => {
279
307
  const deviceId = device.DeviceID;
280
308
  const deviceType = device.Type;
281
309
  const deviceName = device.DeviceName;
@@ -296,6 +324,11 @@
296
324
  buttonsSensors: []
297
325
  };
298
326
 
327
+ const deviceExists = ataDevices.find(device => device.id === deviceId);
328
+ if (!deviceExists) {
329
+ ataDevices.push(deviceAta);
330
+ };
331
+
299
332
  //presets
300
333
  for (const preset of devicePresets) {
301
334
  const presetId = preset.ID;
@@ -305,15 +338,22 @@
305
338
  preset.name = presetName;
306
339
  preset.displayType == 0;
307
340
  preset.namePrefix = false;
308
- newDevices.atwPresets.push(preset);
309
- };
310
- textErvPresets = `ERV Presets: ${newDevices.ErvPresets.length}`
311
341
 
312
- deviceErv.presets = deviceErv.ervPresets;
313
- newDevices.erv.push(deviceErv);
314
- };
315
- pluginConfig[0].accounts[this.deviceIndex].ervDevices = newDevices.erv;
316
- textErv = `ERV: ${newDevices.erv.length}`
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
+ };
353
+ };
354
+ textErvPresets = `ERV Presets: ${ervDevices.presets.length}`
355
+ });
356
+ textErv = `ERV: ${ervDevices.length}`
317
357
 
318
358
  const newDevicesCount = newDevices.ata.length + newDevices.atw.length + newDevices.erv.length ?? 0;
319
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.10",
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",