homebridge-melcloud-control 4.1.2-beta.74 → 4.1.2-beta.77

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.
@@ -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.accountIndex = i;
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 = pluginConfig[0].accounts[this.accountIndex];
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);
@@ -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 = pluginConfig[0].accounts[this.accountIndex];
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 {
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.74",
4
+ "version": "4.1.2-beta.77",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",