homebridge-melcloud-control 4.2.5-beta.21 → 4.2.5-beta.23
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/package.json +1 -1
- package/src/melcloudata.js +25 -18
- package/src/melcloudatw.js +17 -8
- package/src/melclouderv.js +17 -8
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.2.5-beta.
|
|
4
|
+
"version": "4.2.5-beta.23",
|
|
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/melcloudata.js
CHANGED
|
@@ -23,10 +23,10 @@ class MelCloudAta extends EventEmitter {
|
|
|
23
23
|
|
|
24
24
|
//set default values
|
|
25
25
|
this.deviceData = {};
|
|
26
|
-
this.
|
|
26
|
+
this.headers = {};
|
|
27
27
|
|
|
28
28
|
//lock flag
|
|
29
|
-
this.locks =
|
|
29
|
+
this.locks = false;
|
|
30
30
|
this.impulseGenerator = new ImpulseGenerator()
|
|
31
31
|
.on('checkState', () => this.handleWithLock(async () => {
|
|
32
32
|
await this.checkState();
|
|
@@ -53,12 +53,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
53
53
|
try {
|
|
54
54
|
//read device info from file
|
|
55
55
|
const devicesData = await this.functions.readData(this.devicesFile, true);
|
|
56
|
-
|
|
57
|
-
this.axiosInstance = axios.create({
|
|
58
|
-
baseURL: this.baseURL,
|
|
59
|
-
timeout: 30000,
|
|
60
|
-
headers: devicesData.Headers
|
|
61
|
-
});
|
|
56
|
+
this.headers = devicesData.Headers;
|
|
62
57
|
|
|
63
58
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
64
59
|
if (this.accountType === 'melcloudhome') {
|
|
@@ -167,7 +162,13 @@ class MelCloudAta extends EventEmitter {
|
|
|
167
162
|
};
|
|
168
163
|
|
|
169
164
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
170
|
-
await
|
|
165
|
+
await axios(ApiUrls.SetAta, {
|
|
166
|
+
method: 'POST',
|
|
167
|
+
baseURL: ApiUrls.BaseURL,
|
|
168
|
+
timeout: 30000,
|
|
169
|
+
headers: this.headers,
|
|
170
|
+
data: payload
|
|
171
|
+
});
|
|
171
172
|
this.updateData(deviceData);
|
|
172
173
|
return true;
|
|
173
174
|
case "melcloudhome":
|
|
@@ -193,7 +194,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
193
194
|
};
|
|
194
195
|
method = 'POST';
|
|
195
196
|
path = ApiUrlsHome.PostProtectionFrost;
|
|
196
|
-
|
|
197
|
+
this.headers.Referer = ApiUrlsHome.Referers.PostProtectionFrost.replace('deviceid', deviceData.DeviceID);
|
|
197
198
|
break;
|
|
198
199
|
case 'overheatprotection':
|
|
199
200
|
payload = {
|
|
@@ -204,7 +205,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
204
205
|
};
|
|
205
206
|
method = 'POST';
|
|
206
207
|
path = ApiUrlsHome.PostProtectionOverheat;
|
|
207
|
-
|
|
208
|
+
this.headers.Referer = ApiUrlsHome.Referers.PostProtectionOverheat.replace('deviceid', deviceData.DeviceID);
|
|
208
209
|
break;
|
|
209
210
|
case 'holidaymode':
|
|
210
211
|
payload = {
|
|
@@ -215,19 +216,19 @@ class MelCloudAta extends EventEmitter {
|
|
|
215
216
|
};
|
|
216
217
|
method = 'POST';
|
|
217
218
|
path = ApiUrlsHome.PostHolidayMode;
|
|
218
|
-
|
|
219
|
+
this.headers.Referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
|
|
219
220
|
break;
|
|
220
221
|
case 'schedule':
|
|
221
222
|
payload = { enabled: deviceData.ScheduleEnabled };
|
|
222
223
|
method = 'PUT';
|
|
223
224
|
path = ApiUrlsHome.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
224
|
-
|
|
225
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
225
226
|
break;
|
|
226
227
|
case 'scene':
|
|
227
228
|
method = 'PUT';
|
|
228
229
|
const state = flagData.Enabled ? 'Enable' : 'Disable';
|
|
229
230
|
path = ApiUrlsHome.PutScene[state].replace('sceneid', flagData.Id);
|
|
230
|
-
|
|
231
|
+
this.headers.Referer = ApiUrlsHome.Referers.GetPutScenes;
|
|
231
232
|
break;
|
|
232
233
|
default:
|
|
233
234
|
payload = {
|
|
@@ -242,14 +243,20 @@ class MelCloudAta extends EventEmitter {
|
|
|
242
243
|
};
|
|
243
244
|
method = 'PUT';
|
|
244
245
|
path = ApiUrlsHome.PutAta.replace('deviceid', deviceData.DeviceID);
|
|
245
|
-
|
|
246
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutDeviceSettings;
|
|
246
247
|
break
|
|
247
248
|
}
|
|
248
249
|
|
|
249
|
-
|
|
250
|
-
|
|
250
|
+
this.headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
251
|
+
this.headers.Origin = ApiUrlsHome.Origin;
|
|
251
252
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(this.headers, null, 2)}`);
|
|
252
|
-
await
|
|
253
|
+
await axios(path, {
|
|
254
|
+
method: method,
|
|
255
|
+
baseURL: ApiUrlsHome.BaseURL,
|
|
256
|
+
timeout: 30000,
|
|
257
|
+
headers: this.headers,
|
|
258
|
+
data: payload
|
|
259
|
+
});
|
|
253
260
|
this.updateData(deviceData);
|
|
254
261
|
return true;
|
|
255
262
|
default:
|
package/src/melcloudatw.js
CHANGED
|
@@ -23,9 +23,10 @@ class MelCloudAtw extends EventEmitter {
|
|
|
23
23
|
|
|
24
24
|
//set default values
|
|
25
25
|
this.devicesData = {};
|
|
26
|
+
this.headers = {};
|
|
26
27
|
|
|
27
28
|
//lock flags
|
|
28
|
-
this.locks =
|
|
29
|
+
this.locks = false;
|
|
29
30
|
this.impulseGenerator = new ImpulseGenerator()
|
|
30
31
|
.on('checkState', () => this.handleWithLock(async () => {
|
|
31
32
|
await this.checkState();
|
|
@@ -52,11 +53,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
52
53
|
try {
|
|
53
54
|
//read device info from file
|
|
54
55
|
const devicesData = await this.functions.readData(this.devicesFile, true);
|
|
55
|
-
this.
|
|
56
|
-
baseURL: this.baseURL,
|
|
57
|
-
timeout: 30000,
|
|
58
|
-
headers: devicesData.Headers
|
|
59
|
-
});
|
|
56
|
+
this.headers = devicesData.Headers;
|
|
60
57
|
|
|
61
58
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
62
59
|
if (this.accountType === 'melcloudhome') {
|
|
@@ -171,7 +168,13 @@ class MelCloudAtw extends EventEmitter {
|
|
|
171
168
|
}
|
|
172
169
|
|
|
173
170
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
174
|
-
await
|
|
171
|
+
await axios(ApiUrls.SetAtw, {
|
|
172
|
+
method: 'POST',
|
|
173
|
+
baseURL: ApiUrls.BaseURL,
|
|
174
|
+
timeout: 30000,
|
|
175
|
+
headers: this.headers,
|
|
176
|
+
data: payload
|
|
177
|
+
});
|
|
175
178
|
this.updateData(deviceData);
|
|
176
179
|
return true;
|
|
177
180
|
case "melcloudhome":
|
|
@@ -224,7 +227,13 @@ class MelCloudAtw extends EventEmitter {
|
|
|
224
227
|
this.headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
225
228
|
this.headers.Origin = ApiUrlsHome.Origin;
|
|
226
229
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(this.headers, null, 2)}`);
|
|
227
|
-
await
|
|
230
|
+
await axios(path, {
|
|
231
|
+
method: method,
|
|
232
|
+
baseURL: ApiUrlsHome.BaseURL,
|
|
233
|
+
timeout: 30000,
|
|
234
|
+
headers: this.headers,
|
|
235
|
+
data: payload
|
|
236
|
+
});
|
|
228
237
|
this.updateData(deviceData);
|
|
229
238
|
return true;
|
|
230
239
|
default:
|
package/src/melclouderv.js
CHANGED
|
@@ -23,9 +23,10 @@ class MelCloudErv extends EventEmitter {
|
|
|
23
23
|
|
|
24
24
|
//set default values
|
|
25
25
|
this.devicesData = {};
|
|
26
|
+
this.headers = {};
|
|
26
27
|
|
|
27
28
|
//lock flags
|
|
28
|
-
this.locks =
|
|
29
|
+
this.locks = false;
|
|
29
30
|
this.impulseGenerator = new ImpulseGenerator()
|
|
30
31
|
.on('checkState', () => this.handleWithLock(async () => {
|
|
31
32
|
await this.checkState();
|
|
@@ -52,11 +53,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
52
53
|
try {
|
|
53
54
|
//read device info from file
|
|
54
55
|
const devicesData = await this.functions.readData(this.devicesFile, true);
|
|
55
|
-
this.
|
|
56
|
-
baseURL: this.baseURL,
|
|
57
|
-
timeout: 30000,
|
|
58
|
-
headers: devicesData.Headers
|
|
59
|
-
});
|
|
56
|
+
this.headers = devicesData.Headers;
|
|
60
57
|
|
|
61
58
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
62
59
|
if (this.accountType === 'melcloudhome') {
|
|
@@ -174,7 +171,13 @@ class MelCloudErv extends EventEmitter {
|
|
|
174
171
|
}
|
|
175
172
|
|
|
176
173
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
177
|
-
await
|
|
174
|
+
await axios(ApiUrls.SetErv, {
|
|
175
|
+
method: 'POST',
|
|
176
|
+
baseURL: ApiUrls.BaseURL,
|
|
177
|
+
timeout: 30000,
|
|
178
|
+
headers: this.headers,
|
|
179
|
+
data: payload
|
|
180
|
+
});
|
|
178
181
|
this.updateData(deviceData);
|
|
179
182
|
return true;
|
|
180
183
|
case "melcloudhome":
|
|
@@ -231,7 +234,13 @@ class MelCloudErv extends EventEmitter {
|
|
|
231
234
|
this.headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
232
235
|
this.headers.Origin = ApiUrlsHome.Origin;
|
|
233
236
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(this.headers, null, 2)}`);
|
|
234
|
-
await
|
|
237
|
+
await axios(path, {
|
|
238
|
+
method: method,
|
|
239
|
+
baseURL: ApiUrlsHome.BaseURL,
|
|
240
|
+
timeout: 30000,
|
|
241
|
+
headers: this.headers,
|
|
242
|
+
data: payload
|
|
243
|
+
});
|
|
235
244
|
this.updateData(deviceData);
|
|
236
245
|
return true;
|
|
237
246
|
default:
|