homebridge-melcloud-control 3.1.3-beta.15 → 3.1.3-beta.16

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.
@@ -155,23 +155,22 @@
155
155
  //response status
156
156
  switch (status) {
157
157
  case 0:
158
+ //new found devices
159
+ const newDevices = {
160
+ ata: [],
161
+ ataPresets: [],
162
+ atw: [],
163
+ atwPresets: [],
164
+ erv: [],
165
+ ervPresets: [],
166
+ };
167
+
158
168
  const devicesByType = {
159
169
  ata: [],
160
170
  atw: [],
161
171
  erv: []
162
172
  };
163
173
 
164
- //info text
165
- let textAta = 'ATA: 0';
166
- let textAtaPresets = 'ATA Presets: 0';
167
- let ataPresetsCount = 0;
168
- let textAtw = 'ATW: 0';
169
- let textAtwPresets = 'ATW Presets: 0';
170
- let atwPresetsCount = 0;
171
- let textErv = 'ERV: 0';
172
- let textErvPresets = 'ERV Presets: 0';
173
- let ervPresetsCount = 0;
174
-
175
174
  //get devices by type
176
175
  for (const device of devices) {
177
176
  const deviceType = device.Type;
@@ -180,10 +179,22 @@
180
179
  const pusDeviceTypeErv = deviceType === 3 ? devicesByType.erv.push(device) : false;
181
180
  };
182
181
 
182
+ //devices from config
183
183
  const ataDevices = pluginConfig[0].accounts[this.deviceIndex].ataDevices ?? [];
184
184
  const atwDevices = pluginConfig[0].accounts[this.deviceIndex].atwDevices ?? [];
185
185
  const ervDevices = pluginConfig[0].accounts[this.deviceIndex].ervDevices ?? [];
186
186
 
187
+ //info text
188
+ let textAta = 'ATA: 0';
189
+ let textAtaPresets = 'ATA Presets: 0';
190
+ let ataPresetsCount = 0;
191
+ let textAtw = 'ATW: 0';
192
+ let textAtwPresets = 'ATW Presets: 0';
193
+ let atwPresetsCount = 0;
194
+ let textErv = 'ERV: 0';
195
+ let textErvPresets = 'ERV Presets: 0';
196
+ let ervPresetsCount = 0;
197
+
187
198
  //device ata
188
199
  devicesByType.ata.forEach((device, index) => {
189
200
  const deviceId = device.DeviceID;
@@ -209,6 +220,7 @@
209
220
  const deviceExists = ataDevices.find(device => device.id === deviceId);
210
221
  if (!deviceExists) {
211
222
  ataDevices.push(deviceAta);
223
+ newDevices.ata.push(deviceAta);
212
224
  };
213
225
 
214
226
  //presets
@@ -231,12 +243,13 @@
231
243
 
232
244
  if (!presetExists) {
233
245
  ataDevices[index].presets.push(preset);
246
+ newDevices.ataPresets.push(preset);
234
247
  };
235
248
  };
236
- ataPresetsCount = ataDevices[index].presets.length;
249
+ ataPresetsCount = newDevices.ataPresets.length;
237
250
  textAtaPresets = `ATA Presets: ${ataPresetsCount}`
238
251
  });
239
- textAta = `ATA: ${ataDevices.length}`
252
+ textAta = `ATA: ${newDevices.ata.length}`
240
253
 
241
254
  //device atw
242
255
  devicesByType.atw.forEach((device, index) => {
@@ -269,6 +282,7 @@
269
282
  const deviceExists = atwDevices.find(device => device.id === deviceId);
270
283
  if (!deviceExists) {
271
284
  atwDevices.push(deviceAtw);
285
+ newDevices.atw.push(deviceAtw);
272
286
  };
273
287
 
274
288
  //presets
@@ -291,12 +305,13 @@
291
305
 
292
306
  if (!presetExists) {
293
307
  atwDevices[index].presets.push(preset);
308
+ newDevices.atwPresets.push(preset);
294
309
  };
295
310
  };
296
- atwPresetsCount = atwDevices[index].presets.length;
311
+ atwPresetsCount = newDevices.atwPresets.length;
297
312
  textAtwPresets = `ATW Presets: ${atwPresetsCount}`
298
313
  });
299
- textAtw = `ATW: ${atwDevices.length}`
314
+ textAtw = `ATW: ${newDevices.atw.length}`
300
315
 
301
316
  //device erv
302
317
  devicesByType.erv.forEach((device, index) => {
@@ -323,6 +338,7 @@
323
338
  const deviceExists = ervDevices.find(device => device.id === deviceId);
324
339
  if (!deviceExists) {
325
340
  ervDevices.push(deviceErv);
341
+ newDevices.erv.push(deviceErv);
326
342
  };
327
343
 
328
344
  //presets
@@ -345,14 +361,15 @@
345
361
 
346
362
  if (!presetExists) {
347
363
  ervDevices[index].presets.push(preset);
364
+ newDevices.ervPresets.push(preset);
348
365
  };
349
366
  };
350
- ervPresetsCount = ervDevices[index].presets.length;
367
+ ervPresetsCount = newDevices.ervPresets.length;
351
368
  textErvPresets = `ERV Presets: ${ervPresetsCount}`
352
369
  });
353
- textErv = `ERV: ${ervDevices.length}`
370
+ textErv = `ERV: ${newDevices.erv.length}`
354
371
 
355
- const newDevicesCount = ataDevices.length + atwDevices.length + ervDevices.length ?? 0;
372
+ const newDevicesCount = newDevices.ata.length + newDevices.atw.length + newDevices.erv.length ?? 0;
356
373
  const newPresetsCount = ataPresetsCount + atwPresetsCount + ervPresetsCount ?? 0;
357
374
  if (newDevicesCount === 0 && newPresetsCount === 0) {
358
375
  document.getElementById('info').innerHTML = 'No new devices found.';
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.15",
4
+ "version": "3.1.3-beta.16",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",