homebridge-melcloud-control 4.0.1-beta.4 → 4.0.1-beta.6

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.
@@ -257,34 +257,34 @@
257
257
 
258
258
  const handleDevices = (devicesInMelCloud, devicesInConfig, typeString, newArr, newPresets) => {
259
259
  devicesInMelCloud.forEach(device => {
260
- const { DeviceID: id, Type: type, DeviceName: name, Presets: presets = [] } = device;
261
- const devObj = structuredClone({
262
- id,
263
- type,
260
+ const deviceObj = {
261
+ id: device.DeviceID,
262
+ type: device.Type,
264
263
  typeString,
265
- name,
266
264
  displayType: 0,
267
- presets: [],
265
+ name: device.DeviceName,
266
+ presets: device.Presets ?? [],
268
267
  buttonsSensors: []
269
- });
268
+ };
270
269
 
271
- if (!devicesInConfig.some(device => String(device.id) === id)) {
272
- devicesInConfig.push(devObj);
273
- newArr.push(structuredClone(devObj));
270
+ if (!devicesInConfig.some(device => String(device.id) === deviceObj.id)) {
271
+ devicesInConfig.push(deviceObj);
272
+ newArr.push(deviceObj);
274
273
  }
275
274
 
275
+ const presets = device.Presets || [];
276
276
  presets.forEach(preset => {
277
- const p = structuredClone({
277
+ const presetObj = {
278
278
  id: preset.ID,
279
- name: preset.NumberDescription,
280
279
  displayType: 0,
280
+ name: preset.NumberDescription,
281
281
  namePrefix: false
282
- });
282
+ };
283
283
 
284
- const devConfig = devicesInConfig.find(device => String(device.id) === id);
285
- if (devConfig && !devConfig.presets.some(preset => preset.id === p.id)) {
286
- devConfig.presets.push(p);
287
- newPresets.push(structuredClone(p));
284
+ const deviceInConfig = devicesInConfig.find(device => String(device.id) === deviceObj.id);
285
+ if (deviceInConfig && !deviceInConfig.presets.some(preset => preset.id === presetObj.id)) {
286
+ deviceInConfig.presets.push(presetObj);
287
+ newPresets.push(presetObj);
288
288
  }
289
289
  });
290
290
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.0.1-beta.4",
4
+ "version": "4.0.1-beta.6",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",