homebridge-melcloud-control 2.5.0-beta.59 → 2.5.0-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.
@@ -205,165 +205,6 @@
205
205
  "description": "Here select the language used in MELCloud account.",
206
206
  "required": true
207
207
  },
208
- "ataDevices": {
209
- "title": "Devices ATA",
210
- "type": "array",
211
- "items": {
212
- "type": "object",
213
- "properties": {
214
- "name": {
215
- "title": "Name",
216
- "type": "string",
217
- "required": false
218
- },
219
- "id": {
220
- "title": "ID",
221
- "type": "integer",
222
- "required": false
223
- },
224
- "type": {
225
- "title": "Type",
226
- "type": "integer",
227
- "required": false
228
- },
229
- "displayMode": {
230
- "title": "Control",
231
- "type": "integer",
232
- "minimum": 0,
233
- "maximum": 2,
234
- "oneOf": [
235
- {
236
- "title": "None/Disabled",
237
- "enum": [
238
- 0
239
- ]
240
- },
241
- {
242
- "title": "Heater/Cooler",
243
- "enum": [
244
- 0
245
- ]
246
- },
247
- {
248
- "title": "Thermostat",
249
- "enum": [
250
- 1
251
- ]
252
- }
253
- ],
254
- "description": "Select device control mode displayed in HomeKit app.",
255
- "required": true
256
- }
257
- }
258
- },
259
- "required": false
260
- },
261
- "atwDevices": {
262
- "title": "Devices ATW",
263
- "type": "array",
264
- "items": {
265
- "type": "object",
266
- "properties": {
267
- "name": {
268
- "title": "Name",
269
- "type": "string",
270
- "required": false
271
- },
272
- "id": {
273
- "title": "Mode",
274
- "type": "integer",
275
- "required": false
276
- },
277
- "type": {
278
- "title": "Type",
279
- "type": "integer",
280
- "required": false
281
- },
282
- "displayMode": {
283
- "title": "Control",
284
- "type": "integer",
285
- "minimum": 0,
286
- "maximum": 2,
287
- "oneOf": [
288
- {
289
- "title": "None/Disabled",
290
- "enum": [
291
- 0
292
- ]
293
- },
294
- {
295
- "title": "Heater/Cooler",
296
- "enum": [
297
- 0
298
- ]
299
- },
300
- {
301
- "title": "Thermostat",
302
- "enum": [
303
- 1
304
- ]
305
- }
306
- ],
307
- "description": "Select device control mode displayed in HomeKit app.",
308
- "required": true
309
- }
310
- }
311
- },
312
- "required": false
313
- },
314
- "ervDevices": {
315
- "title": "Devices ERV",
316
- "type": "array",
317
- "items": {
318
- "type": "object",
319
- "properties": {
320
- "name": {
321
- "title": "Name",
322
- "type": "string",
323
- "required": false
324
- },
325
- "id": {
326
- "title": "Mode",
327
- "type": "integer",
328
- "required": false
329
- },
330
- "type": {
331
- "title": "Type",
332
- "type": "integer",
333
- "required": false
334
- },
335
- "displayMode": {
336
- "title": "Control",
337
- "type": "integer",
338
- "minimum": 0,
339
- "maximum": 2,
340
- "oneOf": [
341
- {
342
- "title": "None/Disabled",
343
- "enum": [
344
- 0
345
- ]
346
- },
347
- {
348
- "title": "Heater/Cooler",
349
- "enum": [
350
- 0
351
- ]
352
- },
353
- {
354
- "title": "Thermostat",
355
- "enum": [
356
- 1
357
- ]
358
- }
359
- ],
360
- "description": "Select device control mode displayed in HomeKit app.",
361
- "required": true
362
- }
363
- }
364
- },
365
- "required": false
366
- },
367
208
  "ataDisplayMode": {
368
209
  "title": "Control",
369
210
  "type": "integer",
@@ -1574,306 +1415,252 @@
1574
1415
  "accounts[].language",
1575
1416
  {
1576
1417
  "key": "accounts[]",
1577
- "type": "tabarray",
1578
- "title": "{{ value.title }}",
1418
+ "type": "section",
1419
+ "title": "Advanced Settings",
1420
+ "expandable": true,
1421
+ "expanded": false,
1579
1422
  "items": [
1580
1423
  {
1581
1424
  "key": "accounts[]",
1582
- "title": "Air Conditioner",
1425
+ "type": "tabarray",
1426
+ "title": "{{ value.title }}",
1583
1427
  "items": [
1584
1428
  {
1585
- "key": "accounts[].ataDevices",
1586
- "type": "tabarray",
1587
- "title": "{{ value.name }}",
1588
- "addable": false,
1429
+ "key": "accounts[]",
1430
+ "title": "Air Conditioner",
1589
1431
  "items": [
1432
+ "accounts[].ataDisplayMode",
1433
+ "accounts[].ataPresets",
1590
1434
  {
1591
- "key": "accounts[].ataDevices[].name",
1592
- "readonly": true
1435
+ "key": "accounts[]",
1436
+ "type": "section",
1437
+ "title": "Operating Modes",
1438
+ "expandable": true,
1439
+ "expanded": false,
1440
+ "items": [
1441
+ "accounts[].ataHeatDryFanMode",
1442
+ "accounts[].ataCoolDryFanMode",
1443
+ "accounts[].ataAutoDryFanMode"
1444
+ ]
1593
1445
  },
1594
1446
  {
1595
- "key": "accounts[].ataDevices[].id",
1596
- "readonly": true
1447
+ "key": "accounts[]",
1448
+ "type": "section",
1449
+ "title": "Temperature Sensors",
1450
+ "expandable": true,
1451
+ "expanded": false,
1452
+ "items": [
1453
+ "accounts[].ataTemperatureSensor",
1454
+ "accounts[].ataTemperatureSensorOutdoor"
1455
+ ]
1597
1456
  },
1598
1457
  {
1599
- "key": "accounts[].ataDevices[].type",
1600
- "readonly": true
1458
+ "key": "accounts[]",
1459
+ "type": "section",
1460
+ "title": "Buttons / Sensors",
1461
+ "expandable": true,
1462
+ "expanded": false,
1463
+ "items": [
1464
+ {
1465
+ "key": "accounts[].ataButtons",
1466
+ "type": "tabarray",
1467
+ "title": "{{ value.name || 'button/sensor' }}",
1468
+ "items": [
1469
+ "accounts[].ataButtons[].name",
1470
+ "accounts[].ataButtons[].mode",
1471
+ "accounts[].ataButtons[].displayType",
1472
+ "accounts[].ataButtons[].namePrefix"
1473
+ ]
1474
+ }
1475
+ ]
1601
1476
  },
1602
- "accounts[].ataDevices[].displayMode"
1603
- ]
1604
- },
1605
- "accounts[].ataDisplayMode",
1606
- "accounts[].ataPresets",
1607
- {
1608
- "key": "accounts[]",
1609
- "type": "section",
1610
- "title": "Operating Modes",
1611
- "expandable": true,
1612
- "expanded": false,
1613
- "items": [
1614
- "accounts[].ataHeatDryFanMode",
1615
- "accounts[].ataCoolDryFanMode",
1616
- "accounts[].ataAutoDryFanMode"
1617
- ]
1618
- },
1619
- {
1620
- "key": "accounts[]",
1621
- "type": "section",
1622
- "title": "Temperature Sensors",
1623
- "expandable": true,
1624
- "expanded": false,
1625
- "items": [
1626
- "accounts[].ataTemperatureSensor",
1627
- "accounts[].ataTemperatureSensorOutdoor"
1628
- ]
1629
- },
1630
- {
1631
- "key": "accounts[]",
1632
- "type": "section",
1633
- "title": "Buttons / Sensors",
1634
- "expandable": true,
1635
- "expanded": false,
1636
- "items": [
1637
1477
  {
1638
- "key": "accounts[].ataButtons",
1639
- "type": "tabarray",
1640
- "title": "{{ value.name || 'button/sensor' }}",
1478
+ "key": "accounts[]",
1479
+ "type": "section",
1480
+ "title": "Hide Device By Id",
1481
+ "expandable": true,
1482
+ "expanded": false,
1641
1483
  "items": [
1642
- "accounts[].ataButtons[].name",
1643
- "accounts[].ataButtons[].mode",
1644
- "accounts[].ataButtons[].displayType",
1645
- "accounts[].ataButtons[].namePrefix"
1484
+ {
1485
+ "key": "accounts[].ataHideDeviceById",
1486
+ "type": "tabarray",
1487
+ "title": "{{ value.name || 'device' }}",
1488
+ "items": [
1489
+ "accounts[].ataHideDeviceById[].name",
1490
+ "accounts[].ataHideDeviceById[].id"
1491
+ ]
1492
+ }
1646
1493
  ]
1647
1494
  }
1648
1495
  ]
1649
1496
  },
1650
1497
  {
1651
1498
  "key": "accounts[]",
1652
- "type": "section",
1653
- "title": "Hide Device By Id",
1654
- "expandable": true,
1655
- "expanded": false,
1499
+ "title": "Heat Pump",
1656
1500
  "items": [
1501
+ "accounts[].atwDisplayMode",
1502
+ "accounts[].atwPresets",
1657
1503
  {
1658
- "key": "accounts[].ataHideDeviceById",
1659
- "type": "tabarray",
1660
- "title": "{{ value.name || 'device' }}",
1504
+ "key": "accounts[]",
1505
+ "type": "section",
1506
+ "title": "Temperature Sensors",
1507
+ "expandable": true,
1508
+ "expanded": false,
1661
1509
  "items": [
1662
- "accounts[].ataHideDeviceById[].name",
1663
- "accounts[].ataHideDeviceById[].id"
1510
+ "accounts[].atwTemperatureSensor",
1511
+ "accounts[].atwTemperatureSensorFlow",
1512
+ "accounts[].atwTemperatureSensorReturn",
1513
+ "accounts[].atwTemperatureSensorFlowZone1",
1514
+ "accounts[].atwTemperatureSensorReturnZone1",
1515
+ "accounts[].atwTemperatureSensorFlowWaterTank",
1516
+ "accounts[].atwTemperatureSensorReturnWaterTank",
1517
+ "accounts[].atwTemperatureSensorFlowZone2",
1518
+ "accounts[].atwTemperatureSensorReturnZone2"
1664
1519
  ]
1665
- }
1666
- ]
1667
- }
1668
- ]
1669
- },
1670
- {
1671
- "key": "accounts[]",
1672
- "title": "Heat Pump",
1673
- "items": [
1674
- {
1675
- "key": "accounts[].atwDevices",
1676
- "type": "tabarray",
1677
- "title": "{{ value.name }}",
1678
- "addable": false,
1679
- "items": [
1680
- {
1681
- "key": "accounts[].atwDevices[].name",
1682
- "readonly": true
1683
1520
  },
1684
1521
  {
1685
- "key": "accounts[].atwDevices[].id",
1686
- "readonly": true
1522
+ "key": "accounts[]",
1523
+ "type": "section",
1524
+ "title": "Buttons / Sensors",
1525
+ "expandable": true,
1526
+ "expanded": false,
1527
+ "items": [
1528
+ {
1529
+ "key": "accounts[].atwButtons",
1530
+ "type": "tabarray",
1531
+ "title": "{{ value.name || 'button/sensor' }}",
1532
+ "items": [
1533
+ "accounts[].atwButtons[].name",
1534
+ "accounts[].atwButtons[].mode",
1535
+ "accounts[].atwButtons[].displayType",
1536
+ "accounts[].atwButtons[].namePrefix"
1537
+ ]
1538
+ }
1539
+ ]
1687
1540
  },
1688
1541
  {
1689
- "key": "accounts[].atwDevices[].type",
1690
- "readonly": true
1691
- },
1692
- "accounts[].atwDevices[].displayMode"
1693
- ]
1694
- },
1695
- "accounts[].atwDisplayMode",
1696
- "accounts[].atwPresets",
1697
- {
1698
- "key": "accounts[]",
1699
- "type": "section",
1700
- "title": "Temperature Sensors",
1701
- "expandable": true,
1702
- "expanded": false,
1703
- "items": [
1704
- "accounts[].atwTemperatureSensor",
1705
- "accounts[].atwTemperatureSensorFlow",
1706
- "accounts[].atwTemperatureSensorReturn",
1707
- "accounts[].atwTemperatureSensorFlowZone1",
1708
- "accounts[].atwTemperatureSensorReturnZone1",
1709
- "accounts[].atwTemperatureSensorFlowWaterTank",
1710
- "accounts[].atwTemperatureSensorReturnWaterTank",
1711
- "accounts[].atwTemperatureSensorFlowZone2",
1712
- "accounts[].atwTemperatureSensorReturnZone2"
1713
- ]
1714
- },
1715
- {
1716
- "key": "accounts[]",
1717
- "type": "section",
1718
- "title": "Buttons / Sensors",
1719
- "expandable": true,
1720
- "expanded": false,
1721
- "items": [
1722
- {
1723
- "key": "accounts[].atwButtons",
1724
- "type": "tabarray",
1725
- "title": "{{ value.name || 'button/sensor' }}",
1542
+ "key": "accounts[]",
1543
+ "type": "section",
1544
+ "title": "Hide Device By Id",
1545
+ "expandable": true,
1546
+ "expanded": false,
1726
1547
  "items": [
1727
- "accounts[].atwButtons[].name",
1728
- "accounts[].atwButtons[].mode",
1729
- "accounts[].atwButtons[].displayType",
1730
- "accounts[].atwButtons[].namePrefix"
1548
+ {
1549
+ "key": "accounts[].atwHideDeviceById",
1550
+ "type": "tabarray",
1551
+ "title": "{{ value.name || 'device' }}",
1552
+ "items": [
1553
+ "accounts[].atwHideDeviceById[].name",
1554
+ "accounts[].atwHideDeviceById[].id"
1555
+ ]
1556
+ }
1731
1557
  ]
1732
1558
  }
1733
1559
  ]
1734
1560
  },
1735
1561
  {
1736
1562
  "key": "accounts[]",
1737
- "type": "section",
1738
- "title": "Hide Device By Id",
1739
- "expandable": true,
1740
- "expanded": false,
1563
+ "title": "Energy Recovery Ventilation",
1741
1564
  "items": [
1565
+ "accounts[].ervDisplayMode",
1566
+ "accounts[].ervPresets",
1742
1567
  {
1743
- "key": "accounts[].atwHideDeviceById",
1744
- "type": "tabarray",
1745
- "title": "{{ value.name || 'device' }}",
1568
+ "key": "accounts[]",
1569
+ "type": "section",
1570
+ "title": "Temperature Sensors",
1571
+ "expandable": true,
1572
+ "expanded": false,
1746
1573
  "items": [
1747
- "accounts[].atwHideDeviceById[].name",
1748
- "accounts[].atwHideDeviceById[].id"
1574
+ "accounts[].ervTemperatureSensor",
1575
+ "accounts[].ervTemperatureSensorOutdoor",
1576
+ "accounts[].ervTemperatureSensorSupply"
1749
1577
  ]
1750
- }
1751
- ]
1752
- }
1753
- ]
1754
- },
1755
- {
1756
- "key": "accounts[]",
1757
- "title": "Energy Recovery Ventilation",
1758
- "items": [
1759
- {
1760
- "key": "accounts[].ervDevices",
1761
- "type": "tabarray",
1762
- "title": "{{ value.name }}",
1763
- "addable": false,
1764
- "items": [
1765
- {
1766
- "key": "accounts[].ervDevices[].name",
1767
- "readonly": true
1768
- },
1769
- {
1770
- "key": "accounts[].ervDevices[].id",
1771
- "readonly": true
1772
1578
  },
1773
1579
  {
1774
- "key": "accounts[].ervDevices[].type",
1775
- "readonly": true
1580
+ "key": "accounts[]",
1581
+ "type": "section",
1582
+ "title": "Buttons / Sensors",
1583
+ "expandable": true,
1584
+ "expanded": false,
1585
+ "items": [
1586
+ {
1587
+ "key": "accounts[].ervButtons",
1588
+ "type": "tabarray",
1589
+ "title": "{{ value.name || 'button/sensor' }}",
1590
+ "items": [
1591
+ "accounts[].ervButtons[].name",
1592
+ "accounts[].ervButtons[].mode",
1593
+ "accounts[].ervButtons[].displayType",
1594
+ "accounts[].ervButtons[].namePrefix"
1595
+ ]
1596
+ }
1597
+ ]
1776
1598
  },
1777
- "accounts[].ervDevices[].displayMode"
1778
- ]
1779
- },
1780
- "accounts[].ervDisplayMode",
1781
- "accounts[].ervPresets",
1782
- {
1783
- "key": "accounts[]",
1784
- "type": "section",
1785
- "title": "Temperature Sensors",
1786
- "expandable": true,
1787
- "expanded": false,
1788
- "items": [
1789
- "accounts[].ervTemperatureSensor",
1790
- "accounts[].ervTemperatureSensorOutdoor",
1791
- "accounts[].ervTemperatureSensorSupply"
1792
- ]
1793
- },
1794
- {
1795
- "key": "accounts[]",
1796
- "type": "section",
1797
- "title": "Buttons / Sensors",
1798
- "expandable": true,
1799
- "expanded": false,
1800
- "items": [
1801
1599
  {
1802
- "key": "accounts[].ervButtons",
1803
- "type": "tabarray",
1804
- "title": "{{ value.name || 'button/sensor' }}",
1600
+ "key": "accounts[]",
1601
+ "type": "section",
1602
+ "title": "Hide Device By Id",
1603
+ "expandable": true,
1604
+ "expanded": false,
1805
1605
  "items": [
1806
- "accounts[].ervButtons[].name",
1807
- "accounts[].ervButtons[].mode",
1808
- "accounts[].ervButtons[].displayType",
1809
- "accounts[].ervButtons[].namePrefix"
1606
+ {
1607
+ "key": "accounts[].ervHideDeviceById",
1608
+ "type": "tabarray",
1609
+ "title": "{{ value.name || 'device' }}",
1610
+ "items": [
1611
+ "accounts[].ervHideDeviceById[].name",
1612
+ "accounts[].ervHideDeviceById[].id"
1613
+ ]
1614
+ }
1810
1615
  ]
1811
1616
  }
1812
1617
  ]
1813
1618
  },
1814
1619
  {
1815
1620
  "key": "accounts[]",
1816
- "type": "section",
1817
- "title": "Hide Device By Id",
1818
- "expandable": true,
1819
- "expanded": false,
1621
+ "title": "System",
1820
1622
  "items": [
1821
- {
1822
- "key": "accounts[].ervHideDeviceById",
1823
- "type": "tabarray",
1824
- "title": "{{ value.name || 'device' }}",
1825
- "items": [
1826
- "accounts[].ervHideDeviceById[].name",
1827
- "accounts[].ervHideDeviceById[].id"
1828
- ]
1829
- }
1623
+ "accounts[].enableDebugMode",
1624
+ "accounts[].disableLogInfo",
1625
+ "accounts[].disableLogDeviceInfo",
1626
+ "accounts[].refreshInterval",
1627
+ "accounts[].deviceRefreshInterval"
1830
1628
  ]
1831
- }
1832
- ]
1833
- },
1834
- {
1835
- "key": "accounts[]",
1836
- "title": "System",
1837
- "items": [
1838
- "accounts[].enableDebugMode",
1839
- "accounts[].disableLogInfo",
1840
- "accounts[].disableLogDeviceInfo",
1841
- "accounts[].refreshInterval",
1842
- "accounts[].deviceRefreshInterval"
1843
- ]
1844
- },
1845
- {
1846
- "key": "accounts[]",
1847
- "title": "External Integrations",
1848
- "items": [
1629
+ },
1849
1630
  {
1850
1631
  "key": "accounts[]",
1851
- "type": "tabarray",
1852
- "title": "{{ value.title }}",
1632
+ "title": "External Integrations",
1853
1633
  "items": [
1854
1634
  {
1855
- "key": "accounts[].restFul",
1856
- "title": "RESTFul",
1857
- "items": [
1858
- "accounts[].restFul.enable",
1859
- "accounts[].restFul.debug"
1860
- ]
1861
- },
1862
- {
1863
- "key": "accounts[].mqtt",
1864
- "title": "MQTT",
1635
+ "key": "accounts[]",
1636
+ "type": "tabarray",
1637
+ "title": "{{ value.title }}",
1865
1638
  "items": [
1866
- "accounts[].mqtt.enable",
1867
- "accounts[].mqtt.debug",
1868
- "accounts[].mqtt.host",
1869
- "accounts[].mqtt.port",
1870
- "accounts[].mqtt.clientId",
1871
- "accounts[].mqtt.prefix",
1872
- "accounts[].mqtt.auth",
1873
- "accounts[].mqtt.user",
1874
1639
  {
1875
- "key": "accounts[].mqtt.passwd",
1876
- "type": "password"
1640
+ "key": "accounts[].restFul",
1641
+ "title": "RESTFul",
1642
+ "items": [
1643
+ "accounts[].restFul.enable",
1644
+ "accounts[].restFul.debug"
1645
+ ]
1646
+ },
1647
+ {
1648
+ "key": "accounts[].mqtt",
1649
+ "title": "MQTT",
1650
+ "items": [
1651
+ "accounts[].mqtt.enable",
1652
+ "accounts[].mqtt.debug",
1653
+ "accounts[].mqtt.host",
1654
+ "accounts[].mqtt.port",
1655
+ "accounts[].mqtt.clientId",
1656
+ "accounts[].mqtt.prefix",
1657
+ "accounts[].mqtt.auth",
1658
+ "accounts[].mqtt.user",
1659
+ {
1660
+ "key": "accounts[].mqtt.passwd",
1661
+ "type": "password"
1662
+ }
1663
+ ]
1877
1664
  }
1878
1665
  ]
1879
1666
  }
@@ -6,45 +6,18 @@
6
6
  <div id="melCloudAccount" style="display: none;" class="card card-body">
7
7
  <form id="configForm">
8
8
  <div class="text-center">
9
- <label id="accountName" style="font-size: 23px">Account</label><br>
9
+ <label id="accountName" style="font-size: 23px">Account Name</label><br>
10
10
  <label id="info" style="text-align: center; font-size: 17px;">MELCloud</label><br><br>
11
11
  </div>
12
12
  <div class="form-group">
13
13
  <label for="name">Name</label>
14
14
  <input id="name" type="text" class="form-control"><br>
15
- <label for="user">User Name</label>
15
+ <label for="user">MELCloud User</label>
16
16
  <input id="user" type="text" class="form-control"><br>
17
- <label for="passwd">Password</label>
18
- <input id="passwd" type="password" class="form-control"><br>
17
+ <label for="passwd">MELCloud Password</label>
18
+ <input id="passwd" type="text" class="form-control"><br>
19
19
  <label for="language">Language</label>
20
- <select id="language" name="language" class="form-control"><br>
21
- <option value="0">English</option>
22
- <option value="1">Български</option>
23
- <option value="2">Čeština</option>
24
- <option value="3">Dansk</option>
25
- <option value="4">Deutsch</option>
26
- <option value="5">Eesti</option>
27
- <option value="6">Español</option>
28
- <option value="7">Français</option>
29
- <option value="8">Հայերեն</option>
30
- <option value="9">Latviešu</option>
31
- <option value="10">Lietuvių</option>
32
- <option value="11">Magyar</option>
33
- <option value="12">Nederlands</option>
34
- <option value="13">Norwegian</option>
35
- <option value="14">Polski</option>
36
- <option value="15">Português</option>
37
- <option value="16">Русский</option>
38
- <option value="17">Suomi</option>
39
- <option value="18">Svenska</option>
40
- <option value="19">Svenska</option>
41
- <option value="20">Українська</option>
42
- <option value="21">Türkçe</option>
43
- <option value="22">Ελληνικά</option>
44
- <option value="23">Hrvatski</option>
45
- <option value="24">Română</option>
46
- <option value="25">Slovenščina</option>
47
- </select>
20
+ <input id="language" type="text" class="form-control"><br>
48
21
  </div>
49
22
  <div class="text-center">
50
23
  <button id="logIn" type="button" class="btn btn-primary">Connect to MELCloud</button>
@@ -83,8 +56,6 @@
83
56
  const setRemoveAtribute = j === i ? document.getElementById(`button${j}`).setAttribute("class", "btn btn-secondary") : document.getElementById(`button${j}`).setAttribute("class", "btn btn-primary");
84
57
  }
85
58
 
86
- //const devicesCount = pluginConfig[0].accounts[i].devicesAta.length ?? 0;
87
- //document.getElementById('info').innerHTML = `MELCloud configured ${devicesCount} ${devicesCount} ${devicesCount !== 1 ? 'devices' : 'device'}.`;
88
59
  document.getElementById('accountName').innerHTML = pluginConfig[0].accounts[i].name || '';
89
60
  document.getElementById('name').value = pluginConfig[0].accounts[i].name || '';
90
61
  document.getElementById('user').value = pluginConfig[0].accounts[i].user || '';
@@ -92,8 +63,7 @@
92
63
  document.getElementById('language').value = pluginConfig[0].accounts[i].language || '';
93
64
 
94
65
  const accountConfigured = pluginConfig[0].accounts[i].name && pluginConfig[0].accounts[i].user && pluginConfig[0].accounts[i].passwd && pluginConfig[0].accounts[i].language;
95
- const setButtonState = accountConfigured ? document.getElementById('logIn').removeAttribute('disabled') : document.getElementById('logIn').setAttribute('disabled');
96
- document.getElementById('configButton').setAttribute('disabled');
66
+ const setButtonName = accountConfigured ? document.getElementById('logIn').removeAttribute('disabled') : document.getElementById('logIn').setAttribute('disabled');
97
67
  await homebridge.updatePluginConfig(pluginConfig);
98
68
  this.deviceIndex = i;
99
69
  });
@@ -112,7 +82,7 @@
112
82
  pluginConfig[0].accounts[this.deviceIndex].language = document.querySelector('#language').value;
113
83
 
114
84
  const accountConfigured = pluginConfig[0].accounts[i].name && pluginConfig[0].accounts[i].user && pluginConfig[0].accounts[i].passwd && pluginConfig[0].accounts[i].language;
115
- const setButtonState = accountConfigured ? document.getElementById('logIn').removeAttribute('disabled') : document.getElementById('logIn').setAttribute('disabled');
85
+ const setButtonMode = accountConfigured ? document.getElementById('logIn').removeAttribute('disabled') : document.getElementById('logIn').setAttribute('disabled');
116
86
 
117
87
  await homebridge.updatePluginConfig(pluginConfig);
118
88
  await homebridge.savePluginConfig(pluginConfig);
@@ -136,65 +106,55 @@
136
106
  const user = pluginConfig[0].accounts[this.deviceIndex].user;
137
107
  const passwd = pluginConfig[0].accounts[this.deviceIndex].passwd;
138
108
  const language = pluginConfig[0].accounts[this.deviceIndex].language;
109
+ const enableDebugMode = pluginConfig[0].accounts[this.deviceIndex].enableDebugMode;
110
+ const refreshInterval = pluginConfig[0].accounts[this.deviceIndex].refreshInterval;
139
111
 
140
112
  const payload = {
141
113
  accountName: accountName,
142
114
  user: user,
143
115
  passwd: passwd,
144
- language: language
116
+ language: language,
117
+ enableDebugMode: enableDebugMode,
118
+ refreshInterval: refreshInterval
145
119
  };
146
120
  const response = await homebridge.request('/connect', payload);
147
- const info = response.info ?? '';
121
+ const info = response.info;
148
122
  const status = response.status;
149
123
  const devices = response.data ?? [];
150
- const newDevices = [];
151
124
 
152
125
  switch (status) {
153
126
  case 0:
154
127
  //get device info fom devices
155
- devices.forEach((deviceInfo, index) => {
156
- const deviceType = deviceInfo.Type;
128
+ for (const deviceInfo of devices) {
157
129
  const deviceId = deviceInfo.DeviceID;
158
130
  const deviceName = deviceInfo.DeviceName;
159
- const device = { name: deviceName, id: deviceId, type: deviceType, displayMode: 0 };
131
+ };
160
132
 
161
- //config account keys
162
- const accountKeys = Object.keys(pluginConfig[0].accounts[this.deviceIndex]);
163
-
164
- //devices ata
165
- const ataDevices = accountKeys.includes('ataDevices') ? pluginConfig[0].accounts[this.deviceIndex].ataDevices : pluginConfig[0].accounts[this.deviceIndex].ataDevices = [];
166
- const ataDeviceIdExist = ataDevices.some(device => device.id === deviceId)
167
- const pushTypeAta = deviceType === 0 && !ataDeviceIdExist ? ataDevices.push(device) : false;
168
-
169
- //devices atw
170
- const atwDevices = accountKeys.includes('atwDevices') ? pluginConfig[0].accounts[this.deviceIndex].atwDevices : pluginConfig[0].accounts[this.deviceIndex].atwDevices = [];
171
- const atwDeviceIdExist = atwDevices.some(device => device.id === deviceId)
172
- const pushTypeAtw = deviceType === 1 && !atwDeviceIdExist ? atwDevices.push(device) : false;
173
-
174
- //devices erv
175
- const ervDevices = accountKeys.includes('ervDevices') ? pluginConfig[0].accounts[this.deviceIndex].ervDevices : pluginConfig[0].accounts[this.deviceIndex].ervDevices = [];
176
- const ervDeviceIdExist = ervDevices.some(device => device.id === deviceId)
177
- const pushTypeErv = deviceType === 3 && !ervDeviceIdExist ? ervDevices.push(device) : false;
178
-
179
- //push new devices to array
180
- const pushNewDevice = ataDeviceIdExist || atwDeviceIdExist || ervDeviceIdExist ? false : newDevices.push(deviceId);
181
- });
182
-
183
- const devicesCount = newDevices.length;
184
- document.getElementById('info').innerHTML = `Check devices complete, found ${devicesCount} ${devicesCount !== 1 ? 'new devices' : 'new device'}. ${devicesCount === 0 ? '' : 'Now You can start to configure it.'}`;
133
+ document.getElementById('info').innerHTML = `${info} Found: ${devices.length} devices. Now You can start to configure it.`;
185
134
  document.getElementById('info').style.color = 'green';
186
-
187
135
  await homebridge.updatePluginConfig(pluginConfig);
188
136
  await homebridge.savePluginConfig(pluginConfig);
189
137
  break;
190
138
  case 1:
191
139
  document.getElementById('info').innerHTML = info;
192
- document.getElementById('info').style.color = 'red';
140
+ document.getElementById('info').style.color = 'green';
193
141
  break;
194
- default:
195
- document.getElementById('info').innerHTML = `Received unknown status: ${status}, please try again.`;
142
+ case 2:
143
+ document.getElementById('info').innerHTML = info;
144
+ document.getElementById('info').style.color = 'white';
145
+ break;
146
+ case 3:
147
+ document.getElementById('info').innerHTML = info;
148
+ document.getElementById('info').style.color = 'gray';
149
+ break;
150
+ case 4:
151
+ document.getElementById('info').innerHTML = info;
196
152
  document.getElementById('info').style.color = 'yellow';
197
153
  break;
154
+ case 5:
155
+ document.getElementById('info').innerHTML = info;
156
+ document.getElementById('info').style.color = 'red';
157
+ break;
198
158
  };
199
159
 
200
160
  homebridge.hideSpinner();
@@ -19,26 +19,60 @@ class PluginUiServer extends HomebridgePluginUiServer {
19
19
  const user = payload.user;
20
20
  const passwd = payload.passwd;
21
21
  const language = payload.language;
22
+ const enableDebugMode = payload.enableDebugMode;
23
+ const refreshInterval = payload.refreshInterval;
22
24
  const accountInfoFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Account`;
23
25
  const deviceInfoFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Device_`;
24
26
  const buildingsFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Buildings`;
27
+ let data = {};
25
28
 
26
29
  try {
27
- let data = {};
28
- const melCloud = new MelCloud(user, passwd, language, accountInfoFile, deviceInfoFile, buildingsFile, false, 0, true);
29
- const contextKey = await melCloud.connect();
30
- const devices = await melCloud.chackDevicesList(contextKey);
31
- return data = {
32
- info: '',
33
- status: 0,
34
- data: devices
35
- };
30
+ const melCloud = new MelCloud(user, passwd, language, accountInfoFile, deviceInfoFile, buildingsFile, enableDebugMode, refreshInterval, false);
31
+ melCloud.on('devicesList', (devices) => {
32
+ data = {
33
+ info: 'Check devices list complete.',
34
+ status: 0,
35
+ data: devices
36
+ };
37
+ })
38
+ .on('success', (message) => {
39
+ data = {
40
+ info: message,
41
+ status: 1
42
+ };
43
+ })
44
+ .on('message', (message) => {
45
+ data = {
46
+ info: message,
47
+ status: 2
48
+ };
49
+ })
50
+ .on('debug', (debug) => {
51
+ data = {
52
+ info: debug,
53
+ status: 3
54
+ };
55
+ })
56
+ .on('warn', (warn) => {
57
+ data = {
58
+ info: warn,
59
+ status: 4
60
+ };
61
+ })
62
+ .on('error', async (error) => {
63
+ data = {
64
+ info: error,
65
+ status: 5
66
+ };
67
+ });
36
68
  } catch (error) {
37
- return data = {
69
+ data = {
38
70
  info: error,
39
- status: 1
71
+ status: 5
40
72
  };
41
73
  };
74
+
75
+ return data;
42
76
  };
43
77
  };
44
78
 
package/index.js CHANGED
@@ -78,7 +78,7 @@ class MelCloudPlatform {
78
78
  const deviceRefreshInterval = account.deviceRefreshInterval * 1000 || 5000;
79
79
 
80
80
  //melcloud account
81
- const melCloud = new MelCloud(user, passwd, language, accountInfoFile, buildingsFile, deviceInfoFile, enableDebugMode, refreshInterval, false);
81
+ const melCloud = new MelCloud(user, passwd, language, accountInfoFile, buildingsFile, deviceInfoFile, enableDebugMode, refreshInterval, true);
82
82
  melCloud.on('checkDevicesListComplete', (accountInfo, contextKey, deviceInfo) => {
83
83
  const deviceId = deviceInfo.DeviceID.toString();
84
84
  const deviceType = deviceInfo.Type;
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.59",
4
+ "version": "2.5.0-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",
package/src/melcloud.js CHANGED
@@ -8,15 +8,14 @@ const ImpulseGenerator = require('./impulsegenerator.js');
8
8
  const CONSTANTS = require('./constants.json');
9
9
 
10
10
  class MelCloud extends EventEmitter {
11
- constructor(user, passwd, language, accountInfoFile, deviceInfoFile, buildingsFile, enableDebugMode, refreshInterval, connectForConfig) {
11
+ constructor(user, passwd, language, accountInfoFile, deviceInfoFile, buildingsFile, enableDebugMode, refreshInterval, startImpulseGenerator) {
12
12
  super();
13
+ this.enableDebugMode = enableDebugMode;
13
14
  this.accountInfoFile = accountInfoFile;
14
15
  this.buildingsFile = buildingsFile;
15
16
  this.deviceInfoFile = deviceInfoFile;
16
- this.enableDebugMode = enableDebugMode;
17
17
  this.refreshInterval = refreshInterval;
18
- this.connectForConfig = connectForConfig;
19
- this.contextKey = '';
18
+ this.startImpulseGenerator = startImpulseGenerator;
20
19
  this.devicesId = [];
21
20
 
22
21
  this.options = {
@@ -31,18 +30,16 @@ class MelCloud extends EventEmitter {
31
30
  }
32
31
  };
33
32
 
34
- if (!connectForConfig) {
35
- this.impulseGenerator = new ImpulseGenerator();
36
- this.impulseGenerator.on('checkDevicesList', async () => {
37
- try {
38
- await this.chackDevicesList(this.contextKey);
39
- } catch (error) {
40
- this.emit('error', `Check devices list: ${error}.`);
41
- };
42
- }).on('state', (state) => { });
43
-
44
- this.connect();
45
- };
33
+ this.impulseGenerator = new ImpulseGenerator();
34
+ this.impulseGenerator.on('checkDevicesList', async () => {
35
+ try {
36
+ await this.chackDevicesList();
37
+ } catch (error) {
38
+ this.emit('error', `Check devices list: ${error}.`);
39
+ };
40
+ }).on('state', (state) => { });
41
+
42
+ this.connect();
46
43
  };
47
44
 
48
45
  async connect() {
@@ -82,26 +79,57 @@ class MelCloud extends EventEmitter {
82
79
  this.emit('warn', `Context key: ${contextKey}, missing.`)
83
80
  return;
84
81
  };
82
+
83
+ //create axios instance get
84
+ this.axiosInstanceGet = axios.create({
85
+ method: 'GET',
86
+ baseURL: CONSTANTS.ApiUrls.BaseURL,
87
+ timeout: 5000,
88
+ headers: {
89
+ 'X-MitsContextKey': contextKey
90
+ },
91
+ maxContentLength: 100000000,
92
+ maxBodyLength: 1000000000,
93
+ withCredentials: true,
94
+ httpsAgent: new https.Agent({
95
+ keepAlive: false,
96
+ rejectUnauthorized: false
97
+ })
98
+ });
99
+
100
+ //create axios instance post
101
+ this.axiosInstancePost = axios.create({
102
+ method: 'POST',
103
+ baseURL: CONSTANTS.ApiUrls.BaseURL,
104
+ timeout: 5000,
105
+ headers: {
106
+ 'X-MitsContextKey': contextKey,
107
+ 'content-type': 'application/json'
108
+ },
109
+ maxContentLength: 100000000,
110
+ maxBodyLength: 1000000000,
111
+ withCredentials: true,
112
+ httpsAgent: new https.Agent({
113
+ keepAlive: false,
114
+ rejectUnauthorized: false
115
+ })
116
+ });
117
+
85
118
  this.accountInfo = accountInfo;
86
119
  this.contextKey = contextKey;
87
120
 
88
- //return if connect for config
89
- if (this.connectForConfig) {
90
- return contextKey;
91
- };
92
-
93
121
  //save melcloud info to the file
94
122
  await this.saveData(this.accountInfoFile, accountInfo);
95
123
 
96
124
  //check devices list
97
- await this.chackDevicesList(contextKey);
125
+ await this.chackDevicesList();
98
126
 
99
127
  //emit connect success
100
128
  this.emit('success', `Connect to MELCloud Success.`)
101
129
 
102
130
  //start impulse generator
103
131
  const timers = [{ name: 'checkDevicesList', sampling: this.refreshInterval }];
104
- this.impulseGenerator.start(timers);
132
+ const startImpulseGenerator = this.startImpulseGenerator ? this.impulseGenerator.start(timers) : false;
105
133
 
106
134
  return true;
107
135
  } catch (error) {
@@ -109,27 +137,10 @@ class MelCloud extends EventEmitter {
109
137
  };
110
138
  }
111
139
 
112
- async chackDevicesList(contextKey) {
140
+ async chackDevicesList() {
113
141
  try {
114
- //create axios instance get
115
- const axiosInstanceGet = axios.create({
116
- method: 'GET',
117
- baseURL: CONSTANTS.ApiUrls.BaseURL,
118
- timeout: 5000,
119
- headers: {
120
- 'X-MitsContextKey': contextKey
121
- },
122
- maxContentLength: 100000000,
123
- maxBodyLength: 1000000000,
124
- withCredentials: true,
125
- httpsAgent: new https.Agent({
126
- keepAlive: false,
127
- rejectUnauthorized: false
128
- })
129
- });
130
-
131
142
  const debug = this.enableDebugMode ? this.emit('debug', `Scanning for devices.`) : false;
132
- const listDevicesData = await axiosInstanceGet(CONSTANTS.ApiUrls.ListDevices);
143
+ const listDevicesData = await this.axiosInstanceGet(CONSTANTS.ApiUrls.ListDevices);
133
144
  const buildingsList = listDevicesData.data;
134
145
  const debug1 = this.enableDebugMode ? this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`) : false;
135
146
 
@@ -165,11 +176,6 @@ class MelCloud extends EventEmitter {
165
176
  }
166
177
  const debug3 = this.enableDebugMode ? this.emit('debug', `Found: ${devicesCount} devices.`) : false;
167
178
 
168
- //return devices list for config
169
- if (this.connectForConfig) {
170
- return devices;
171
- };
172
-
173
179
  //get device info fom devices
174
180
  for (const deviceInfo of devices) {
175
181
  const deviceId = deviceInfo.DeviceID
@@ -183,13 +189,16 @@ class MelCloud extends EventEmitter {
183
189
  //prepare device if not in devices array
184
190
  if (!this.devicesId.includes(deviceId)) {
185
191
  this.devicesId.push(deviceId);
186
- this.emit('checkDevicesListComplete', this.accountInfo, contextKey, deviceInfo);
192
+ this.emit('checkDevicesListComplete', this.accountInfo, this.contextKey, deviceInfo);
187
193
  }
188
194
  };
189
195
 
196
+ //emit devices list
197
+ this.emit('devicesList', devices);
198
+
190
199
  return true;
191
200
  } catch (error) {
192
- const stop = connectForConfig ? false : this.impulseGenerator.stop();
201
+ this.impulseGenerator.stop();
193
202
  throw new Error(`Scanning for devices error: ${error.message ?? error}.`);
194
203
  };
195
204
  }
@@ -206,29 +215,11 @@ class MelCloud extends EventEmitter {
206
215
 
207
216
  async send(accountInfo) {
208
217
  try {
209
- //create axios instance post
210
- const axiosInstancePost = axios.create({
211
- method: 'POST',
212
- baseURL: CONSTANTS.ApiUrls.BaseURL,
213
- timeout: 5000,
214
- headers: {
215
- 'X-MitsContextKey': this.contextKey,
216
- 'content-type': 'application/json'
217
- },
218
- maxContentLength: 100000000,
219
- maxBodyLength: 1000000000,
220
- withCredentials: true,
221
- httpsAgent: new https.Agent({
222
- keepAlive: false,
223
- rejectUnauthorized: false
224
- })
225
- });
226
-
227
218
  const options = {
228
219
  data: accountInfo
229
220
  };
230
221
 
231
- await axiosInstancePost(CONSTANTS.ApiUrls.UpdateApplicationOptions, options);
222
+ await this.axiosInstancePost(CONSTANTS.ApiUrls.UpdateApplicationOptions, options);
232
223
  await this.saveData(this.accountInfoFile, accountInfo);
233
224
  return true;
234
225
  } catch (error) {