homebridge-melcloud-control 4.0.0-beta.554 → 4.0.0-beta.555
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/melcloud.js +23 -20
- package/src/melcloudata.js +1 -13
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.555",
|
|
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/melcloud.js
CHANGED
|
@@ -64,11 +64,15 @@ class MelCloud extends EventEmitter {
|
|
|
64
64
|
async checkMelcloudDevicesList() {
|
|
65
65
|
try {
|
|
66
66
|
const devicesList = { State: false, Info: null, Devices: [] }
|
|
67
|
+
const headers = {
|
|
68
|
+
'X-MitsContextKey': this.contextKey,
|
|
69
|
+
'Content-Type': 'application/json'
|
|
70
|
+
}
|
|
67
71
|
const axiosInstance = axios.create({
|
|
68
72
|
method: 'GET',
|
|
69
73
|
baseURL: ApiUrls.BaseURL,
|
|
70
74
|
timeout: 15000,
|
|
71
|
-
headers:
|
|
75
|
+
headers: headers
|
|
72
76
|
});
|
|
73
77
|
|
|
74
78
|
if (this.logDebug) this.emit('debug', `Scanning for devices...`);
|
|
@@ -112,7 +116,8 @@ class MelCloud extends EventEmitter {
|
|
|
112
116
|
|
|
113
117
|
// Zamiana ID na string
|
|
114
118
|
allDevices.forEach(device => {
|
|
115
|
-
|
|
119
|
+
device.DeviceID = String(device.DeviceID);
|
|
120
|
+
device.Headers = headers;
|
|
116
121
|
});
|
|
117
122
|
|
|
118
123
|
if (this.logDebug) this.emit('debug', `Found ${allDevices.length} devices in building: ${building.Name || 'Unnamed'}`);
|
|
@@ -121,7 +126,6 @@ class MelCloud extends EventEmitter {
|
|
|
121
126
|
|
|
122
127
|
const devicesCount = devicesList.Devices.length;
|
|
123
128
|
if (devicesCount === 0) {
|
|
124
|
-
devicesList.State = false;
|
|
125
129
|
devicesList.Info = 'No devices found'
|
|
126
130
|
return devicesList;
|
|
127
131
|
}
|
|
@@ -176,7 +180,6 @@ class MelCloud extends EventEmitter {
|
|
|
176
180
|
if (this.logDebug) this.emit('debug', `MELCloud Info: ${JSON.stringify(debugData, null, 2)}`);
|
|
177
181
|
|
|
178
182
|
if (!contextKey) {
|
|
179
|
-
accountInfo.State = false;
|
|
180
183
|
accountInfo.Info = 'Context key missing'
|
|
181
184
|
return accountInfo;
|
|
182
185
|
}
|
|
@@ -198,23 +201,24 @@ class MelCloud extends EventEmitter {
|
|
|
198
201
|
async checkMelcloudHomeDevicesList() {
|
|
199
202
|
try {
|
|
200
203
|
const devicesList = { State: false, Info: null, Devices: [] }
|
|
204
|
+
const headers = {
|
|
205
|
+
'Accept': '*/*',
|
|
206
|
+
'Accept-Language': 'en-US,en;q=0.9',
|
|
207
|
+
'Cookie': this.contextKey,
|
|
208
|
+
'User-Agent': 'homebridge-melcloud-control/4.0.0',
|
|
209
|
+
'DNT': '1',
|
|
210
|
+
'Origin': 'https://melcloudhome.com',
|
|
211
|
+
'Referer': 'https://melcloudhome.com/dashboard',
|
|
212
|
+
'Sec-Fetch-Dest': 'empty',
|
|
213
|
+
'Sec-Fetch-Mode': 'cors',
|
|
214
|
+
'Sec-Fetch-Site': 'same-origin',
|
|
215
|
+
'X-CSRF': '1'
|
|
216
|
+
};
|
|
201
217
|
const axiosInstance = axios.create({
|
|
202
218
|
method: 'GET',
|
|
203
219
|
baseURL: ApiUrlsHome.BaseURL,
|
|
204
220
|
timeout: 25000,
|
|
205
|
-
headers:
|
|
206
|
-
'Accept': '*/*',
|
|
207
|
-
'Accept-Language': 'en-US,en;q=0.9',
|
|
208
|
-
'Cookie': this.contextKey,
|
|
209
|
-
'User-Agent': 'homebridge-melcloud-control/4.0.0',
|
|
210
|
-
'DNT': '1',
|
|
211
|
-
'Origin': 'https://melcloudhome.com',
|
|
212
|
-
'Referer': 'https://melcloudhome.com/dashboard',
|
|
213
|
-
'Sec-Fetch-Dest': 'empty',
|
|
214
|
-
'Sec-Fetch-Mode': 'cors',
|
|
215
|
-
'Sec-Fetch-Site': 'same-origin',
|
|
216
|
-
'X-CSRF': '1'
|
|
217
|
-
}
|
|
221
|
+
headers: headers
|
|
218
222
|
});
|
|
219
223
|
|
|
220
224
|
if (this.logDebug) this.emit('debug', `Scanning for devices`);
|
|
@@ -270,11 +274,11 @@ class MelCloud extends EventEmitter {
|
|
|
270
274
|
|
|
271
275
|
return {
|
|
272
276
|
...rest,
|
|
273
|
-
ContextKey: this.contextKey,
|
|
274
277
|
Type: type,
|
|
275
278
|
DeviceID: Id,
|
|
276
279
|
DeviceName: GivenDisplayName,
|
|
277
|
-
Device: deviceObject
|
|
280
|
+
Device: deviceObject,
|
|
281
|
+
Headers: headers
|
|
278
282
|
};
|
|
279
283
|
};
|
|
280
284
|
|
|
@@ -287,7 +291,6 @@ class MelCloud extends EventEmitter {
|
|
|
287
291
|
|
|
288
292
|
const devicesCount = devices.length;
|
|
289
293
|
if (devicesCount === 0) {
|
|
290
|
-
devicesList.State = false;
|
|
291
294
|
devicesList.Info = 'No devices found'
|
|
292
295
|
return devicesList;
|
|
293
296
|
}
|
package/src/melcloudata.js
CHANGED
|
@@ -228,19 +228,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
228
228
|
method: 'PUT',
|
|
229
229
|
baseURL: ApiUrlsHome.BaseURL,
|
|
230
230
|
timeout: 25000,
|
|
231
|
-
headers:
|
|
232
|
-
'Accept': '*/*',
|
|
233
|
-
'Accept-Language': 'en-US,en;q=0.9',
|
|
234
|
-
'Cookie': deviceData.ContextKey,
|
|
235
|
-
'User-Agent': 'homebridge-melcloud-control/4.0.0',
|
|
236
|
-
'DNT': '1',
|
|
237
|
-
'Origin': 'https://melcloudhome.com',
|
|
238
|
-
'Referer': 'https://melcloudhome.com/dashboard',
|
|
239
|
-
'Sec-Fetch-Dest': 'empty',
|
|
240
|
-
'Sec-Fetch-Mode': 'cors',
|
|
241
|
-
'Sec-Fetch-Site': 'same-origin',
|
|
242
|
-
'X-CSRF': '1'
|
|
243
|
-
}
|
|
231
|
+
headers: deviceData.Headers
|
|
244
232
|
});
|
|
245
233
|
|
|
246
234
|
if (displayType === 1 && deviceData.Device.OperationMode === 8) {
|