homebridge-melcloud-control 4.1.2-beta.70 → 4.1.2-beta.72
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 +14 -15
- package/package.json +1 -1
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
|
|
108
108
|
const accounts = pluginConfig[0].accounts || [];
|
|
109
109
|
const accountsCount = accounts.length;
|
|
110
|
+
this.accountIndex = 0;
|
|
110
111
|
|
|
111
112
|
const container = document.getElementById("accountButton");
|
|
112
113
|
container.style.display = 'flex';
|
|
@@ -130,8 +131,6 @@
|
|
|
130
131
|
|
|
131
132
|
// Tworzenie przycisków
|
|
132
133
|
accounts.forEach((account, i) => {
|
|
133
|
-
this.account = account;
|
|
134
|
-
|
|
135
134
|
const button = document.createElement("button");
|
|
136
135
|
button.type = "button";
|
|
137
136
|
button.id = `button${i}`;
|
|
@@ -141,7 +140,7 @@
|
|
|
141
140
|
container.appendChild(button);
|
|
142
141
|
|
|
143
142
|
button.addEventListener('click', async () => {
|
|
144
|
-
this.
|
|
143
|
+
this.accountIndex = i;
|
|
145
144
|
|
|
146
145
|
// Zmieniamy klasę wszystkich przycisków
|
|
147
146
|
accounts.forEach((_, j) => {
|
|
@@ -167,7 +166,7 @@
|
|
|
167
166
|
|
|
168
167
|
// Jeden listener input dla całego formularza
|
|
169
168
|
document.getElementById('configForm').addEventListener('input', async () => {
|
|
170
|
-
const account = this.
|
|
169
|
+
const account = pluginConfig[0].accounts[this.accountIndex];
|
|
171
170
|
if (!account) return;
|
|
172
171
|
|
|
173
172
|
account.name = formElements.name.value;
|
|
@@ -239,7 +238,7 @@
|
|
|
239
238
|
homebridge.showSpinner();
|
|
240
239
|
|
|
241
240
|
try {
|
|
242
|
-
const account = this.
|
|
241
|
+
const account = pluginConfig[0].accounts[this.accountIndex];
|
|
243
242
|
const response = await homebridge.request('/connect', account);
|
|
244
243
|
if (!response.State) {
|
|
245
244
|
homebridge.hideSpinner();
|
|
@@ -249,21 +248,21 @@
|
|
|
249
248
|
|
|
250
249
|
// Initialize devices arrays
|
|
251
250
|
const newDevices = { ata: [], ataPresets: [], atw: [], atwPresets: [], erv: [], ervPresets: [] };
|
|
252
|
-
const
|
|
251
|
+
const melcloud = { ata: [], atw: [], erv: [] };
|
|
253
252
|
|
|
254
253
|
response.Devices.forEach(d => {
|
|
255
|
-
if (d.Type === 0)
|
|
256
|
-
if (d.Type === 1)
|
|
257
|
-
if (d.Type === 3)
|
|
254
|
+
if (d.Type === 0) melcloud.ata.push(d);
|
|
255
|
+
if (d.Type === 1) melcloud.atw.push(d);
|
|
256
|
+
if (d.Type === 3) melcloud.erv.push(d);
|
|
258
257
|
});
|
|
259
258
|
|
|
260
259
|
account.ataDevices = (account.ataDevices || []).filter(d => String(d.id) !== '0');
|
|
261
260
|
account.atwDevices = (account.atwDevices || []).filter(d => String(d.id) !== '0');
|
|
262
261
|
account.ervDevices = (account.ervDevices || []).filter(d => String(d.id) !== '0');
|
|
263
262
|
|
|
264
|
-
const removedAta = removeStaleDevices(account.ataDevices,
|
|
265
|
-
const removedAtw = removeStaleDevices(account.atwDevices,
|
|
266
|
-
const removedErv = removeStaleDevices(account.ervDevices,
|
|
263
|
+
const removedAta = removeStaleDevices(account.ataDevices, melcloud.ata);
|
|
264
|
+
const removedAtw = removeStaleDevices(account.atwDevices, melcloud.atw);
|
|
265
|
+
const removedErv = removeStaleDevices(account.ervDevices, melcloud.erv);
|
|
267
266
|
|
|
268
267
|
const handleDevices = (devicesInMelCloud, devicesInConfig, typeString, newArr, newPresets) => {
|
|
269
268
|
try {
|
|
@@ -323,9 +322,9 @@
|
|
|
323
322
|
}
|
|
324
323
|
};
|
|
325
324
|
|
|
326
|
-
account.ataDevices = handleDevices(
|
|
327
|
-
account.atwDevices = handleDevices(
|
|
328
|
-
account.ervDevices = handleDevices(
|
|
325
|
+
account.ataDevices = handleDevices(melcloud.ata, account.ataDevices, "Air Conditioner", newDevices.ata, newDevices.ataPresets);
|
|
326
|
+
account.atwDevices = handleDevices(melcloud.atw, account.atwDevices, "Heat Pump", newDevices.atw, newDevices.atwPresets);
|
|
327
|
+
account.ervDevices = handleDevices(melcloud.erv, account.ervDevices, "Energy Recovery Ventilation", newDevices.erv, newDevices.ervPresets);
|
|
329
328
|
|
|
330
329
|
const newDevicesCount = newDevices.ata.length + newDevices.atw.length + newDevices.erv.length;
|
|
331
330
|
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.72",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|