homebridge-melcloud-control 4.1.2-beta.9 → 4.1.2
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/CHANGELOG.md +10 -0
- package/README.md +16 -3
- package/config.schema.json +445 -115
- package/homebridge-ui/public/index.html +90 -46
- package/package.json +2 -2
- package/src/constants.js +4 -0
- package/src/deviceata.js +68 -12
- package/src/deviceatw.js +64 -3
- package/src/deviceerv.js +68 -7
- package/src/functions.js +41 -57
- package/src/melcloud.js +64 -47
- package/src/melcloudata.js +17 -8
- package/src/melcloudatw.js +14 -8
- package/src/melclouderv.js +14 -8
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 = {
|
|
@@ -55,13 +54,11 @@ class MelCloudErv extends EventEmitter {
|
|
|
55
54
|
try {
|
|
56
55
|
//read device info from file
|
|
57
56
|
const devicesData = await this.functions.readData(this.devicesFile, true);
|
|
58
|
-
|
|
59
57
|
if (!Array.isArray(devicesData)) {
|
|
60
58
|
if (this.logWarn) this.emit('warn', `Device data not found`);
|
|
61
59
|
return null;
|
|
62
60
|
}
|
|
63
61
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
64
|
-
this.headers = deviceData.Headers;
|
|
65
62
|
|
|
66
63
|
if (this.accountType === 'melcloudhome') {
|
|
67
64
|
deviceData.SerialNumber = deviceData.DeviceID || '4.0.0';
|
|
@@ -72,7 +69,11 @@ class MelCloudErv extends EventEmitter {
|
|
|
72
69
|
deviceData.Device.DefaultHeatingSetTemperature = temps?.defaultHeatingSetTemperature ?? 20;
|
|
73
70
|
deviceData.Device.DefaultCoolingSetTemperature = temps?.defaultCoolingSetTemperature ?? 24;
|
|
74
71
|
}
|
|
75
|
-
|
|
72
|
+
const safeConfig = {
|
|
73
|
+
...deviceData,
|
|
74
|
+
headers: 'removed',
|
|
75
|
+
};
|
|
76
|
+
if (this.logDebug) this.emit('debug', `Device Data: ${JSON.stringify(safeConfig, null, 2)}`);
|
|
76
77
|
|
|
77
78
|
//presets
|
|
78
79
|
const serialNumber = deviceData.SerialNumber;
|
|
@@ -141,7 +142,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
141
142
|
method: 'POST',
|
|
142
143
|
baseURL: ApiUrls.BaseURL,
|
|
143
144
|
timeout: 10000,
|
|
144
|
-
headers:
|
|
145
|
+
headers: deviceData.Headers,
|
|
145
146
|
withCredentials: true
|
|
146
147
|
});
|
|
147
148
|
|
|
@@ -194,7 +195,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
194
195
|
method: 'PUT',
|
|
195
196
|
baseURL: ApiUrlsHome.BaseURL,
|
|
196
197
|
timeout: 10000,
|
|
197
|
-
headers:
|
|
198
|
+
headers: deviceData.Headers,
|
|
198
199
|
withCredentials: true
|
|
199
200
|
});
|
|
200
201
|
|
|
@@ -210,7 +211,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
210
211
|
}
|
|
211
212
|
}
|
|
212
213
|
|
|
213
|
-
const settings = {
|
|
214
|
+
const settings = effectiveFlags === 'scheduleset' ? { data: { enabled: deviceData.ScheduleEnabled } } : {
|
|
214
215
|
data: {
|
|
215
216
|
Power: deviceData.Device.Power,
|
|
216
217
|
SetTemperature: deviceData.Device.SetTemperature,
|
|
@@ -221,7 +222,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
221
222
|
};
|
|
222
223
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(settings.data, null, 2)}`);
|
|
223
224
|
|
|
224
|
-
const path = ApiUrlsHome.SetErv.replace('deviceid', deviceData.DeviceID);
|
|
225
|
+
const path = effectiveFlags === 'scheduleset' ? ApiUrlsHome.SetSchedule.replace('deviceid', deviceData.DeviceID) : ApiUrlsHome.SetErv.replace('deviceid', deviceData.DeviceID);
|
|
225
226
|
await axiosInstancePut(path, settings);
|
|
226
227
|
this.updateData(deviceData);
|
|
227
228
|
return true;
|
|
@@ -229,6 +230,11 @@ class MelCloudErv extends EventEmitter {
|
|
|
229
230
|
return;
|
|
230
231
|
}
|
|
231
232
|
} catch (error) {
|
|
233
|
+
// Return 500 for schedule hovewer working correct
|
|
234
|
+
if (error?.response?.status === 500) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
|
|
232
238
|
throw new Error(`Send data error: ${error.message}`);
|
|
233
239
|
}
|
|
234
240
|
}
|