homebridge-melcloud-control 2.5.0-beta.40 → 2.5.0-beta.41

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.
@@ -205,7 +205,7 @@
205
205
  "description": "Here select the language used in MELCloud account.",
206
206
  "required": true
207
207
  },
208
- "devicesAta": {
208
+ "ataDevices": {
209
209
  "title": "Devices ATA",
210
210
  "type": "array",
211
211
  "items": {
@@ -258,7 +258,7 @@
258
258
  },
259
259
  "required": false
260
260
  },
261
- "devicesAtw": {
261
+ "atwDevices": {
262
262
  "title": "Devices ATW",
263
263
  "type": "array",
264
264
  "items": {
@@ -312,7 +312,7 @@
312
312
  },
313
313
  "required": false
314
314
  },
315
- "devicesErv": {
315
+ "ervDevices": {
316
316
  "title": "Devices ERV",
317
317
  "type": "array",
318
318
  "items": {
@@ -1591,15 +1591,15 @@
1591
1591
  "title": "Air Conditioner",
1592
1592
  "items": [
1593
1593
  {
1594
- "key": "accounts[].devicesAta",
1594
+ "key": "accounts[].ataDevices",
1595
1595
  "type": "tabarray",
1596
1596
  "title": "{{ value.name }}",
1597
1597
  "items": [
1598
- "accounts[].devicesAta[].displayMode"
1599
- ],
1600
- "condition": {
1601
- "functionBody": "return model.accounts[arrayIndices].devicesAta.length > 0"
1602
- }
1598
+ "accounts[].ataDevices[].name",
1599
+ "accounts[].ataDevices[].id",
1600
+ "accounts[].ataDevices[].type",
1601
+ "accounts[].ataDevices[].displayMode"
1602
+ ]
1603
1603
  },
1604
1604
  "accounts[].ataDisplayMode",
1605
1605
  "accounts[].ataPresets",
@@ -1671,18 +1671,15 @@
1671
1671
  "title": "Heat Pump",
1672
1672
  "items": [
1673
1673
  {
1674
- "key": "accounts[].devicesAtw",
1674
+ "key": "accounts[].atwDevices",
1675
1675
  "type": "tabarray",
1676
1676
  "title": "{{ value.name }}",
1677
1677
  "items": [
1678
- "accounts[].devicesAtw[].name",
1679
- "accounts[].devicesAtw[].id",
1680
- "accounts[].devicesAtw[].type",
1681
- "accounts[].devicesAtw[].displayMode"
1682
- ],
1683
- "condition": {
1684
- "functionBody": "return model.accounts[arrayIndices].devicesAtw.length > 0"
1685
- }
1678
+ "accounts[].atwDevices[].name",
1679
+ "accounts[].atwDevices[].id",
1680
+ "accounts[].atwDevices[].type",
1681
+ "accounts[].atwDevices[].displayMode"
1682
+ ]
1686
1683
  },
1687
1684
  "accounts[].atwDisplayMode",
1688
1685
  "accounts[].atwPresets",
@@ -1749,18 +1746,15 @@
1749
1746
  "title": "Energy Recovery Ventilation",
1750
1747
  "items": [
1751
1748
  {
1752
- "key": "accounts[].devicesErv",
1749
+ "key": "accounts[].ervDevices",
1753
1750
  "type": "tabarray",
1754
1751
  "title": "{{ value.name }}",
1755
1752
  "items": [
1756
- "accounts[].devicesErv[].name",
1757
- "accounts[].devicesErv[].id",
1758
- "accounts[].devicesErv[].type",
1759
- "accounts[].devicesErv[].displayMode"
1760
- ],
1761
- "condition": {
1762
- "functionBody": "return model.accounts[arrayIndices].devicesErv.length > 0"
1763
- }
1753
+ "accounts[].ervDevices[].name",
1754
+ "accounts[].ervDevices[].id",
1755
+ "accounts[].ervDevices[].type",
1756
+ "accounts[].ervDevices[].displayMode"
1757
+ ]
1764
1758
  },
1765
1759
  "accounts[].ervDisplayMode",
1766
1760
  "accounts[].ervPresets",
@@ -147,31 +147,27 @@
147
147
  const info = response.info ?? '';
148
148
  const status = response.status;
149
149
  const devices = response.data ?? [];
150
- const typeAta = [];
151
- const typeAtw = [];
152
- const typeErv = [];
150
+ const newDevices = [];
153
151
 
154
152
  switch (status) {
155
153
  case 0:
156
- const devicesCount = devices.length;
157
- document.getElementById('info').innerHTML = `Success, found ${devicesCount} ${devicesCount !== 1 ? 'devices' : 'device'}. Now You can start to configure it.`;
158
- document.getElementById('info').style.color = 'green';
159
-
160
154
  //get device info fom devices
161
155
  devices.forEach((deviceInfo, index) => {
162
156
  const deviceType = deviceInfo.Type;
163
157
  const deviceId = deviceInfo.DeviceID;
164
158
  const deviceName = deviceInfo.DeviceName;
159
+ const deviceIdExist = pluginConfig[0].accounts[this.deviceIndex].ataDevices.some(device => device.type === deviceId)
160
+ const pushNewDevice = !deviceIdExist ? newDevices.push(deviceId) : false;
165
161
 
166
162
  const device = { name: deviceName, id: deviceId, type: deviceType, displayMode: 0 };
167
- const pushTypeAta = deviceType === 0 ? typeAta.push(device) : false;
168
- const pushTypeAtw = deviceType === 1 ? typeAtw.push(device) : false;
169
- const pushTypeErv = deviceType === 3 ? typeErv.push(device) : false;
163
+ const pushTypeAta = deviceType === 0 && !deviceIdExist ? pluginConfig[0].accounts[this.deviceIndex].ataDevices.push(device) : false;
164
+ const pushTypeAtw = deviceType === 1 && !deviceIdExist ? pluginConfig[0].accounts[this.deviceIndex].atwDevices.push(device) : false;
165
+ const pushTypeErv = deviceType === 3 && !deviceIdExist ? pluginConfig[0].accounts[this.deviceIndex].ervDevices.push(device) : false;
170
166
  });
171
167
 
172
- pluginConfig[0].accounts[this.deviceIndex].devicesAta = typeAta;
173
- pluginConfig[0].accounts[this.deviceIndex].devicesAtw = typeAtw;
174
- pluginConfig[0].accounts[this.deviceIndex].devicesErv = typeErv;
168
+ const devicesCount = newDevices.length;
169
+ document.getElementById('info').innerHTML = `Success, found ${devicesCount} ${devicesCount !== 1 ? 'new devices' : 'new device'}. Now You can start to configure it.`;
170
+ document.getElementById('info').style.color = 'green';
175
171
 
176
172
  await homebridge.updatePluginConfig(pluginConfig);
177
173
  await homebridge.savePluginConfig(pluginConfig);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "2.5.0-beta.40",
4
+ "version": "2.5.0-beta.41",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",