homebridge-melcloud-control 4.1.2-beta.73 → 4.1.2-beta.76
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 +25 -24
- package/package.json +1 -1
|
@@ -107,7 +107,6 @@
|
|
|
107
107
|
|
|
108
108
|
const accounts = pluginConfig[0].accounts || [];
|
|
109
109
|
const accountsCount = accounts.length;
|
|
110
|
-
this.accountIndex = 0;
|
|
111
110
|
|
|
112
111
|
const container = document.getElementById("accountButton");
|
|
113
112
|
container.style.display = 'flex';
|
|
@@ -131,6 +130,8 @@
|
|
|
131
130
|
|
|
132
131
|
// Tworzenie przycisków
|
|
133
132
|
accounts.forEach((account, i) => {
|
|
133
|
+
this.account = account;
|
|
134
|
+
|
|
134
135
|
const button = document.createElement("button");
|
|
135
136
|
button.type = "button";
|
|
136
137
|
button.id = `button${i}`;
|
|
@@ -140,7 +141,7 @@
|
|
|
140
141
|
container.appendChild(button);
|
|
141
142
|
|
|
142
143
|
button.addEventListener('click', async () => {
|
|
143
|
-
this.
|
|
144
|
+
this.account = account;
|
|
144
145
|
|
|
145
146
|
// Zmieniamy klasę wszystkich przycisków
|
|
146
147
|
accounts.forEach((_, j) => {
|
|
@@ -158,6 +159,8 @@
|
|
|
158
159
|
formElements.language.value = account.language || '0';
|
|
159
160
|
formElements.accountType.value = account.type || 'disabled';
|
|
160
161
|
formElements.logIn.disabled = !(account.name && account.user && account.passwd && account.language && account.type);
|
|
162
|
+
|
|
163
|
+
await homebridge.updatePluginConfig(pluginConfig);
|
|
161
164
|
});
|
|
162
165
|
});
|
|
163
166
|
|
|
@@ -166,7 +169,7 @@
|
|
|
166
169
|
|
|
167
170
|
// Jeden listener input dla całego formularza
|
|
168
171
|
document.getElementById('configForm').addEventListener('input', async () => {
|
|
169
|
-
const account =
|
|
172
|
+
const account = this.account;
|
|
170
173
|
if (!account) return;
|
|
171
174
|
|
|
172
175
|
account.name = formElements.name.value;
|
|
@@ -205,6 +208,15 @@
|
|
|
205
208
|
}
|
|
206
209
|
});
|
|
207
210
|
|
|
211
|
+
// Update info
|
|
212
|
+
function updateInfo(id, text, color) {
|
|
213
|
+
const el = document.getElementById(id);
|
|
214
|
+
if (el) {
|
|
215
|
+
el.innerText = text;
|
|
216
|
+
el.style.color = color;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
208
220
|
// Device Handling & Login Logic
|
|
209
221
|
function removeStaleDevices(configDevices, melcloudDevices) {
|
|
210
222
|
const melcloudIds = melcloudDevices.map(d => d.DeviceID);
|
|
@@ -212,7 +224,7 @@
|
|
|
212
224
|
|
|
213
225
|
for (let i = configDevices.length - 1; i >= 0; i--) {
|
|
214
226
|
const device = configDevices[i];
|
|
215
|
-
if (
|
|
227
|
+
if (!melcloudIds.includes(device.id)) {
|
|
216
228
|
removedDevices.push(device);
|
|
217
229
|
configDevices.splice(i, 1);
|
|
218
230
|
}
|
|
@@ -220,18 +232,7 @@
|
|
|
220
232
|
return removedDevices;
|
|
221
233
|
}
|
|
222
234
|
|
|
223
|
-
function updateInfo(id, text, color) {
|
|
224
|
-
const el = document.getElementById(id);
|
|
225
|
-
if (el) {
|
|
226
|
-
el.innerText = text;
|
|
227
|
-
el.style.color = color;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
235
|
document.getElementById('logIn').addEventListener('click', async () => {
|
|
232
|
-
await homebridge.updatePluginConfig(pluginConfig);
|
|
233
|
-
await homebridge.savePluginConfig(pluginConfig);
|
|
234
|
-
|
|
235
236
|
document.getElementById(`logIn`).className = "btn btn-primary";
|
|
236
237
|
updateInfo('info', '', 'white');
|
|
237
238
|
updateInfo('info1', '', 'white');
|
|
@@ -239,7 +240,7 @@
|
|
|
239
240
|
homebridge.showSpinner();
|
|
240
241
|
|
|
241
242
|
try {
|
|
242
|
-
const account =
|
|
243
|
+
const account = this.account;
|
|
243
244
|
const response = await homebridge.request('/connect', account);
|
|
244
245
|
if (!response.State) {
|
|
245
246
|
homebridge.hideSpinner();
|
|
@@ -264,6 +265,7 @@
|
|
|
264
265
|
const removedAta = removeStaleDevices(account.ataDevices, melcloudDevices.ata);
|
|
265
266
|
const removedAtw = removeStaleDevices(account.atwDevices, melcloudDevices.atw);
|
|
266
267
|
const removedErv = removeStaleDevices(account.ervDevices, melcloudDevices.erv);
|
|
268
|
+
await homebridge.updatePluginConfig(pluginConfig);
|
|
267
269
|
|
|
268
270
|
const handleDevices = (devicesInMelCloud, devicesInConfig, typeString, newArr, newPresets) => {
|
|
269
271
|
try {
|
|
@@ -275,8 +277,7 @@
|
|
|
275
277
|
const typeKey1 = isMelcloud ? 'presets' : 'schedules';
|
|
276
278
|
|
|
277
279
|
devicesInMelCloud.forEach(device => {
|
|
278
|
-
|
|
279
|
-
let deviceInConfig = configDevicesMap.get(deviceId);
|
|
280
|
+
let deviceInConfig = configDevicesMap.get(device.DeviceID);
|
|
280
281
|
|
|
281
282
|
// === Create device if missing ===
|
|
282
283
|
if (!deviceInConfig) {
|
|
@@ -292,15 +293,15 @@
|
|
|
292
293
|
};
|
|
293
294
|
devicesInConfig.push(deviceInConfig);
|
|
294
295
|
newArr.push(deviceInConfig);
|
|
295
|
-
configDevicesMap.set(
|
|
296
|
+
configDevicesMap.set(device.DeviceID, deviceInConfig);
|
|
296
297
|
}
|
|
297
298
|
|
|
298
299
|
// === Process presets/schedules ===
|
|
299
|
-
const
|
|
300
|
+
const presetsInMelcloud = device[typeKey] || [];
|
|
300
301
|
const presetsInConfig = (deviceInConfig[typeKey1] || []).filter(p => String(p.id) !== '0');
|
|
301
302
|
const presetIds = new Set(presetsInConfig.map(p => String(p.id)));
|
|
302
303
|
|
|
303
|
-
|
|
304
|
+
presetsInMelcloud.forEach((preset, index) => {
|
|
304
305
|
const presetId = String(preset[idKey]);
|
|
305
306
|
if (!presetIds.has(presetId)) {
|
|
306
307
|
const presetObj = {
|
|
@@ -323,9 +324,9 @@
|
|
|
323
324
|
}
|
|
324
325
|
};
|
|
325
326
|
|
|
326
|
-
|
|
327
|
-
account.atwDevices = handleDevices(melcloudDevices.atw, account.atwDevices, "Heat Pump", newDevices.atw, newDevices.atwPresets);
|
|
328
|
-
account.ervDevices = handleDevices(melcloudDevices.erv, account.ervDevices, "Energy Recovery Ventilation", newDevices.erv, newDevices.ervPresets);
|
|
327
|
+
pluginConfig[0].account.ataDevices = handleDevices(melcloudDevices.ata, account.ataDevices, "Air Conditioner", newDevices.ata, newDevices.ataPresets);
|
|
328
|
+
pluginConfig[0].account.atwDevices = handleDevices(melcloudDevices.atw, account.atwDevices, "Heat Pump", newDevices.atw, newDevices.atwPresets);
|
|
329
|
+
pluginConfig[0].account.ervDevices = handleDevices(melcloudDevices.erv, account.ervDevices, "Energy Recovery Ventilation", newDevices.erv, newDevices.ervPresets);
|
|
329
330
|
|
|
330
331
|
const newDevicesCount = newDevices.ata.length + newDevices.atw.length + newDevices.erv.length;
|
|
331
332
|
const newPresetsCount = newDevices.ataPresets.length + newDevices.atwPresets.length + newDevices.ervPresets.length;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.1.2-beta.
|
|
4
|
+
"version": "4.1.2-beta.76",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|