homebridge-melcloud-control 3.1.3-beta.14 → 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.
@@ -151,23 +151,26 @@
151
151
  const info = response.info ?? '';
152
152
  const status = response.status;
153
153
  const devices = response.data ?? [];
154
- const devicesByType = {
155
- ata: [],
156
- atw: [],
157
- erv: []
158
- };
159
-
160
- //info text
161
- let textAta = 'ATA: 0';
162
- let textAtaPresets = 'ATA Presets: 0';
163
- let textAtw = 'ATW: 0';
164
- let textAtwPresets = 'ATW Presets: 0';
165
- let textErv = 'ERV: 0';
166
- let textErvPresets = 'ERV Presets: 0';
167
154
 
168
155
  //response status
169
156
  switch (status) {
170
157
  case 0:
158
+ //new found devices
159
+ const newDevices = {
160
+ ata: [],
161
+ ataPresets: [],
162
+ atw: [],
163
+ atwPresets: [],
164
+ erv: [],
165
+ ervPresets: [],
166
+ };
167
+
168
+ const devicesByType = {
169
+ ata: [],
170
+ atw: [],
171
+ erv: []
172
+ };
173
+
171
174
  //get devices by type
172
175
  for (const device of devices) {
173
176
  const deviceType = device.Type;
@@ -176,10 +179,22 @@
176
179
  const pusDeviceTypeErv = deviceType === 3 ? devicesByType.erv.push(device) : false;
177
180
  };
178
181
 
182
+ //devices from config
179
183
  const ataDevices = pluginConfig[0].accounts[this.deviceIndex].ataDevices ?? [];
180
184
  const atwDevices = pluginConfig[0].accounts[this.deviceIndex].atwDevices ?? [];
181
185
  const ervDevices = pluginConfig[0].accounts[this.deviceIndex].ervDevices ?? [];
182
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
+
183
198
  //device ata
184
199
  devicesByType.ata.forEach((device, index) => {
185
200
  const deviceId = device.DeviceID;
@@ -205,6 +220,7 @@
205
220
  const deviceExists = ataDevices.find(device => device.id === deviceId);
206
221
  if (!deviceExists) {
207
222
  ataDevices.push(deviceAta);
223
+ newDevices.ata.push(deviceAta);
208
224
  };
209
225
 
210
226
  //presets
@@ -227,11 +243,13 @@
227
243
 
228
244
  if (!presetExists) {
229
245
  ataDevices[index].presets.push(preset);
246
+ newDevices.ataPresets.push(preset);
230
247
  };
231
248
  };
232
- textAtaPresets = `ATA Presets: ${ataDevices[index].presets.length}`
249
+ ataPresetsCount = newDevices.ataPresets.length;
250
+ textAtaPresets = `ATA Presets: ${ataPresetsCount}`
233
251
  });
234
- textAta = `ATA: ${ataDevices.length}`
252
+ textAta = `ATA: ${newDevices.ata.length}`
235
253
 
236
254
  //device atw
237
255
  devicesByType.atw.forEach((device, index) => {
@@ -264,6 +282,7 @@
264
282
  const deviceExists = atwDevices.find(device => device.id === deviceId);
265
283
  if (!deviceExists) {
266
284
  atwDevices.push(deviceAtw);
285
+ newDevices.atw.push(deviceAtw);
267
286
  };
268
287
 
269
288
  //presets
@@ -286,11 +305,13 @@
286
305
 
287
306
  if (!presetExists) {
288
307
  atwDevices[index].presets.push(preset);
308
+ newDevices.atwPresets.push(preset);
289
309
  };
290
310
  };
291
- textAtwPresets = `ATW Presets: ${atwDevices[index].presets.length}`
311
+ atwPresetsCount = newDevices.atwPresets.length;
312
+ textAtwPresets = `ATW Presets: ${atwPresetsCount}`
292
313
  });
293
- textAtw = `ATW: ${atwDevices.length}`
314
+ textAtw = `ATW: ${newDevices.atw.length}`
294
315
 
295
316
  //device erv
296
317
  devicesByType.erv.forEach((device, index) => {
@@ -317,6 +338,7 @@
317
338
  const deviceExists = ervDevices.find(device => device.id === deviceId);
318
339
  if (!deviceExists) {
319
340
  ervDevices.push(deviceErv);
341
+ newDevices.erv.push(deviceErv);
320
342
  };
321
343
 
322
344
  //presets
@@ -339,14 +361,16 @@
339
361
 
340
362
  if (!presetExists) {
341
363
  ervDevices[index].presets.push(preset);
364
+ newDevices.ervPresets.push(preset);
342
365
  };
343
366
  };
344
- textErvPresets = `ERV Presets: ${ervDevices[index].presets.length}`
367
+ ervPresetsCount = newDevices.ervPresets.length;
368
+ textErvPresets = `ERV Presets: ${ervPresetsCount}`
345
369
  });
346
- textErv = `ERV: ${ervDevices.length}`
370
+ textErv = `ERV: ${newDevices.erv.length}`
347
371
 
348
- const newDevicesCount = ataDevices[index].length + atwDevices[index].length + ervDevices[index].length ?? 0;
349
- const newPresetsCount = ataDevices[index].presets.length + atwDevices[index].presets.length + ervDevices[index].presets.length ?? 0;
372
+ const newDevicesCount = newDevices.ata.length + newDevices.atw.length + newDevices.erv.length ?? 0;
373
+ const newPresetsCount = ataPresetsCount + atwPresetsCount + ervPresetsCount ?? 0;
350
374
  if (newDevicesCount === 0 && newPresetsCount === 0) {
351
375
  document.getElementById('info').innerHTML = 'No new devices found.';
352
376
  document.getElementById('info').style.color = 'white';
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.14",
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",