homebridge-melcloud-control 4.1.2-beta.65 → 4.1.2-beta.67
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 -13
- package/package.json +1 -1
- package/src/melcloudatw.js +2 -4
- package/src/melclouderv.js +2 -4
|
@@ -272,21 +272,11 @@
|
|
|
272
272
|
const typeKey = isMelcloud ? 'Presets' : 'Schedule';
|
|
273
273
|
const typeKey1 = isMelcloud ? 'presets' : 'schedules';
|
|
274
274
|
|
|
275
|
+
let addedNewDevice = false;
|
|
275
276
|
devicesInMelCloud.forEach(device => {
|
|
276
277
|
const deviceId = String(device.DeviceID);
|
|
277
278
|
let deviceInConfig = configDevicesMap.get(deviceId);
|
|
278
279
|
|
|
279
|
-
// === Remove placeholder devices with id '0' before adding new ===
|
|
280
|
-
const beforeDevicesCount = devicesInConfig.length;
|
|
281
|
-
devicesInConfig = devicesInConfig.filter(d => String(d.id) !== '0');
|
|
282
|
-
if (devicesInConfig.length !== beforeDevicesCount) {
|
|
283
|
-
updateInfo('info2', `Removed placeholder devices with id '0'`, 'yellow');
|
|
284
|
-
|
|
285
|
-
// Rebuild map after filtering
|
|
286
|
-
configDevicesMap.clear();
|
|
287
|
-
devicesInConfig.forEach(dev => configDevicesMap.set(String(dev.id), dev));
|
|
288
|
-
}
|
|
289
|
-
|
|
290
280
|
// === Create device if missing ===
|
|
291
281
|
if (!deviceInConfig) {
|
|
292
282
|
deviceInConfig = {
|
|
@@ -302,6 +292,18 @@
|
|
|
302
292
|
devicesInConfig.push(deviceInConfig);
|
|
303
293
|
newArr.push(deviceInConfig);
|
|
304
294
|
configDevicesMap.set(deviceId, deviceInConfig);
|
|
295
|
+
addedNewDevice = true;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// === Remove placeholder devices (id === '0') if new ones were added ===
|
|
299
|
+
if (addedNewDevice) {
|
|
300
|
+
const beforeCount = devicesInConfig.length;
|
|
301
|
+
deviceInConfig = devicesInConfig.filter(d => String(d.id) !== '0');
|
|
302
|
+
const removedCount = beforeCount - deviceInConfig.length;
|
|
303
|
+
|
|
304
|
+
if (removedCount > 0 && removedCount < beforeCount) {
|
|
305
|
+
updateInfo('info1', `Removed ${removedCount} placeholder from device ${device.DeviceID}`, 'yellow');
|
|
306
|
+
}
|
|
305
307
|
}
|
|
306
308
|
|
|
307
309
|
// === Process presets/schedules ===
|
|
@@ -367,12 +369,11 @@
|
|
|
367
369
|
|
|
368
370
|
await homebridge.updatePluginConfig(pluginConfig);
|
|
369
371
|
await homebridge.savePluginConfig(pluginConfig);
|
|
370
|
-
document.getElementById('logIn').className = "btn btn-secondary";
|
|
371
|
-
|
|
372
372
|
} catch (error) {
|
|
373
373
|
updateInfo('info', `Connect error ${JSON.stringify(error)}`, 'red');
|
|
374
374
|
document.getElementById('logIn').className = "btn btn-secondary";
|
|
375
375
|
} finally {
|
|
376
|
+
document.getElementById('logIn').className = "btn btn-secondary";
|
|
376
377
|
homebridge.hideSpinner();
|
|
377
378
|
}
|
|
378
379
|
});
|
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.67",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/melcloudatw.js
CHANGED
|
@@ -23,7 +23,6 @@ class MelCloudAtw extends EventEmitter {
|
|
|
23
23
|
|
|
24
24
|
//set default values
|
|
25
25
|
this.devicesData = {};
|
|
26
|
-
this.headers = {};
|
|
27
26
|
|
|
28
27
|
//lock flags
|
|
29
28
|
this.locks = {
|
|
@@ -60,7 +59,6 @@ class MelCloudAtw extends EventEmitter {
|
|
|
60
59
|
return null;
|
|
61
60
|
}
|
|
62
61
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
63
|
-
this.headers = deviceData.Headers;
|
|
64
62
|
|
|
65
63
|
if (this.accountType === 'melcloudhome') {
|
|
66
64
|
deviceData.SerialNumber = deviceData.DeviceID || '4.0.0';
|
|
@@ -155,7 +153,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
155
153
|
method: 'POST',
|
|
156
154
|
baseURL: ApiUrls.BaseURL,
|
|
157
155
|
timeout: 10000,
|
|
158
|
-
headers:
|
|
156
|
+
headers: deviceData.Headers,
|
|
159
157
|
withCredentials: true
|
|
160
158
|
});
|
|
161
159
|
|
|
@@ -193,7 +191,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
193
191
|
method: 'PUT',
|
|
194
192
|
baseURL: ApiUrlsHome.BaseURL,
|
|
195
193
|
timeout: 10000,
|
|
196
|
-
headers:
|
|
194
|
+
headers: deviceData.Headers,
|
|
197
195
|
withCredentials: true
|
|
198
196
|
});
|
|
199
197
|
|
package/src/melclouderv.js
CHANGED
|
@@ -23,7 +23,6 @@ class MelCloudErv extends EventEmitter {
|
|
|
23
23
|
|
|
24
24
|
//set default values
|
|
25
25
|
this.devicesData = {};
|
|
26
|
-
this.headers = {};
|
|
27
26
|
|
|
28
27
|
//lock flags
|
|
29
28
|
this.locks = {
|
|
@@ -60,7 +59,6 @@ class MelCloudErv extends EventEmitter {
|
|
|
60
59
|
return null;
|
|
61
60
|
}
|
|
62
61
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
63
|
-
this.headers = deviceData.Headers;
|
|
64
62
|
|
|
65
63
|
if (this.accountType === 'melcloudhome') {
|
|
66
64
|
deviceData.SerialNumber = deviceData.DeviceID || '4.0.0';
|
|
@@ -144,7 +142,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
144
142
|
method: 'POST',
|
|
145
143
|
baseURL: ApiUrls.BaseURL,
|
|
146
144
|
timeout: 10000,
|
|
147
|
-
headers:
|
|
145
|
+
headers: deviceData.Headers,
|
|
148
146
|
withCredentials: true
|
|
149
147
|
});
|
|
150
148
|
|
|
@@ -197,7 +195,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
197
195
|
method: 'PUT',
|
|
198
196
|
baseURL: ApiUrlsHome.BaseURL,
|
|
199
197
|
timeout: 10000,
|
|
200
|
-
headers:
|
|
198
|
+
headers: deviceData.Headers,
|
|
201
199
|
withCredentials: true
|
|
202
200
|
});
|
|
203
201
|
|