homebridge-melcloud-control 3.1.0-beta.3 → 3.1.0-beta.30

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.
package/CHANGELOG.md CHANGED
@@ -15,6 +15,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
15
  - v3 After update to v3 from previous versions the plugin need to be configured using Config UI X.
16
16
  - do not configure it manually, always using Config UI X
17
17
 
18
+ ## [3.1.0] - (31.08.2024)
19
+
20
+ ## Changes
21
+
22
+ - improvements in plugin config UI
23
+ - added possibility indyvidual presets control
24
+ - config schema update
25
+ - bump dependencies
26
+ - cleanup
27
+
18
28
  ## [3.0.7] - (30.08.2024)
19
29
 
20
30
  ## Changes
@@ -29,7 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
29
39
 
30
40
  - added homebridge UI server
31
41
  - whole new concept get all devices from melcloud usin config UI X
32
- - added indyvidual configuration of every device
42
+ - added individual configuration of every device
33
43
  - config schema updated
34
44
  - cleanup
35
45
 
package/README.md CHANGED
@@ -185,7 +185,10 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
185
185
  | `ataDevices.autoDryFanMode` | Here select the operatiing mode for `Auto`, if this mode is not supported, it will be disabled.. |
186
186
  | `ataDevices.temperatureSensor` | This enable extra `Room` temperature sensors to use with automations in HomeKit app. |
187
187
  | `ataDevices.temperatureSensorOutdoor` | This enable extra `Outdoor` temperature sensors to use with automations in HomeKit app. |
188
- | `ataDevices.presets` | This enable extra buttons for configured presets and display it in HomeKit app. |
188
+ | `ataDevices.presets` | Array of ATA device Presets created automatically after login to MELCloud from plugin config UI. |
189
+ | `ataDevices.presets.id` | Read only data, do not change it. |
190
+ | `ataDevices.presets.name` | Here You can schange the `Preset Name` which is exposed to the `Homebridge/HomeKit`. |
191
+ | `ataDevices.presets.displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Outlet`, `2 - Switch`, `3 - Motion Sensor`, `4 - Occupancy Sensor`, `5 - Contact Sensor`. |
189
192
  | `buttonsSensors` | Array of buttons sensors. |
190
193
  | `buttonsSensors.name` | Here set `Button Name` which You want expose to the `Homebridge/HomeKit`. |
191
194
  | `buttonsSensors.mode` | Here select button mode, VH - Vane Horizontal, VV - Vane Horizontal. |
@@ -206,7 +209,10 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
206
209
  | `atwDevices.temperatureSensorReturnWaterTank` | This enable extra `Return Water Tank` temperature sensors to use with automations in HomeKit app. |
207
210
  | `atwDevices.temperatureSensorFlowZone2` | This enable extra `Flow Zone 2` temperature sensors to use with automations in HomeKit app. |
208
211
  | `atwDevices.temperatureSensorReturnZone2` | This enable extra `Return Zone 2` temperature sensors to use with automations in HomeKit app. |
209
- | `atwDevices.presets` | This enable extra buttons for configured presets and display it in HomeKit app. |
212
+ | `atwDevices.presets` | Array of ATA device Presets created automatically after login to MELCloud from plugin config UI. |
213
+ | `atwDevices.presets.id` | Read only data, do not change it. |
214
+ | `atwDevices.presets.name` | Here You can schange the `Preset Name` which is exposed to the `Homebridge/HomeKit`. |
215
+ | `atwDevices.presets.displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Outlet`, `2 - Switch`, `3 - Motion Sensor`, `4 - Occupancy Sensor`, `5 - Contact Sensor`. |
210
216
  | `buttonsSensors` | Array of buttons sensors. |
211
217
  | `buttonsSensors.name` | Here set `Button Name` which You want expose to the `Homebridge/HomeKit`. |
212
218
  | `buttonsSensors.mode` | Here select button mode. |
@@ -221,7 +227,10 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
221
227
  | `ervDevices.temperatureSensor` | This enable extra `Room` temperature sensors to use with automations in HomeKit app. |
222
228
  | `ervDevices.temperatureSensorOutdoor` | This enable extra `Outdoor` temperature sensors to use with automations in HomeKit app. |
223
229
  | `ervDevices.temperatureSensorSupply` | This enable extra `Supply` temperature sensors to use with automations in HomeKit app. |
224
- | `ervDevices.presets` | This enable extra buttons for configured presets and display it in HomeKit app. |
230
+ | `ervDevices.presets` | Array of ATA device Presets created automatically after login to MELCloud from plugin config UI. |
231
+ | `ervDevices.presets.id` | Read only data, do not change it. |
232
+ | `ervDevices.presets.name` | Here You can schange the `Preset Name` which is exposed to the `Homebridge/HomeKit`. |
233
+ | `ervDevices.presets.displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Outlet`, `2 - Switch`, `3 - Motion Sensor`, `4 - Occupancy Sensor`, `5 - Contact Sensor`. |
225
234
  | `buttonsSensors` | Array of buttons sensors. |
226
235
  | `buttonsSensors.name` | Here set `Button Name` which You want expose to the `Homebridge/HomeKit`. |
227
236
  | `buttonsSensors.mode` | Here select button mode. |
@@ -213,22 +213,25 @@
213
213
  "id": {
214
214
  "title": "ID",
215
215
  "type": "integer",
216
- "required": false
216
+ "required": true,
217
+ "readonly": true
217
218
  },
218
219
  "type": {
219
220
  "title": "Type",
220
221
  "type": "integer",
221
- "required": false
222
+ "required": true,
223
+ "readonly": true
222
224
  },
223
225
  "typeString": {
224
226
  "title": "Type",
225
227
  "type": "string",
226
- "required": false
228
+ "required": true,
229
+ "readonly": true
227
230
  },
228
231
  "name": {
229
232
  "title": "Name",
230
233
  "type": "string",
231
- "required": false
234
+ "required": true
232
235
  },
233
236
  "displayMode": {
234
237
  "title": "Control",
@@ -363,12 +366,31 @@
363
366
  "description": "Select the operating mode for Auto, if this mode is not supported, it will be disabled.",
364
367
  "required": true
365
368
  },
369
+ "temperatureSensor": {
370
+ "title": "Room",
371
+ "type": "boolean",
372
+ "default": false,
373
+ "description": "This enable extra room temperature sensor to use with automations in HomeKit app.",
374
+ "required": false
375
+ },
376
+ "temperatureSensorOutdoor": {
377
+ "title": "Outdoor",
378
+ "type": "boolean",
379
+ "default": false,
380
+ "description": "This enable extra outdoor temperature sensor to use with automations in HomeKit app.",
381
+ "required": false
382
+ },
366
383
  "presets": {
367
384
  "title": "Presets",
368
385
  "type": "array",
369
386
  "items": {
370
387
  "type": "object",
371
388
  "properties": {
389
+ "id": {
390
+ "title": "ID",
391
+ "type": "integer",
392
+ "required": true
393
+ },
372
394
  "name": {
373
395
  "title": "Name",
374
396
  "type": "string",
@@ -431,22 +453,11 @@
431
453
  "required": false
432
454
  }
433
455
  }
456
+ },
457
+ "condition": {
458
+ "functionBody": "const presets = model.accounts[arrayIndices]?.ataDevices[arrayIndices]?.presets || []; return presets.length > 0 && presets.every(preset => preset.id != null && preset.id !== '');"
434
459
  }
435
460
  },
436
- "temperatureSensor": {
437
- "title": "Room",
438
- "type": "boolean",
439
- "default": false,
440
- "description": "This enable extra room temperature sensor to use with automations in HomeKit app.",
441
- "required": false
442
- },
443
- "temperatureSensorOutdoor": {
444
- "title": "Outdoor",
445
- "type": "boolean",
446
- "default": false,
447
- "description": "This enable extra outdoor temperature sensor to use with automations in HomeKit app.",
448
- "required": false
449
- },
450
461
  "buttonsSensors": {
451
462
  "title": "Button / Sensor",
452
463
  "type": "array",
@@ -752,22 +763,25 @@
752
763
  "id": {
753
764
  "title": "Mode",
754
765
  "type": "integer",
755
- "required": false
766
+ "required": true,
767
+ "readonly": true
756
768
  },
757
769
  "type": {
758
770
  "title": "Type",
759
771
  "type": "integer",
760
- "required": false
772
+ "required": true,
773
+ "readonly": true
761
774
  },
762
775
  "typeString": {
763
776
  "title": "Type",
764
777
  "type": "string",
765
- "required": false
778
+ "required": true,
779
+ "readonly": true
766
780
  },
767
781
  "name": {
768
782
  "title": "Name",
769
783
  "type": "string",
770
- "required": false
784
+ "required": true
771
785
  },
772
786
  "displayMode": {
773
787
  "title": "Control",
@@ -867,6 +881,11 @@
867
881
  "items": {
868
882
  "type": "object",
869
883
  "properties": {
884
+ "id": {
885
+ "title": "ID",
886
+ "type": "integer",
887
+ "required": true
888
+ },
870
889
  "name": {
871
890
  "title": "Name",
872
891
  "type": "string",
@@ -929,6 +948,9 @@
929
948
  "required": false
930
949
  }
931
950
  }
951
+ },
952
+ "condition": {
953
+ "functionBody": "const presets = model.accounts[arrayIndices]?.atwDevices[arrayIndices]?.presets || []; return presets.length > 0 && presets.every(preset => preset.id != null && preset.id !== '');"
932
954
  }
933
955
  },
934
956
  "buttonsSensors": {
@@ -1158,29 +1180,32 @@
1158
1180
  "id": {
1159
1181
  "title": "Mode",
1160
1182
  "type": "integer",
1161
- "required": false
1183
+ "required": true,
1184
+ "readonly": true
1162
1185
  },
1163
1186
  "type": {
1164
1187
  "title": "Type",
1165
1188
  "type": "integer",
1166
- "required": false
1189
+ "required": true,
1190
+ "readonly": true
1167
1191
  },
1168
1192
  "typeString": {
1169
1193
  "title": "Type",
1170
1194
  "type": "string",
1171
- "required": false
1195
+ "required": true,
1196
+ "readonly": true
1172
1197
  },
1173
1198
  "name": {
1174
1199
  "title": "Name",
1175
1200
  "type": "string",
1176
- "required": false
1201
+ "required": true
1177
1202
  },
1178
1203
  "displayMode": {
1179
1204
  "title": "Control",
1180
1205
  "type": "integer",
1181
1206
  "minimum": 0,
1182
1207
  "maximum": 2,
1183
- "default": 0,
1208
+ "default": 1,
1184
1209
  "oneOf": [
1185
1210
  {
1186
1211
  "title": "None/Disabled",
@@ -1231,6 +1256,12 @@
1231
1256
  "items": {
1232
1257
  "type": "object",
1233
1258
  "properties": {
1259
+ "id": {
1260
+ "title": "ID",
1261
+ "type": "integer",
1262
+ "required": true,
1263
+ "readonly": true
1264
+ },
1234
1265
  "name": {
1235
1266
  "title": "Name",
1236
1267
  "type": "string",
@@ -1293,6 +1324,9 @@
1293
1324
  "required": false
1294
1325
  }
1295
1326
  }
1327
+ },
1328
+ "condition": {
1329
+ "functionBody": "const presets = model.accounts[arrayIndices]?.ervDevices[arrayIndices]?.presets || []; return presets.length > 0 && presets.every(preset => preset.id != null && preset.id !== '');"
1296
1330
  }
1297
1331
  },
1298
1332
  "buttonsSensors": {
@@ -1681,19 +1715,7 @@
1681
1715
  "accounts[].ataDevices[].displayMode",
1682
1716
  "accounts[].ataDevices[].heatDryFanMode",
1683
1717
  "accounts[].ataDevices[].coolDryFanMode",
1684
- "accounts[].ataDevices[].autoDryFanMode",
1685
- "accounts[].ataDevices[].presets"
1686
- ]
1687
- },
1688
- {
1689
- "key": "accounts[].ataDevices[]",
1690
- "type": "section",
1691
- "title": "Temperature Sensors",
1692
- "expandable": true,
1693
- "expanded": false,
1694
- "items": [
1695
- "accounts[].ataDevices[].temperatureSensor",
1696
- "accounts[].ataDevices[].temperatureSensorOutdoor"
1718
+ "accounts[].ataDevices[].autoDryFanMode"
1697
1719
  ]
1698
1720
  },
1699
1721
  {
@@ -1706,8 +1728,12 @@
1706
1728
  {
1707
1729
  "key": "accounts[].ataDevices[].presets",
1708
1730
  "type": "tabarray",
1709
- "title": "{{ value.name || 'button/sensor' }}",
1731
+ "title": "{{ value.name }}",
1710
1732
  "items": [
1733
+ {
1734
+ "key": "accounts[].ataDevices[].presets[].id",
1735
+ "readonly": true
1736
+ },
1711
1737
  "accounts[].ataDevices[].presets[].name",
1712
1738
  "accounts[].ataDevices[].presets[].displayType",
1713
1739
  "accounts[].ataDevices[].presets[].namePrefix"
@@ -1715,6 +1741,17 @@
1715
1741
  }
1716
1742
  ]
1717
1743
  },
1744
+ {
1745
+ "key": "accounts[].ataDevices[]",
1746
+ "type": "section",
1747
+ "title": "Temperature Sensors",
1748
+ "expandable": true,
1749
+ "expanded": false,
1750
+ "items": [
1751
+ "accounts[].ataDevices[].temperatureSensor",
1752
+ "accounts[].ataDevices[].temperatureSensorOutdoor"
1753
+ ]
1754
+ },
1718
1755
  {
1719
1756
  "key": "accounts[].ataDevices[]",
1720
1757
  "type": "section",
@@ -1764,26 +1801,7 @@
1764
1801
  "expanded": false,
1765
1802
  "items": [
1766
1803
  "accounts[].atwDevices[].name",
1767
- "accounts[].atwDevices[].displayMode",
1768
- "accounts[].atwDevices[].presets"
1769
- ]
1770
- },
1771
- {
1772
- "key": "accounts[].atwDevices[]",
1773
- "type": "section",
1774
- "title": "Temperature Sensors",
1775
- "expandable": true,
1776
- "expanded": false,
1777
- "items": [
1778
- "accounts[].atwDevices[].temperatureSensor",
1779
- "accounts[].atwDevices[].temperatureSensorFlow",
1780
- "accounts[].atwDevices[].temperatureSensorReturn",
1781
- "accounts[].atwDevices[].temperatureSensorFlowZone1",
1782
- "accounts[].atwDevices[].temperatureSensorReturnZone1",
1783
- "accounts[].atwDevices[].temperatureSensorFlowWaterTank",
1784
- "accounts[].atwDevices[].temperatureSensorReturnWaterTank",
1785
- "accounts[].atwDevices[].temperatureSensorFlowZone2",
1786
- "accounts[].atwDevices[].temperatureSensorReturnZone2"
1804
+ "accounts[].atwDevices[].displayMode"
1787
1805
  ]
1788
1806
  },
1789
1807
  {
@@ -1796,8 +1814,12 @@
1796
1814
  {
1797
1815
  "key": "accounts[].atwDevices[].presets",
1798
1816
  "type": "tabarray",
1799
- "title": "{{ value.name || 'button/sensor' }}",
1817
+ "title": "{{ value.name }}",
1800
1818
  "items": [
1819
+ {
1820
+ "key": "accounts[].atwDevices[].presets[].id",
1821
+ "readonly": true
1822
+ },
1801
1823
  "accounts[].atwDevices[].presets[].name",
1802
1824
  "accounts[].atwDevices[].presets[].displayType",
1803
1825
  "accounts[].atwDevices[].presets[].namePrefix"
@@ -1805,6 +1827,24 @@
1805
1827
  }
1806
1828
  ]
1807
1829
  },
1830
+ {
1831
+ "key": "accounts[].atwDevices[]",
1832
+ "type": "section",
1833
+ "title": "Temperature Sensors",
1834
+ "expandable": true,
1835
+ "expanded": false,
1836
+ "items": [
1837
+ "accounts[].atwDevices[].temperatureSensor",
1838
+ "accounts[].atwDevices[].temperatureSensorFlow",
1839
+ "accounts[].atwDevices[].temperatureSensorReturn",
1840
+ "accounts[].atwDevices[].temperatureSensorFlowZone1",
1841
+ "accounts[].atwDevices[].temperatureSensorReturnZone1",
1842
+ "accounts[].atwDevices[].temperatureSensorFlowWaterTank",
1843
+ "accounts[].atwDevices[].temperatureSensorReturnWaterTank",
1844
+ "accounts[].atwDevices[].temperatureSensorFlowZone2",
1845
+ "accounts[].atwDevices[].temperatureSensorReturnZone2"
1846
+ ]
1847
+ },
1808
1848
  {
1809
1849
  "key": "accounts[].atwDevices[]",
1810
1850
  "type": "section",
@@ -1854,20 +1894,7 @@
1854
1894
  "expanded": false,
1855
1895
  "items": [
1856
1896
  "accounts[].ervDevices[].name",
1857
- "accounts[].ervDevices[].displayMode",
1858
- "accounts[].ervDevices[].presets"
1859
- ]
1860
- },
1861
- {
1862
- "key": "accounts[].ervDevices[]",
1863
- "type": "section",
1864
- "title": "Temperature Sensors",
1865
- "expandable": true,
1866
- "expanded": false,
1867
- "items": [
1868
- "accounts[].ervDevices[].temperatureSensor",
1869
- "accounts[].ervDevices[].temperatureSensorOutdoor",
1870
- "accounts[].ervDevices[].temperatureSensorSupply"
1897
+ "accounts[].ervDevices[].displayMode"
1871
1898
  ]
1872
1899
  },
1873
1900
  {
@@ -1880,8 +1907,12 @@
1880
1907
  {
1881
1908
  "key": "accounts[].ervDevices[].presets",
1882
1909
  "type": "tabarray",
1883
- "title": "{{ value.name || 'button/sensor' }}",
1910
+ "title": "{{ value.name }}",
1884
1911
  "items": [
1912
+ {
1913
+ "key": "accounts[].ervDevices[].presets[].id",
1914
+ "readonly": true
1915
+ },
1885
1916
  "accounts[].ervDevices[].presets[].name",
1886
1917
  "accounts[].ervDevices[].presets[].displayType",
1887
1918
  "accounts[].ervDevices[].presets[].namePrefix"
@@ -1889,6 +1920,18 @@
1889
1920
  }
1890
1921
  ]
1891
1922
  },
1923
+ {
1924
+ "key": "accounts[].ervDevices[]",
1925
+ "type": "section",
1926
+ "title": "Temperature Sensors",
1927
+ "expandable": true,
1928
+ "expanded": false,
1929
+ "items": [
1930
+ "accounts[].ervDevices[].temperatureSensor",
1931
+ "accounts[].ervDevices[].temperatureSensorOutdoor",
1932
+ "accounts[].ervDevices[].temperatureSensorSupply"
1933
+ ]
1934
+ },
1892
1935
  {
1893
1936
  "key": "accounts[].ervDevices[]",
1894
1937
  "type": "section",
@@ -9,6 +9,7 @@
9
9
  <label id="accountName" style="font-size: 23px">Account</label><br>
10
10
  <label id="info" style="text-align: center; font-size: 17px;"></label><br>
11
11
  <label id="info1" style="text-align: center; font-size: 15px;"></label><br>
12
+ <label id="info2" style="text-align: center; font-size: 15px;"></label><br>
12
13
  </div>
13
14
  <div class="form-group">
14
15
  <label for="name">Name</label>
@@ -131,11 +132,10 @@
131
132
  //watch for click on the login button
132
133
  document.getElementById('logIn').addEventListener('click', async () => {
133
134
  homebridge.showSpinner();
135
+ document.getElementById('info').innerHTML = 'Connecting...';
136
+ await homebridge.updatePluginConfig(pluginConfig)
134
137
 
135
138
  try {
136
- await homebridge.updatePluginConfig(pluginConfig)
137
- document.getElementById('info').innerHTML = 'Connecting...';
138
-
139
139
  const accountName = pluginConfig[0].accounts[this.deviceIndex].name;
140
140
  const user = pluginConfig[0].accounts[this.deviceIndex].user;
141
141
  const passwd = pluginConfig[0].accounts[this.deviceIndex].passwd;
@@ -166,24 +166,24 @@
166
166
  erv: [],
167
167
  ervPresets: [],
168
168
  };
169
+
170
+ //info text
169
171
  let textAta = 'ATA: 0';
170
- let textAtaPresets = 'Presets: 0';
172
+ let textAtaPresets = 'ATA Presets: 0';
171
173
  let textAtw = 'ATW: 0';
172
- let textAtwPresets = 'Presets: 0';
174
+ let textAtwPresets = 'ATW Presets: 0';
173
175
  let textErv = 'ERV: 0';
174
- let textErvPresets = 'Presets: 0';
176
+ let textErvPresets = 'ERV Presets: 0';
175
177
 
176
178
  //response status
177
179
  switch (status) {
178
180
  case 0:
179
181
  //get devices by type
180
182
  for (const device of devices) {
181
- const deviceId = device.DeviceID;
182
183
  const deviceType = device.Type;
183
-
184
184
  const pusDeviceTypeAta = deviceType === 0 ? devicesByType.ata.push(device) : false;
185
- const pusDeviceTypeAtw = deviceType === 0 ? devicesByType.atw.push(device) : false;
186
- const pusDeviceTypeErv = deviceType === 0 ? devicesByType.erv.push(device) : false;
185
+ const pusDeviceTypeAtw = deviceType === 1 ? devicesByType.atw.push(device) : false;
186
+ const pusDeviceTypeErv = deviceType === 3 ? devicesByType.erv.push(device) : false;
187
187
  };
188
188
 
189
189
  //get device info fom devices ata
@@ -192,9 +192,9 @@
192
192
  const deviceType = device.Type;
193
193
  const deviceTypeText = "Air Conditioner";
194
194
  const deviceName = device.DeviceName;
195
- const devicePresets = device.presets ?? [];
195
+ const devicePresets = device.Presets ?? [];
196
196
 
197
- //devices ata
197
+ //device ata
198
198
  const deviceAta = {
199
199
  id: deviceId,
200
200
  type: deviceType,
@@ -219,22 +219,23 @@
219
219
  textAta = `ATA: ${devicesCount}`
220
220
 
221
221
  //presets
222
- devicePresets.forEach((preset, index1) => {
222
+ for (const preset of devicePresets) {
223
223
  const presetId = preset.ID;
224
224
  const presetName = preset.NumberDescription;
225
225
 
226
+ preset.id = presetId;
226
227
  preset.name = presetName;
227
228
  preset.displayType == 0;
228
229
  preset.namePrefix = false;
229
230
 
230
231
  const ataPresetsExist = pluginConfig[0].accounts[this.deviceIndex].ataDevices[index].presets ?? false;
231
232
  const ataPresets = ataPresetsExist ? pluginConfig[0].accounts[this.deviceIndex].ataDevices[index].presets : pluginConfig[0].accounts[this.deviceIndex].ataDevices[index].presets = [];
232
- const ataPresetIdExist = ataPresets.some(preset => preset.ID === presetId);
233
+ const ataPresetIdExist = ataPresets.some(preset => preset.id === presetId);
233
234
  const pushPresetAta = ataPresetIdExist ? false : ataPresets.push(preset);
234
235
  const pushNewPreset = ataPresetIdExist ? false : newDevices.ataPresets.push(preset);
235
236
  const presetsCount = newDevices.ataPresets.length;
236
237
  textAtaPresets = `ATA Presets: ${presetsCount}`
237
- });
238
+ };
238
239
  });
239
240
 
240
241
  //get device info fom devices atw
@@ -243,9 +244,9 @@
243
244
  const deviceType = device.Type;
244
245
  const deviceTypeText = "Heat Pump";
245
246
  const deviceName = device.DeviceName;
246
- const devicePresets = device.presets ?? [];
247
+ const devicePresets = device.Presets ?? [];
247
248
 
248
- //devices atw
249
+ //device atw
249
250
  const deviceAtw = {
250
251
  id: deviceId,
251
252
  type: deviceType,
@@ -275,31 +276,34 @@
275
276
  textAtw = `ATW: ${devicesCount}`
276
277
 
277
278
  //presetzs
278
- devicePresets.forEach((preset, index1) => {
279
+ for (const preset of devicePresets) {
279
280
  const presetId = preset.ID;
280
281
  const presetName = preset.NumberDescription;
281
282
 
283
+ preset.id = presetId;
282
284
  preset.name = presetName;
283
285
  preset.displayType == 0;
284
286
  preset.namePrefix = false;
285
287
 
286
288
  const atwPresetsExist = pluginConfig[0].accounts[this.deviceIndex].atwDevices[index].presets ?? false;
287
289
  const atwPresets = atwPresetsExist ? pluginConfig[0].accounts[this.deviceIndex].atwDevices[index].presets : pluginConfig[0].accounts[this.deviceIndex].atwDevices[index].presets = [];
288
- const atwPresetIdExist = atwPresets.some(preset => preset.ID === presetId);
290
+ const atwPresetIdExist = atwPresets.some(preset => preset.id === presetId);
289
291
  const pushPresetAtw = atwPresetIdExist ? false : atwPresets.push(preset);
290
292
  const pushNewPreset = atwPresetIdExist ? false : newDevices.atwPresets.push(preset);
291
293
  const presetsCount = newDevices.atwPresets.length;
292
294
  textAtwPresets = `ATW Presets: ${presetsCount}`
293
- });
295
+ };
294
296
  });
295
297
 
296
298
  //get device info fom devices erv
297
- devicesByType.ata.forEach((device, index) => {
299
+ devicesByType.erv.forEach((device, index) => {
298
300
  const deviceId = device.DeviceID;
299
301
  const deviceType = device.Type;
300
302
  const deviceTypeText = "Energy Recovery Ventilation";
301
303
  const deviceName = device.DeviceName;
302
- const devicePresets = device.presets ?? [];
304
+ const devicePresets = device.Presets ?? [];
305
+
306
+ //device erv
303
307
  const deviceErv = {
304
308
  id: deviceId,
305
309
  type: deviceType,
@@ -323,29 +327,54 @@
323
327
  textErv = `ERV: ${devicesCount}`
324
328
 
325
329
  //presets
326
- devicePresets.forEach((preset, index1) => {
330
+ for (const preset of devicePresets) {
327
331
  const presetId = preset.ID;
328
332
  const presetName = preset.NumberDescription;
329
333
 
334
+ preset.id = presetId;
330
335
  preset.name = presetName;
331
336
  preset.displayType == 0;
332
337
  preset.namePrefix = false;
333
338
 
334
339
  const ervPresetsExist = pluginConfig[0].accounts[this.deviceIndex].ervDevices[index].presets ?? false;
335
340
  const ervPresets = ervPresetsExist ? pluginConfig[0].accounts[this.deviceIndex].ervDevices[index].presets : pluginConfig[0].accounts[this.deviceIndex].ervDevices[index].presets = [];
336
- const ervPresetIdExist = ervPresets.some(preset => preset.ID === presetId);
341
+ const ervPresetIdExist = ervPresets.some(preset => preset.id === presetId);
337
342
  const pushPresetErv = ervPresetIdExist ? false : ervPresets.push(preset);
338
343
  const pushNewPreset = ervPresetIdExist ? false : newDevices.ervPresets.push(preset);
339
344
  const presetsCount = newDevices.ervPresets.length;
340
345
  textErvPresets = `ERV Presets: ${presetsCount}`
341
- });
346
+ };
342
347
  });
343
348
 
344
- const newDevicesCount = newDevices.ata.length + newDevices.atw.length + newDevices.erv.length;
345
- const newPresetsCount = newDevices.ataPresets.length + newDevices.atwPresets.length + newDevices.ervPresets.length;
346
- document.getElementById('info').innerHTML = `${newDevicesCount === 0 ? 'No new devices found.' : `Found, ${textAta}, ${textAtw}, ${textErv}. ${newDevicesCount === 0 ? '' : 'Now You can start to configure it.'}`}`;
347
- document.getElementById('info1').innerHTML = `${newPresetsCount === 0 ? 'No new presets found.' : `Found, ${textAtaPresets}, ${textAtwPresets}, ${textErvPresets}. ${newPresetsCount === 0 ? '' : 'Now You can start to configure it.'}`}`;
348
- document.getElementById('info').style.color = 'green';
349
+ const newDevicesCount = newDevices.ata.length + newDevices.atw.length + newDevices.erv.length ?? 0;
350
+ const newPresetsCount = newDevices.ataPresets.length + newDevices.atwPresets.length + newDevices.ervPresets.length ?? 0;
351
+ if (newDevicesCount === 0 && newPresetsCount === 0) {
352
+ document.getElementById('info').innerHTML = 'No new devices found.';
353
+ document.getElementById('info').style.color = 'white';
354
+ };
355
+
356
+ if (newDevicesCount > 0 && newPresetsCount > 0) {
357
+ document.getElementById('info').innerHTML = `Found, ${textAta}, ${textAtw}, ${textErv}.`;
358
+ document.getElementById('info').style.color = 'green';
359
+ document.getElementById('info1').innerHTML = `${textAtaPresets}, ${textAtwPresets}, ${textErvPresets}.`;
360
+ document.getElementById('info1').style.color = 'green';
361
+ document.getElementById('info2').innerHTML = 'Now You can configure it.';
362
+ document.getElementById('info2').style.color = 'green';
363
+ };
364
+
365
+ if (newDevicesCount > 0 && newPresetsCount === 0) {
366
+ document.getElementById('info').innerHTML = `Found, ${textAta}, ${textAtw}, ${textErv}.`;
367
+ document.getElementById('info').style.color = 'green';
368
+ document.getElementById('info1').innerHTML = 'Now You can configure it.';
369
+ document.getElementById('info1').style.color = 'green';
370
+ };
371
+
372
+ if (newDevicesCount === 0 && newPresetsCount > 0) {
373
+ document.getElementById('info').innerHTML = `Found, ${textAtaPresets}, ${textAtwPresets}, ${textErvPresets}.`;
374
+ document.getElementById('info').style.color = 'green';
375
+ document.getElementById('info1').innerHTML = 'Now You can configure it.';
376
+ document.getElementById('info1').style.color = 'green';
377
+ }
349
378
 
350
379
  await homebridge.updatePluginConfig(pluginConfig);
351
380
  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": "3.1.0-beta.3",
4
+ "version": "3.1.0-beta.30",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/deviceata.js CHANGED
@@ -204,6 +204,9 @@ class DeviceAta extends EventEmitter {
204
204
  const outdoorTemperature = deviceData.Device.OutdoorTemperature;
205
205
  const temperatureUnit = CONSTANTS.TemperatureDisplayUnits[useFahrenheit];
206
206
 
207
+ //presets
208
+ const presetsOnServer = deviceData.Presets ?? [];
209
+
207
210
  //device state
208
211
  const roomTemperature = deviceState.RoomTemperature;
209
212
  const setTemperature = deviceState.SetTemperature;
@@ -221,6 +224,7 @@ class DeviceAta extends EventEmitter {
221
224
  const offline = deviceState.Offline;
222
225
 
223
226
  //accessory
227
+ this.accessory.presetsOnServer = presetsOnServer;
224
228
  this.accessory.power = power;
225
229
  this.accessory.offline = offline;
226
230
  this.accessory.roomTemperature = roomTemperature;
@@ -425,6 +429,28 @@ class DeviceAta extends EventEmitter {
425
429
  .updateCharacteristic(Characteristic.CurrentTemperature, outdoorTemperature)
426
430
  };
427
431
 
432
+ //update presets state
433
+ if (this.presetsConfigured.length > 0) {
434
+ for (let i = 0; i < this.presetsConfigured.length; i++) {
435
+ const preset = this.presetsConfigured[i];
436
+ const index = presetsOnServer.findIndex(p => p.ID === preset.Id);
437
+ const presetData = presetsOnServer[index];
438
+
439
+ preset.state = presetData ? (presetData.Power === power
440
+ && presetData.SetTemperature === setTemperature
441
+ && presetData.OperationMode === operationMode
442
+ && presetData.VaneHorizontal === vaneHorizontal
443
+ && presetData.VaneVertical === vaneVertical
444
+ && presetData.FanSpeed === setFanSpeed) : false;
445
+
446
+ if (this.presetsServices) {
447
+ const characteristicType = preset.characteristicType;
448
+ this.presetsServices[i]
449
+ .updateCharacteristic(characteristicType, preset.state)
450
+ };
451
+ };
452
+ };
453
+
428
454
  //update buttons state
429
455
  if (this.buttonsConfiguredCount > 0) {
430
456
  for (let i = 0; i < this.buttonsConfiguredCount; i++) {
@@ -550,25 +576,6 @@ class DeviceAta extends EventEmitter {
550
576
  };
551
577
  };
552
578
 
553
- //update presets state
554
- if (this.presetsConfigured.length > 0) {
555
- for (let i = 0; i < this.presetsConfigured.length; i++) {
556
- const preset = this.presetsConfigured[i];
557
- preset.state = (preset.Power === power
558
- && preset.SetTemperature === setTemperature
559
- && preset.OperationMode === operationMode
560
- && preset.VaneHorizontal === vaneHorizontal
561
- && preset.VaneVertical === vaneVertical
562
- && preset.FanSpeed === setFanSpeed) ?? false;
563
-
564
- if (this.presetsServices) {
565
- const characteristicType = preset.characteristicType;
566
- this.presetsServices[i]
567
- .updateCharacteristic(characteristicType, preset.state)
568
- };
569
- };
570
- };
571
-
572
579
  //log current state
573
580
  if (!this.disableLogInfo) {
574
581
  const operationModeText = !power ? CONSTANTS.AirConditioner.System[0] : CONSTANTS.AirConditioner.DriveMode[operationMode];
@@ -708,6 +715,7 @@ class DeviceAta extends EventEmitter {
708
715
  .setCharacteristic(Characteristic.FirmwareRevision, this.firmwareRevision);
709
716
 
710
717
  //melcloud services
718
+ const presetsOnServer = this.accessory.presetsOnServer;
711
719
  const displayMode = this.displayMode;
712
720
  const temperatureSensor = this.temperatureSensor;
713
721
  const temperatureSensorOutdoor = this.temperatureSensorOutdoor;
@@ -1081,14 +1089,16 @@ class DeviceAta extends EventEmitter {
1081
1089
 
1082
1090
  for (let i = 0; i < presetsConfiguredCount; i++) {
1083
1091
  const preset = presetsConfigured[i];
1092
+ const index = presetsOnServer.findIndex(p => p.ID === preset.Id);
1093
+ const presetData = presetsOnServer[index];
1084
1094
 
1085
- //get button display type
1086
- const displayType = preset.displayType;
1087
-
1088
- //get button name
1095
+ //get preset name
1089
1096
  const presetName = preset.name;
1090
1097
 
1091
- //get button name prefix
1098
+ //get preset display type
1099
+ const displayType = button.displayType;
1100
+
1101
+ //get preset name prefix
1092
1102
  const presetNamePrefix = preset.namePrefix;
1093
1103
 
1094
1104
  const serviceName = presetNamePrefix ? `${accessoryName} ${presetName}` : presetName;
@@ -1103,16 +1113,20 @@ class DeviceAta extends EventEmitter {
1103
1113
  return state;
1104
1114
  })
1105
1115
  .onSet(async (state) => {
1116
+ if (displayType > 2) {
1117
+ return;
1118
+ };
1119
+
1106
1120
  try {
1107
1121
  switch (state) {
1108
1122
  case true:
1109
1123
  previousPresets[i] = deviceState;
1110
- deviceState.SetTemperature = preset.SetTemperature;
1111
- deviceState.Power = preset.Power;
1112
- deviceState.OperationMode = preset.OperationMode;
1113
- deviceState.VaneHorizontal = preset.VaneHorizontal;
1114
- deviceState.VaneVertical = preset.VaneVertical;
1115
- deviceState.SetFanSpeed = preset.FanSpeed;
1124
+ deviceState.SetTemperature = presetData.SetTemperature;
1125
+ deviceState.Power = presetData.Power;
1126
+ deviceState.OperationMode = presetData.OperationMode;
1127
+ deviceState.VaneHorizontal = presetData.VaneHorizontal;
1128
+ deviceState.VaneVertical = presetData.VaneVertical;
1129
+ deviceState.SetFanSpeed = presetData.FanSpeed;
1116
1130
  deviceState.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power;
1117
1131
  break;
1118
1132
  case false:
package/src/deviceatw.js CHANGED
@@ -214,6 +214,9 @@ class DeviceAtw extends EventEmitter {
214
214
  const returnTemperatureZone2 = deviceData.Device.ReturnTemperatureZone2;
215
215
  const returnTemperatureWaterTank = deviceData.Device.ReturnTemperatureBoiler;
216
216
 
217
+ //presets
218
+ const presetsOnServer = deviceData.Presets ?? [];
219
+
217
220
  //zones
218
221
  const hotWater = hasHotWaterTank ? 1 : 0;
219
222
  const zone2 = hasZone2 ? 1 : 0;
@@ -254,6 +257,7 @@ class DeviceAtw extends EventEmitter {
254
257
  const offline = deviceState.Offline;
255
258
 
256
259
  //accessory
260
+ this.accessory.presetsOnServer = presetsOnServer;
257
261
  this.accessory.power = power;
258
262
  this.accessory.offline = offline;
259
263
  this.accessory.unitStatus = unitStatus;
@@ -570,6 +574,34 @@ class DeviceAtw extends EventEmitter {
570
574
  };
571
575
  };
572
576
 
577
+ //update presets state
578
+ if (this.presetsConfigured.length > 0) {
579
+ for (let i = 0; i < this.presetsConfigured.length; i++) {
580
+ const preset = this.presetsConfigured[i];
581
+ const index = presetsOnServer.findIndex(p => p.ID === preset.Id);
582
+ const presetData = presetsOnServer[index];
583
+
584
+ preset.state = presetData ? (presetData.Power === power
585
+ && presetData.EcoHotWater === ecoHotWater
586
+ && presetData.OperationModeZone1 === operationModeZone1
587
+ && presetData.OperationModeZone2 === operationModeZone2
588
+ && presetData.SetTankWaterTemperature === setTankWaterTemperature
589
+ && presetData.SetTemperatureZone1 === setTemperatureZone1
590
+ && presetData.SetTemperatureZone2 === setTemperatureZone2
591
+ && presetData.ForcedHotWaterMode === forcedHotWaterMode
592
+ && presetData.SetHeatFlowTemperatureZone1 === setHeatFlowTemperatureZone1
593
+ && presetData.SetHeatFlowTemperatureZone2 === setHeatFlowTemperatureZone2
594
+ && presetData.SetCoolFlowTemperatureZone1 === setCoolFlowTemperatureZone1
595
+ && presetData.SetCoolFlowTemperatureZone2 === setCoolFlowTemperatureZone2) : false;
596
+
597
+ if (this.presetsServices) {
598
+ const characteristicType = preset.characteristicType;
599
+ this.presetsServices[i]
600
+ .updateCharacteristic(characteristicType, preset.state)
601
+ };
602
+ };
603
+ };
604
+
573
605
  //update buttons state
574
606
  if (this.buttonsConfiguredCount > 0) {
575
607
  for (let i = 0; i < this.buttonsConfiguredCount; i++) {
@@ -659,31 +691,6 @@ class DeviceAtw extends EventEmitter {
659
691
  };
660
692
  };
661
693
 
662
- //update presets state
663
- if (this.presetsConfigured.length > 0) {
664
- for (let i = 0; i < this.presetsConfigured.length; i++) {
665
- const preset = this.presetsConfigured[i];
666
- preset.state = (preset.Power === power
667
- && preset.EcoHotWater === ecoHotWater
668
- && preset.OperationModeZone1 === operationModeZone1
669
- && preset.OperationModeZone2 === operationModeZone2
670
- && preset.SetTankWaterTemperature === setTankWaterTemperature
671
- && preset.SetTemperatureZone1 === setTemperatureZone1
672
- && preset.SetTemperatureZone2 === setTemperatureZone2
673
- && preset.ForcedHotWaterMode === forcedHotWaterMode
674
- && preset.SetHeatFlowTemperatureZone1 === setHeatFlowTemperatureZone1
675
- && preset.SetHeatFlowTemperatureZone2 === setHeatFlowTemperatureZone2
676
- && preset.SetCoolFlowTemperatureZone1 === setCoolFlowTemperatureZone1
677
- && preset.SetCoolFlowTemperatureZone2 === setCoolFlowTemperatureZone2) ?? false;
678
-
679
- if (this.presetsServices) {
680
- const characteristicType = preset.characteristicType;
681
- this.presetsServices[i]
682
- .updateCharacteristic(characteristicType, preset.state)
683
- };
684
- };
685
- };
686
-
687
694
  //start prepare accessory
688
695
  if (this.startPrepareAccessory) {
689
696
  try {
@@ -827,6 +834,7 @@ class DeviceAtw extends EventEmitter {
827
834
 
828
835
  //melcloud services
829
836
  const zonesCount = this.zonesCount;
837
+ const presetsOnServer = this.accessory.presetsOnServer;
830
838
  const temperatureSensor = this.temperatureSensor;
831
839
  const temperatureSensorFlow = this.temperatureSensorFlow;
832
840
  const temperatureSensorReturn = this.temperatureSensorReturn;
@@ -1529,14 +1537,16 @@ class DeviceAtw extends EventEmitter {
1529
1537
 
1530
1538
  for (let i = 0; i < presetsConfiguredCount; i++) {
1531
1539
  const preset = presetsConfigured[i];
1540
+ const index = presetsOnServer.findIndex(p => p.ID === preset.Id);
1541
+ const presetData = presetsOnServer[index];
1532
1542
 
1533
- //get button display type
1534
- const displayType = preset.displayType;
1535
-
1536
- //get button name
1543
+ //get preset name
1537
1544
  const presetName = preset.name;
1538
1545
 
1539
- //get button name prefix
1546
+ //get preset display type
1547
+ const displayType = button.displayType;
1548
+
1549
+ //get preset name prefix
1540
1550
  const presetNamePrefix = preset.namePrefix;
1541
1551
 
1542
1552
  const serviceName = presetNamePrefix ? `${accessoryName} ${presetName}` : presetName;
@@ -1551,22 +1561,26 @@ class DeviceAtw extends EventEmitter {
1551
1561
  return state;
1552
1562
  })
1553
1563
  .onSet(async (state) => {
1564
+ if (displayType > 2) {
1565
+ return;
1566
+ };
1567
+
1554
1568
  try {
1555
1569
  switch (state) {
1556
1570
  case true:
1557
1571
  previousPresets[i] = deviceState;
1558
- deviceState.Power = preset.Power;
1559
- deviceState.EcoHotWater = preset.EcoHotWater;
1560
- deviceState.OperationModeZone1 = preset.OperationModeZone1;
1561
- deviceState.OperationModeZone2 = preset.OperationModeZone2;
1562
- deviceState.SetTankWaterTemperature = preset.SetTankWaterTemperature;
1563
- deviceState.SetTemperatureZone1 = preset.SetTemperatureZone1;
1564
- deviceState.SetTemperatureZone2 = preset.SetTemperatureZone2;
1565
- deviceState.ForcedHotWaterMode = preset.ForcedHotWaterMode;
1566
- deviceState.SetHeatFlowTemperatureZone1 = preset.SetHeatFlowTemperatureZone1;
1567
- deviceState.SetHeatFlowTemperatureZone2 = preset.SetHeatFlowTemperatureZone2;
1568
- deviceState.SetCoolFlowTemperatureZone1 = preset.SetCoolFlowTemperatureZone1;
1569
- deviceState.SetCoolFlowTemperatureZone2 = preset.SetCoolFlowTemperatureZone2;
1572
+ deviceState.Power = presetData.Power;
1573
+ deviceState.EcoHotWater = presetData.EcoHotWater;
1574
+ deviceState.OperationModeZone1 = presetData.OperationModeZone1;
1575
+ deviceState.OperationModeZone2 = presetData.OperationModeZone2;
1576
+ deviceState.SetTankWaterTemperature = presetData.SetTankWaterTemperature;
1577
+ deviceState.SetTemperatureZone1 = presetData.SetTemperatureZone1;
1578
+ deviceState.SetTemperatureZone2 = presetData.SetTemperatureZone2;
1579
+ deviceState.ForcedHotWaterMode = presetData.ForcedHotWaterMode;
1580
+ deviceState.SetHeatFlowTemperatureZone1 = presetData.SetHeatFlowTemperatureZone1;
1581
+ deviceState.SetHeatFlowTemperatureZone2 = presetData.SetHeatFlowTemperatureZone2;
1582
+ deviceState.SetCoolFlowTemperatureZone1 = presetData.SetCoolFlowTemperatureZone1;
1583
+ deviceState.SetCoolFlowTemperatureZone2 = presetData.SetCoolFlowTemperatureZone2;
1570
1584
  deviceState.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.Power;
1571
1585
  break;
1572
1586
  case false:
package/src/deviceerv.js CHANGED
@@ -211,6 +211,9 @@ class DeviceErv extends EventEmitter {
211
211
  const numberOfFanSpeeds = deviceData.Device.NumberOfFanSpeeds ?? 0;
212
212
  const temperatureIncrement = deviceData.Device.TemperatureIncrement ?? 1;
213
213
 
214
+ //presets
215
+ const presetsOnServer = deviceData.Presets ?? [];
216
+
214
217
  //device state
215
218
  const roomTemperature = deviceState.RoomTemperature;
216
219
  const supplyTemperature = deviceState.SupplyTemperature;
@@ -231,6 +234,7 @@ class DeviceErv extends EventEmitter {
231
234
  const targetTemperature = hasCoolOperationMode || hasHeatOperationMode ? setTemperature : 20;
232
235
 
233
236
  //accessory
237
+ this.accessory.presetsOnServer = presetsOnServer;
234
238
  this.accessory.power = power;
235
239
  this.accessory.offline = offline;
236
240
  this.accessory.roomTemperature = roomTemperature;
@@ -434,6 +438,27 @@ class DeviceErv extends EventEmitter {
434
438
  .updateCharacteristic(Characteristic.PM2_5Density, pM25Level)
435
439
  }
436
440
 
441
+ //update presets state
442
+ if (this.presetsConfigured.length > 0) {
443
+ for (let i = 0; i < this.presetsConfigured.length; i++) {
444
+ const preset = this.presetsConfigured[i];
445
+ const index = presetsOnServer.findIndex(p => p.ID === preset.Id);
446
+ const presetData = presetsOnServer[index];
447
+
448
+ preset.state = presetData ? (presetData.Power === power
449
+ && presetData.SetTemperature === targetTemperature
450
+ && presetData.OperationMode === operationMode
451
+ && presetData.VentilationMode === ventilationMode
452
+ && presetData.FanSpeed === setFanSpeed) : false;
453
+
454
+ if (this.presetsServices) {
455
+ const characteristicType = preset.characteristicType;
456
+ this.presetsServices[i]
457
+ .updateCharacteristic(characteristicType, preset.state)
458
+ };
459
+ };
460
+ };
461
+
437
462
  //update buttons state
438
463
  if (this.buttonsConfiguredCount > 0) {
439
464
  for (let i = 0; i < this.buttonsConfiguredCount; i++) {
@@ -496,24 +521,6 @@ class DeviceErv extends EventEmitter {
496
521
  };
497
522
  };
498
523
 
499
- //update presets state
500
- if (this.presetsConfigured.length > 0) {
501
- for (let i = 0; i < this.presetsConfigured.length; i++) {
502
- const preset = this.presetsConfigured[i];
503
- preset.state = (preset.Power === power
504
- && preset.SetTemperature === targetTemperature
505
- && preset.OperationMode === operationMode
506
- && preset.VentilationMode === ventilationMode
507
- && preset.FanSpeed === setFanSpeed) ?? false;
508
-
509
- if (this.presetsServices) {
510
- const characteristicType = preset.characteristicType;
511
- this.presetsServices[i]
512
- .updateCharacteristic(characteristicType, preset.state)
513
- };
514
- };
515
- };
516
-
517
524
  //log current state
518
525
  if (!this.disableLogInfo) {
519
526
  const operationModeText = !power ? CONSTANTS.Ventilation.System[0] : CONSTANTS.Ventilation.OperationMode[ventilationMode];
@@ -648,6 +655,7 @@ class DeviceErv extends EventEmitter {
648
655
  .setCharacteristic(Characteristic.FirmwareRevision, this.firmwareRevision);
649
656
 
650
657
  //melcloud services
658
+ const presetsOnServer = this.accessory.presetsOnServer;
651
659
  const displayMode = this.displayMode;
652
660
  const temperatureSensor = this.temperatureSensor;
653
661
  const temperatureSensorOutdoor = this.temperatureSensorOutdoor;
@@ -1078,14 +1086,16 @@ class DeviceErv extends EventEmitter {
1078
1086
 
1079
1087
  for (let i = 0; i < presetsConfiguredCount; i++) {
1080
1088
  const preset = presetsConfigured[i];
1089
+ const index = presetsOnServer.findIndex(p => p.ID === preset.Id);
1090
+ const presetData = presetsOnServer[index]
1081
1091
 
1082
- //get button display type
1083
- const displayType = preset.displayType;
1084
-
1085
- //get button name
1092
+ //get preset name
1086
1093
  const presetName = preset.name;
1087
1094
 
1088
- //get button name prefix
1095
+ //get preset display type
1096
+ const displayType = button.displayType;
1097
+
1098
+ //get preset name prefix
1089
1099
  const presetNamePrefix = preset.namePrefix;
1090
1100
 
1091
1101
  const serviceName = presetNamePrefix ? `${accessoryName} ${presetName}` : presetName;
@@ -1100,15 +1110,19 @@ class DeviceErv extends EventEmitter {
1100
1110
  return state;
1101
1111
  })
1102
1112
  .onSet(async (state) => {
1113
+ if (displayType > 2) {
1114
+ return;
1115
+ };
1116
+
1103
1117
  try {
1104
1118
  switch (state) {
1105
1119
  case true:
1106
1120
  previousPresets[i] = deviceState;
1107
- deviceState.SetTemperature = preset.SetTemperature;
1108
- deviceState.Power = preset.Power;
1109
- deviceState.OperationMode = preset.OperationMode;
1110
- deviceState.VentilationMode = preset.VentilationMode;
1111
- deviceState.SetFanSpeed = preset.FanSpeed;
1121
+ deviceState.SetTemperature = presetData.SetTemperature;
1122
+ deviceState.Power = presetData.Power;
1123
+ deviceState.OperationMode = presetData.OperationMode;
1124
+ deviceState.VentilationMode = presetData.VentilationMode;
1125
+ deviceState.SetFanSpeed = presetData.FanSpeed;
1112
1126
  deviceState.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power;
1113
1127
  break;
1114
1128
  case false: