homebridge-melcloud-control 3.1.3-beta.0 → 3.1.3-beta.2

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.
@@ -210,8 +210,8 @@
210
210
  buttonsSensors: []
211
211
  };
212
212
 
213
- const ataDevicesExist = pluginConfig[0].accounts[this.deviceIndex].ataDevices ?? false;
214
- const ataDevices = ataDevicesExist ? pluginConfig[0].accounts[this.deviceIndex].ataDevices : pluginConfig[0].accounts[this.deviceIndex].ataDevices = [];
213
+ const ataDevicesExist = pluginConfig[0].accounts[this.deviceIndex].ataDevices ?? [];
214
+ const ataDevices = ataDevicesExist.length > 0 ? pluginConfig[0].accounts[this.deviceIndex].ataDevices : pluginConfig[0].accounts[this.deviceIndex].ataDevices = [];
215
215
 
216
216
  const ataDeviceIdExist = ataDevices.some(device => device.id === deviceId);
217
217
  const pushTypeAta = ataDeviceIdExist ? false : ataDevices.push(deviceAta);
@@ -229,8 +229,8 @@
229
229
  preset.displayType == 0;
230
230
  preset.namePrefix = false;
231
231
 
232
- const ataPresetsExist = pluginConfig[0].accounts[this.deviceIndex].ataDevices[index].presets ?? false;
233
- const ataPresets = ataPresetsExist ? pluginConfig[0].accounts[this.deviceIndex].ataDevices[index].presets : pluginConfig[0].accounts[this.deviceIndex].ataDevices[index].presets = [];
232
+ const ataPresetsExist = pluginConfig[0].accounts[this.deviceIndex].ataDevices[index].presets ?? [];
233
+ const ataPresets = ataPresetsExist.length > 0 ? pluginConfig[0].accounts[this.deviceIndex].ataDevices[index].presets : pluginConfig[0].accounts[this.deviceIndex].ataDevices[index].presets = [];
234
234
  const ataPresetIdExist = ataPresets.some(preset => preset.id === presetId);
235
235
  const pushPresetAta = ataPresetIdExist ? false : ataPresets.push(preset);
236
236
  const pushNewPreset = ataPresetIdExist ? false : newDevices.ataPresets.push(preset);
@@ -241,7 +241,7 @@
241
241
  //compare presets
242
242
  const presetsOnMelCloud = devicePresets;
243
243
  const presetsAtaInConfig = pluginConfig[0].accounts[this.deviceIndex].ataDevices[index].presets;
244
- presetsAtaInConfig = syncArrays(presetsOnMelCloud, presetsAtaInConfig);
244
+ pluginConfig[0].accounts[this.deviceIndex].ataDevices[index].presets = syncArrays(presetsOnMelCloud, presetsAtaInConfig);
245
245
  });
246
246
 
247
247
  //get device info fom devices atw
@@ -273,8 +273,8 @@
273
273
  presets: [],
274
274
  buttonsSensors: []
275
275
  };
276
- const atwDevicesExist = pluginConfig[0].accounts[this.deviceIndex].atwDevices ?? false;
277
- const atwDevices = atwDevicesExist ? pluginConfig[0].accounts[this.deviceIndex].atwDevices : pluginConfig[0].accounts[this.deviceIndex].atwDevices = [];
276
+ const atwDevicesExist = pluginConfig[0].accounts[this.deviceIndex].atwDevices ?? [];
277
+ const atwDevices = atwDevicesExist.length > 0 ? pluginConfig[0].accounts[this.deviceIndex].atwDevices : pluginConfig[0].accounts[this.deviceIndex].atwDevices = [];
278
278
  const atwDeviceIdExist = atwDevices.some(device => device.id === deviceId);
279
279
  const pushTypeAtw = atwDeviceIdExist ? false : atwDevices.push(deviceAtw);
280
280
  const pushNewDevice = atwDeviceIdExist ? false : newDevices.atw.push(device);
@@ -291,8 +291,8 @@
291
291
  preset.displayType == 0;
292
292
  preset.namePrefix = false;
293
293
 
294
- const atwPresetsExist = pluginConfig[0].accounts[this.deviceIndex].atwDevices[index].presets ?? false;
295
- const atwPresets = atwPresetsExist ? pluginConfig[0].accounts[this.deviceIndex].atwDevices[index].presets : pluginConfig[0].accounts[this.deviceIndex].atwDevices[index].presets = [];
294
+ const atwPresetsExist = pluginConfig[0].accounts[this.deviceIndex].atwDevices[index].presets ?? [];
295
+ const atwPresets = atwPresetsExist.length > 0 ? pluginConfig[0].accounts[this.deviceIndex].atwDevices[index].presets : pluginConfig[0].accounts[this.deviceIndex].atwDevices[index].presets = [];
296
296
  const atwPresetIdExist = atwPresets.some(preset => preset.id === presetId);
297
297
  const pushPresetAtw = atwPresetIdExist ? false : atwPresets.push(preset);
298
298
  const pushNewPreset = atwPresetIdExist ? false : newDevices.atwPresets.push(preset);
@@ -302,7 +302,7 @@
302
302
 
303
303
  const presetsOnMelCloud = devicePresets;
304
304
  const presetsAtwInConfig = pluginConfig[0].accounts[this.deviceIndex].atwDevices[index].presets;
305
- presetsAtwInConfig = syncArrays(presetsOnMelCloud, presetsAtwInConfig);
305
+ pluginConfig[0].accounts[this.deviceIndex].atwDevices[index].presets = syncArrays(presetsOnMelCloud, presetsAtwInConfig);
306
306
  });
307
307
 
308
308
  //get device info fom devices erv
@@ -328,8 +328,8 @@
328
328
  presets: [],
329
329
  buttonsSensors: []
330
330
  };
331
- const ervDevicesExist = pluginConfig[0].accounts[this.deviceIndex].ervDevices ?? false;
332
- const ervDevices = ervDevicesExist ? pluginConfig[0].accounts[this.deviceIndex].ervDevices : pluginConfig[0].accounts[this.deviceIndex].ervDevices = [];
331
+ const ervDevicesExist = pluginConfig[0].accounts[this.deviceIndex].ervDevices ?? [];
332
+ const ervDevices = ervDevicesExist.length > 0 ? pluginConfig[0].accounts[this.deviceIndex].ervDevices : pluginConfig[0].accounts[this.deviceIndex].ervDevices = [];
333
333
  const ervDeviceIdExist = ervDevices.some(device => device.id === deviceId);
334
334
  const pushTypeerv = ervDeviceIdExist ? false : ervDevices.push(deviceErv);
335
335
  const pushNewDevice = ervDeviceIdExist ? false : newDevices.erv.push(device);
@@ -346,8 +346,8 @@
346
346
  preset.displayType == 0;
347
347
  preset.namePrefix = false;
348
348
 
349
- const ervPresetsExist = pluginConfig[0].accounts[this.deviceIndex].ervDevices[index].presets ?? false;
350
- const ervPresets = ervPresetsExist ? pluginConfig[0].accounts[this.deviceIndex].ervDevices[index].presets : pluginConfig[0].accounts[this.deviceIndex].ervDevices[index].presets = [];
349
+ const ervPresetsExist = pluginConfig[0].accounts[this.deviceIndex].ervDevices[index].presets ?? [];
350
+ const ervPresets = ervPresetsExist.length > 0 ? pluginConfig[0].accounts[this.deviceIndex].ervDevices[index].presets : pluginConfig[0].accounts[this.deviceIndex].ervDevices[index].presets = [];
351
351
  const ervPresetIdExist = ervPresets.some(preset => preset.id === presetId);
352
352
  const pushPresetErv = ervPresetIdExist ? false : ervPresets.push(preset);
353
353
  const pushNewPreset = ervPresetIdExist ? false : newDevices.ervPresets.push(preset);
@@ -357,19 +357,19 @@
357
357
 
358
358
  const presetsOnMelCloud = devicePresets;
359
359
  const presetsErvInConfig = pluginConfig[0].accounts[this.deviceIndex].ervDevices[index].presets;
360
- presetsErvInConfig = await syncArrays(presetsOnMelCloud, presetsErvInConfig);
360
+ pluginConfig[0].accounts[this.deviceIndex].ervDevices[index].presets = await syncArrays(presetsOnMelCloud, presetsErvInConfig);
361
361
  });
362
362
 
363
363
  //compare arrays and update array in config
364
364
  const devicesOnMelCloud = devices;
365
365
  const devicesAtaInConfig = pluginConfig[0].accounts[this.deviceIndex].ataDevices;
366
- devicesAtaInConfig = await syncArrays(devicesOnMelCloud, devicesAtaInConfig);
366
+ pluginConfig[0].accounts[this.deviceIndex].ataDevices = await syncArrays(devicesOnMelCloud, devicesAtaInConfig);
367
367
 
368
368
  const devicesAtwInConfig = pluginConfig[0].accounts[this.deviceIndex].atwDevices;
369
- devicesAtwInConfig = await syncArrays(devicesOnMelCloud, devicesAtwInConfig);
369
+ pluginConfig[0].accounts[this.deviceIndex].atwDevices = await syncArrays(devicesOnMelCloud, devicesAtwInConfig);
370
370
 
371
371
  const devicesErvInConfig = pluginConfig[0].accounts[this.deviceIndex].ervDevices;
372
- devicesErvInConfig = await syncArrays(devicesOnMelCloud, devicesErvInConfig);
372
+ pluginConfig[0].accounts[this.deviceIndex].ervDevices = await syncArrays(devicesOnMelCloud, devicesErvInConfig);
373
373
 
374
374
  const newDevicesCount = newDevices.ata.length + newDevices.atw.length + newDevices.erv.length ?? 0;
375
375
  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.0",
4
+ "version": "3.1.3-beta.2",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",