homebridge-melcloud-control 3.0.7-beta.19 → 3.0.7-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.
@@ -1437,13 +1437,22 @@
1437
1437
  "type": "tabarray",
1438
1438
  "title": "{{ value.name || 'account' }}",
1439
1439
  "items": [
1440
- "accounts[].name",
1441
- "accounts[].user",
1442
1440
  {
1443
- "key": "accounts[].passwd",
1444
- "type": "password"
1441
+ "key": "accounts[]",
1442
+ "type": "section",
1443
+ "title": "MELCloud Credentials",
1444
+ "expandable": true,
1445
+ "expanded": false,
1446
+ "items": [
1447
+ "accounts[].name",
1448
+ "accounts[].user",
1449
+ {
1450
+ "key": "accounts[].passwd",
1451
+ "type": "password"
1452
+ },
1453
+ "accounts[].language"
1454
+ ]
1445
1455
  },
1446
- "accounts[].language",
1447
1456
  {
1448
1457
  "key": "accounts[]",
1449
1458
  "type": "tabarray",
@@ -1651,72 +1660,50 @@
1651
1660
  ]
1652
1661
  }
1653
1662
  ]
1654
- }
1655
- ]
1656
- },
1657
- {
1658
- "key": "accounts[]",
1659
- "type": "section",
1660
- "title": "Advanced Settings",
1661
- "expandable": true,
1662
- "expanded": false,
1663
- "items": [
1663
+ },
1664
1664
  {
1665
1665
  "key": "accounts[]",
1666
- "type": "tabarray",
1667
- "title": "{{ value.name }}",
1666
+ "title": "System",
1667
+ "items": [
1668
+ "accounts[].enableDebugMode",
1669
+ "accounts[].disableLogInfo",
1670
+ "accounts[].disableLogDeviceInfo",
1671
+ "accounts[].refreshInterval",
1672
+ "accounts[].deviceRefreshInterval"
1673
+ ]
1674
+ },
1675
+ {
1676
+ "key": "accounts[]",
1677
+ "title": "External Integrations",
1668
1678
  "items": [
1669
1679
  {
1670
1680
  "key": "accounts[]",
1671
- "title": "Data Refresh",
1672
- "items": [
1673
- "accounts[].refreshInterval",
1674
- "accounts[].deviceRefreshInterval"
1675
- ]
1676
- },
1677
- {
1678
- "key": "accounts[]",
1679
- "title": "Log",
1680
- "items": [
1681
- "accounts[].enableDebugMode",
1682
- "accounts[].disableLogInfo",
1683
- "accounts[].disableLogDeviceInfo"
1684
- ]
1685
- },
1686
- {
1687
- "key": "accounts[]",
1688
- "title": "External Integrations",
1681
+ "type": "tabarray",
1682
+ "title": "{{ value.title }}",
1689
1683
  "items": [
1690
1684
  {
1691
- "key": "accounts[]",
1692
- "type": "tabarray",
1693
- "title": "{{ value.title }}",
1685
+ "key": "accounts[].restFul",
1686
+ "title": "RESTFul",
1694
1687
  "items": [
1688
+ "accounts[].restFul.enable",
1689
+ "accounts[].restFul.debug"
1690
+ ]
1691
+ },
1692
+ {
1693
+ "key": "accounts[].mqtt",
1694
+ "title": "MQTT",
1695
+ "items": [
1696
+ "accounts[].mqtt.enable",
1697
+ "accounts[].mqtt.debug",
1698
+ "accounts[].mqtt.host",
1699
+ "accounts[].mqtt.port",
1700
+ "accounts[].mqtt.clientId",
1701
+ "accounts[].mqtt.prefix",
1702
+ "accounts[].mqtt.auth",
1703
+ "accounts[].mqtt.user",
1695
1704
  {
1696
- "key": "accounts[].restFul",
1697
- "title": "RESTFul",
1698
- "items": [
1699
- "accounts[].restFul.enable",
1700
- "accounts[].restFul.debug"
1701
- ]
1702
- },
1703
- {
1704
- "key": "accounts[].mqtt",
1705
- "title": "MQTT",
1706
- "items": [
1707
- "accounts[].mqtt.enable",
1708
- "accounts[].mqtt.debug",
1709
- "accounts[].mqtt.host",
1710
- "accounts[].mqtt.port",
1711
- "accounts[].mqtt.clientId",
1712
- "accounts[].mqtt.prefix",
1713
- "accounts[].mqtt.auth",
1714
- "accounts[].mqtt.user",
1715
- {
1716
- "key": "accounts[].mqtt.passwd",
1717
- "type": "password"
1718
- }
1719
- ]
1705
+ "key": "accounts[].mqtt.passwd",
1706
+ "type": "password"
1720
1707
  }
1721
1708
  ]
1722
1709
  }
@@ -1,10 +1,56 @@
1
- <div style="text-align: center;">
2
- </divstyle>
3
- <img src="homebridge-melcloud-control.png" alt="Image" height="150" />
1
+ <div>
2
+ <img src="homebridge-melcloud-control.png" style="text-align: center;" height="150" />
4
3
  </div>
5
-
6
- <div id="melCloudTabs">
7
- <!-- Tabs will be dynamically inserted here -->
4
+ <div id="accounts">
5
+ </div>
6
+ <div id="melCloudAccount" style="display: none;" class="card card-body">
7
+ <form id="configForm">
8
+ <div class="text-center">
9
+ <label id="accountName" style="font-size: 23px">Account</label><br>
10
+ <label id="info" style="text-align: center; font-size: 17px;">MELCloud</label><br><br>
11
+ </div>
12
+ <div class="form-group">
13
+ <label for="name">Name</label>
14
+ <input id="name" type="text" class="form-control"><br>
15
+ <label for="user">User Name</label>
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>
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>
48
+ </div>
49
+ <div class="text-center">
50
+ <button id="logIn" type="button" class="btn btn-primary">Connect to MELCloud</button>
51
+ <button id="configButton" type="button" class="btn btn-primary"><i class="fas fa-gear"></i></button>
52
+ </div>
53
+ </form>
8
54
  </div>
9
55
 
10
56
  <script>
@@ -23,161 +69,13 @@
23
69
  const accountsCount = pluginConfig[0].accounts.length;
24
70
  this.deviceIndex = 0;
25
71
  for (let i = 0; i < accountsCount; i++) {
26
-
27
- // Array of languages for the dropdown
28
- const languages = [
29
- { value: "0", text: "English" },
30
- { value: "1", text: "Български" },
31
- { value: "2", text: "Čeština" },
32
- { value: "3", text: "Dansk" },
33
- { value: "4", text: "Deutsch" },
34
- { value: "5", text: "Eesti" },
35
- { value: "6", text: "Español" },
36
- { value: "7", text: "Français" },
37
- { value: "8", text: "Հայերեն" },
38
- { value: "9", text: "Latviešu" },
39
- { value: "10", text: "Lietuvių" },
40
- { value: "11", text: "Magyar" },
41
- { value: "12", text: "Nederlands" },
42
- { value: "13", text: "Norwegian" },
43
- { value: "14", text: "Polski" },
44
- { value: "15", text: "Português" },
45
- { value: "16", text: "Русский" },
46
- { value: "17", text: "Suomi" },
47
- { value: "18", text: "Svenska" },
48
- { value: "19", text: "Svenska" },
49
- { value: "20", text: "Українська" },
50
- { value: "21", text: "Türkçe" },
51
- { value: "22", text: "Ελληνικά" },
52
- { value: "23", text: "Hrvatski" },
53
- { value: "24", text: "Română" },
54
- { value: "25", text: "Slovenščina" }
55
- ];
56
-
57
- // Get the melCloudTabs container
58
- const melCloudTabs = document.getElementById('melCloudTabs');
59
-
60
- // Loop through and create tabs for each account
61
- for (let i = 0; i < accountsCount; i++) {
62
- // Create the tab container
63
- const melCloudAccount = document.createElement('div');
64
- melCloudAccount.className = 'card card-body';
65
- melCloudAccount.id = `melCloudAccount${i}`;
66
-
67
- // Create the form
68
- const form = document.createElement('form');
69
- form.id = `configForm${i}`;
70
-
71
- // Create the header section
72
- const headerDiv = document.createElement('div');
73
- headerDiv.className = 'text-center';
74
-
75
- const accountName = document.createElement('label');
76
- accountName.id = `accountName${i}`;
77
- accountName.style.fontSize = '23px';
78
- accountName.textContent = `Account ${i + 1}`;
79
-
80
- const info = document.createElement('label');
81
- info.id = `info${i}`;
82
- info.style.fontSize = '17px';
83
- info.textContent = 'MELCloud';
84
-
85
- headerDiv.appendChild(accountName);
86
- headerDiv.appendChild(info);
87
- headerDiv.appendChild(document.createElement('br'));
88
- headerDiv.appendChild(document.createElement('br'));
89
-
90
- // Create the form group with inputs
91
- const formGroup = document.createElement('div');
92
- formGroup.className = 'form-group';
93
-
94
- const nameLabel = document.createElement('label');
95
- nameLabel.htmlFor = `name${i}`;
96
- nameLabel.textContent = 'Name';
97
-
98
- const nameInput = document.createElement('input');
99
- nameInput.id = `name${i}`;
100
- nameInput.type = 'text';
101
- nameInput.className = 'form-control';
102
-
103
- const userLabel = document.createElement('label');
104
- userLabel.htmlFor = `user${i}`;
105
- userLabel.textContent = 'User Name';
106
-
107
- const userInput = document.createElement('input');
108
- userInput.id = `user${i}`;
109
- userInput.type = 'text';
110
- userInput.className = 'form-control';
111
-
112
- const passwdLabel = document.createElement('label');
113
- passwdLabel.htmlFor = `passwd${i}`;
114
- passwdLabel.textContent = 'Password';
115
-
116
- const passwdInput = document.createElement('input');
117
- passwdInput.id = `passwd${i}`;
118
- passwdInput.type = 'password';
119
- passwdInput.className = 'form-control';
120
-
121
- const languageLabel = document.createElement('label');
122
- languageLabel.htmlFor = `language${i}`;
123
- languageLabel.textContent = 'Language';
124
-
125
- const languageSelect = document.createElement('select');
126
- languageSelect.id = `language${i}`;
127
- languageSelect.name = 'language';
128
- languageSelect.className = 'form-control';
129
-
130
- // Populate the language dropdown
131
- languages.forEach(lang => {
132
- const option = document.createElement('option');
133
- option.value = lang.value;
134
- option.textContent = lang.text;
135
- languageSelect.appendChild(option);
136
- });
137
-
138
- formGroup.appendChild(nameLabel);
139
- formGroup.appendChild(nameInput);
140
- formGroup.appendChild(document.createElement('br'));
141
- formGroup.appendChild(userLabel);
142
- formGroup.appendChild(userInput);
143
- formGroup.appendChild(document.createElement('br'));
144
- formGroup.appendChild(passwdLabel);
145
- formGroup.appendChild(passwdInput);
146
- formGroup.appendChild(document.createElement('br'));
147
- formGroup.appendChild(languageLabel);
148
- formGroup.appendChild(languageSelect);
149
- formGroup.appendChild(document.createElement('br'));
150
-
151
- // Create the buttons section
152
- const buttonDiv = document.createElement('div');
153
- buttonDiv.className = 'text-center';
154
-
155
- const logInButton = document.createElement('button');
156
- logInButton.id = `logIn${i}`;
157
- logInButton.type = 'button';
158
- logInButton.className = 'btn btn-primary';
159
- logInButton.textContent = 'Connect to MELCloud';
160
-
161
- const configButton = document.createElement('button');
162
- configButton.id = `configButton${i}`;
163
- configButton.type = 'button';
164
- configButton.className = 'btn btn-primary';
165
- configButton.innerHTML = '<i class="fas fa-gear"></i>';
166
-
167
- buttonDiv.appendChild(logInButton);
168
- buttonDiv.appendChild(configButton);
169
-
170
- // Append sections to the form
171
- form.appendChild(headerDiv);
172
- form.appendChild(formGroup);
173
- form.appendChild(buttonDiv);
174
-
175
- // Append the form to the melCloudAccount div
176
- melCloudAccount.appendChild(form);
177
-
178
- // Append the melCloudAccount div to the main container
179
- melCloudTabs.appendChild(melCloudAccount);
180
- }
72
+ //create buttons
73
+ const button = document.createElement("button");
74
+ button.setAttribute("type", "button");
75
+ button.setAttribute("id", `button${i}`);
76
+ button.setAttribute("class", "btn btn-primary");
77
+ button.innerText = pluginConfig[0].accounts[i].name;
78
+ document.getElementById("accounts").appendChild(button);
181
79
 
182
80
  //get actuall value on account select
183
81
  document.getElementById(`button${i}`).addEventListener('click', async () => {
@@ -249,23 +147,15 @@
249
147
  const info = response.info ?? '';
250
148
  const status = response.status;
251
149
  const devices = response.data ?? [];
252
- const newDevices = {
253
- ata: [],
254
- atw: [],
255
- erv: []
256
- };
257
- let textAta = 'ATA: 0';
258
- let textAtw = 'ATW: 0';
259
- let textErv = 'ERV: 0';
150
+ const newDevices = [];
260
151
 
261
152
  switch (status) {
262
153
  case 0:
263
154
  //get device info fom devices
264
- devices.forEach((device, index) => {
265
- const deviceType = device.Type;
266
- const deviceId = device.DeviceID;
267
- const deviceName = device.DeviceName;
268
- const deviceTypeText = ["Air Conditioner", "Heat Pump", "Unknown", "Energy Recovery Ventilation"][device.Type];
155
+ devices.forEach((deviceInfo, index) => {
156
+ const deviceType = deviceInfo.Type;
157
+ const deviceId = deviceInfo.DeviceID;
158
+ const deviceName = deviceInfo.DeviceName;
269
159
 
270
160
  //config account keys
271
161
  const accountKeys = Object.keys(pluginConfig[0].accounts[this.deviceIndex]);
@@ -275,7 +165,7 @@
275
165
  const deviceAta = {
276
166
  name: deviceName,
277
167
  id: deviceId,
278
- type: deviceTypeText,
168
+ type: deviceType,
279
169
  displayMode: 0,
280
170
  heatDryFanMode: 0,
281
171
  coolDryFanMode: 0,
@@ -290,9 +180,7 @@
290
180
  const ataDevices = ataDevicesExist ? pluginConfig[0].accounts[this.deviceIndex].ataDevices : pluginConfig[0].accounts[this.deviceIndex].ataDevices = [];
291
181
  const ataDeviceIdExist = ataDevices.some(device => device.id === deviceId);
292
182
  const pushTypeAta = ataDeviceIdExist ? false : ataDevices.push(deviceAta);
293
- const pushNewDevice = ataDeviceIdExist ? false : newDevices.ata.push(device);
294
- const devicesCount = newDevices.ata.length;
295
- textAta = `ATA: ${devicesCount}`
183
+ const pushNewDevice = ataDeviceIdExist ? false : newDevices.push(deviceId);
296
184
  };
297
185
 
298
186
  //devices atw
@@ -300,7 +188,7 @@
300
188
  const deviceAtw = {
301
189
  name: deviceName,
302
190
  id: deviceId,
303
- type: deviceTypeText,
191
+ type: deviceType,
304
192
  displayMode: 0,
305
193
  temperatureSensor: false,
306
194
  temperatureSensorFlow: false,
@@ -320,9 +208,7 @@
320
208
  const atwDevices = atwDevicesExist ? pluginConfig[0].accounts[this.deviceIndex].atwDevices : pluginConfig[0].accounts[this.deviceIndex].atwDevices = [];
321
209
  const atwDeviceIdExist = atwDevices.some(device => device.id === deviceId);
322
210
  const pushTypeatw = atwDeviceIdExist ? false : atwDevices.push(deviceAtw);
323
- const pushNewDevice = atwDeviceIdExist ? false : newDevices.atw.push(device);
324
- const devicesCount = newDevices.ata.length;
325
- textAtw = `ATW: ${devicesCount}`
211
+ const pushNewDevice = atwDeviceIdExist ? false : newDevices.push(deviceId);
326
212
  };
327
213
 
328
214
  //devices erv
@@ -330,7 +216,7 @@
330
216
  const deviceErv = {
331
217
  name: deviceName,
332
218
  id: deviceId,
333
- type: deviceTypeText,
219
+ type: deviceType,
334
220
  displayMode: 0,
335
221
  temperatureSensor: false,
336
222
  temperatureSensorOutdoor: false,
@@ -344,14 +230,12 @@
344
230
  const ervDevices = ervDevicesExist ? pluginConfig[0].accounts[this.deviceIndex].ervDevices : pluginConfig[0].accounts[this.deviceIndex].ervDevices = [];
345
231
  const ervDeviceIdExist = ervDevices.some(device => device.id === deviceId);
346
232
  const pushTypeerv = ervDeviceIdExist ? false : ervDevices.push(deviceErv);
347
- const pushNewDevice = ervDeviceIdExist ? false : newDevices.erv.push(device);
348
- const devicesCount = newDevices.ata.length;
349
- textErv = `ERV: ${devicesCount}`
233
+ const pushNewDevice = ervDeviceIdExist ? false : newDevices.push(deviceId);
350
234
  };
351
235
  });
352
236
 
353
- const newDevicesCount = newDevices.ata.length + newDevices.atw.length + newDevices.erv.length;
354
- document.getElementById('info').innerHTML = `Found in MELCloud, ${textAta}, ${textAtw}, ${textErv}. ${newDevicesCount === 0 ? '' : 'Now You can start to configure it.'}`;
237
+ const devicesCount = newDevices.length;
238
+ document.getElementById('info').innerHTML = `Check devices complete, found ${devicesCount} ${devicesCount !== 1 ? 'new devices' : 'new device'}. ${devicesCount === 0 ? '' : 'Now You can start to configure it.'}`;
355
239
  document.getElementById('info').style.color = 'green';
356
240
 
357
241
  await homebridge.updatePluginConfig(pluginConfig);
@@ -38,8 +38,7 @@ class PluginUiServer extends HomebridgePluginUiServer {
38
38
  } catch (error) {
39
39
  return data = {
40
40
  info: error,
41
- status: 1,
42
- data: data
41
+ status: 1
43
42
  };
44
43
  };
45
44
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "3.0.7-beta.19",
4
+ "version": "3.0.7-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",