homebridge-melcloud-control 3.9.0-beta.11 → 3.9.0-beta.12
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/homebridge-ui/public/index.html +42 -59
- package/package.json +1 -1
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
<img src="homebridge-melcloud-control.png" alt="Image" height="100" />
|
|
16
16
|
</div>
|
|
17
17
|
|
|
18
|
+
<!-- Config button -->
|
|
19
|
+
<div class="text-center mt-3">
|
|
20
|
+
<button type="button" class="btn btn-primary" id="configButton" disabled>⚙️ Config</button>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
18
23
|
<!-- Tabs -->
|
|
19
24
|
<ul class="nav nav-tabs mt-3" id="accountTabs" role="tablist"></ul>
|
|
20
25
|
|
|
@@ -43,6 +48,17 @@
|
|
|
43
48
|
const tabs = document.getElementById("accountTabs");
|
|
44
49
|
const content = document.getElementById("accountTabsContent");
|
|
45
50
|
|
|
51
|
+
let configButtonState = false;
|
|
52
|
+
const configButton = document.getElementById('configButton');
|
|
53
|
+
|
|
54
|
+
function updateConfigButtonState(account) {
|
|
55
|
+
const hasMultipleDevices =
|
|
56
|
+
(account.ataDevices?.length || 0) > 1 ||
|
|
57
|
+
(account.atwDevices?.length || 0) > 1 ||
|
|
58
|
+
(account.ervDevices?.length || 0) > 1;
|
|
59
|
+
configButton.disabled = !hasMultipleDevices;
|
|
60
|
+
}
|
|
61
|
+
|
|
46
62
|
function createAccountForm(account, i) {
|
|
47
63
|
// Tab header
|
|
48
64
|
const li = document.createElement("li");
|
|
@@ -103,7 +119,6 @@
|
|
|
103
119
|
</div>
|
|
104
120
|
<button type="button" class="btn btn-secondary" id="logIn-${i}">Connect</button>
|
|
105
121
|
<button type="button" class="btn btn-danger ms-2" id="remove-${i}">❌ Remove Account</button>
|
|
106
|
-
<button type="button" class="btn btn-primary" id="configButton">⚙️ Config</button>
|
|
107
122
|
</form>`;
|
|
108
123
|
content.appendChild(pane);
|
|
109
124
|
|
|
@@ -124,45 +139,11 @@
|
|
|
124
139
|
accounts.splice(i, 1);
|
|
125
140
|
document.getElementById(`tab-li-${i}`).remove();
|
|
126
141
|
document.getElementById(`pane-${i}`).remove();
|
|
127
|
-
|
|
128
|
-
// Rebuild IDs
|
|
129
|
-
const panes = document.querySelectorAll(".tab-pane");
|
|
130
|
-
panes.forEach((p, index) => {
|
|
131
|
-
p.id = `pane-${index}`;
|
|
132
|
-
p.querySelector("form").id = `configForm-${index}`;
|
|
133
|
-
p.querySelector(`[id^="name-"]`).id = `name-${index}`;
|
|
134
|
-
p.querySelector(`[id^="user-"]`).id = `user-${index}`;
|
|
135
|
-
p.querySelector(`[id^="passwd-"]`).id = `passwd-${index}`;
|
|
136
|
-
p.querySelector(`[id^="language-"]`).id = `language-${index}`;
|
|
137
|
-
p.querySelector(`[id^="logIn-"]`).id = `logIn-${index}`;
|
|
138
|
-
p.querySelector(`[id^="remove-"]`).id = `remove-${index}`;
|
|
139
|
-
});
|
|
140
|
-
const tabButtons = document.querySelectorAll(".nav-link");
|
|
141
|
-
tabButtons.forEach((btn, idx) => {
|
|
142
|
-
btn.id = `tab-${idx}`;
|
|
143
|
-
btn.dataset.bsTarget = `#pane-${idx}`;
|
|
144
|
-
});
|
|
145
|
-
|
|
146
142
|
await homebridge.updatePluginConfig(pluginConfig);
|
|
147
143
|
await homebridge.savePluginConfig(pluginConfig);
|
|
148
|
-
|
|
149
144
|
if (accounts.length > 0) new bootstrap.Tab(document.getElementById("tab-0")).show();
|
|
150
145
|
});
|
|
151
146
|
|
|
152
|
-
document.getElementById('configButton').addEventListener('click', async () => {
|
|
153
|
-
if (this.configButtonState) {
|
|
154
|
-
homebridge.hideSchemaForm();
|
|
155
|
-
document.getElementById('configButton').className = "btn btn-secondary";
|
|
156
|
-
} else {
|
|
157
|
-
homebridge.showSchemaForm();
|
|
158
|
-
document.getElementById('configButton').className = "btn btn-primary";
|
|
159
|
-
}
|
|
160
|
-
this.configButtonState = !this.configButtonState;
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
// Initialize state
|
|
164
|
-
this.configButtonState = false;
|
|
165
|
-
|
|
166
147
|
// Login button
|
|
167
148
|
document.getElementById(`logIn-${i}`).addEventListener("click", async () => {
|
|
168
149
|
homebridge.showSpinner();
|
|
@@ -201,31 +182,23 @@
|
|
|
201
182
|
const atwDevices = account.atwDevices ?? (account.atwDevices = []);
|
|
202
183
|
const ervDevices = account.ervDevices ?? (account.ervDevices = []);
|
|
203
184
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
185
|
+
removeStaleDevices(ataDevices, devicesByType.ata);
|
|
186
|
+
removeStaleDevices(atwDevices, devicesByType.atw);
|
|
187
|
+
removeStaleDevices(ervDevices, devicesByType.erv);
|
|
207
188
|
|
|
208
189
|
// Add new devices & presets
|
|
209
190
|
function handleDevices(configArray, devicesArray, typeName, newDevicesArr, newPresetsArr) {
|
|
210
191
|
devicesArray.forEach(d => {
|
|
211
|
-
|
|
192
|
+
let existing = configArray.find(x => x.id === d.DeviceID);
|
|
212
193
|
if (!existing) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
typeString: typeName,
|
|
217
|
-
name: d.DeviceName,
|
|
218
|
-
displayMode: 1,
|
|
219
|
-
presets: [],
|
|
220
|
-
buttonsSensors: []
|
|
221
|
-
};
|
|
222
|
-
configArray.push(devObj);
|
|
223
|
-
newDevicesArr.push(devObj);
|
|
194
|
+
existing = { id: d.DeviceID, type: d.Type, typeString: typeName, name: d.DeviceName, displayMode: 1, presets: [], buttonsSensors: [] };
|
|
195
|
+
configArray.push(existing);
|
|
196
|
+
newDevicesArr.push(existing);
|
|
224
197
|
}
|
|
225
198
|
(d.Presets || []).forEach(p => {
|
|
226
199
|
const preset = { ...p, id: p.ID, name: p.NumberDescription, displayType: 0, namePrefix: false };
|
|
227
|
-
if (!existing
|
|
228
|
-
existing
|
|
200
|
+
if (!existing.presets.some(pr => pr.id === p.ID)) {
|
|
201
|
+
existing.presets.push(preset);
|
|
229
202
|
newPresetsArr.push(preset);
|
|
230
203
|
}
|
|
231
204
|
});
|
|
@@ -236,19 +209,17 @@
|
|
|
236
209
|
handleDevices(atwDevices, devicesByType.atw, "Heat Pump", newDevices.atw, newDevices.atwPresets);
|
|
237
210
|
handleDevices(ervDevices, devicesByType.erv, "ERV", newDevices.erv, newDevices.ervPresets);
|
|
238
211
|
|
|
239
|
-
//
|
|
212
|
+
// Update info
|
|
240
213
|
function updateInfo(id, text, color) {
|
|
241
214
|
const el = document.getElementById(id);
|
|
242
215
|
if (el) { el.innerHTML = text; el.style.color = color; }
|
|
243
216
|
}
|
|
244
217
|
|
|
245
218
|
const textInfo = `Found devices: ATA(${newDevices.ata.length}), ATW(${newDevices.atw.length}), ERV(${newDevices.erv.length})`;
|
|
246
|
-
|
|
247
|
-
const textRemoved = `Removed devices: ATA(${removedAta.length}), ATW(${removedAtw.length}), ERV(${removedErv.length})`;
|
|
219
|
+
updateInfo('info', textInfo, 'green');
|
|
248
220
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
updateInfo('info2', textRemoved, removedAta.length + removedAtw.length + removedErv.length > 0 ? 'orange' : 'white');
|
|
221
|
+
// Update Config button state
|
|
222
|
+
updateConfigButtonState(account);
|
|
252
223
|
|
|
253
224
|
await homebridge.updatePluginConfig(pluginConfig);
|
|
254
225
|
await homebridge.savePluginConfig(pluginConfig);
|
|
@@ -270,7 +241,7 @@
|
|
|
270
241
|
tabs.appendChild(addLi);
|
|
271
242
|
|
|
272
243
|
document.getElementById("addTab").addEventListener("click", async () => {
|
|
273
|
-
const newAccount = { name: "", user: "", passwd: "", language: 0 };
|
|
244
|
+
const newAccount = { name: "", user: "", passwd: "", language: 0, ataDevices: [{}], atwDevices: [{}], ervDevices: [{}] };
|
|
274
245
|
accounts.push(newAccount);
|
|
275
246
|
const i = accounts.length - 1;
|
|
276
247
|
createAccountForm(newAccount, i);
|
|
@@ -279,6 +250,18 @@
|
|
|
279
250
|
new bootstrap.Tab(document.getElementById(`tab-${i}`)).show();
|
|
280
251
|
});
|
|
281
252
|
|
|
253
|
+
// Config button toggle
|
|
254
|
+
configButton.addEventListener('click', () => {
|
|
255
|
+
if (configButtonState) {
|
|
256
|
+
homebridge.hideSchemaForm();
|
|
257
|
+
configButton.className = "btn btn-secondary";
|
|
258
|
+
} else {
|
|
259
|
+
homebridge.showSchemaForm();
|
|
260
|
+
configButton.className = "btn btn-primary";
|
|
261
|
+
}
|
|
262
|
+
configButtonState = !configButtonState;
|
|
263
|
+
});
|
|
264
|
+
|
|
282
265
|
})();
|
|
283
266
|
</script>
|
|
284
267
|
</body>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "3.9.0-beta.
|
|
4
|
+
"version": "3.9.0-beta.12",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|