homebridge-melcloud-control 4.0.0-beta.364 → 4.0.0-beta.365
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/melcloudhometoken.js +21 -4
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.365",
|
|
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/melcloudhometoken.js
CHANGED
|
@@ -3,8 +3,8 @@ import crypto from 'crypto';
|
|
|
3
3
|
import { wrapper } from 'axios-cookiejar-support';
|
|
4
4
|
import { CookieJar } from 'tough-cookie';
|
|
5
5
|
import { JSDOM } from 'jsdom';
|
|
6
|
-
import QueryString from 'querystring';
|
|
7
6
|
import EventEmitter from 'events';
|
|
7
|
+
import { ApiUrls, ApiUrlsHome } from './constants.js';
|
|
8
8
|
|
|
9
9
|
const MOBILE_USER_AGENT = 'MonitorAndControl.App.Mobile/35 CFNetwork/3860.100.1 Darwin/25.0.0';
|
|
10
10
|
const CLIENT_ID = 'homemobile';
|
|
@@ -151,9 +151,6 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
151
151
|
validateStatus: status => [200, 302, 400].includes(status),
|
|
152
152
|
});
|
|
153
153
|
|
|
154
|
-
if (this.logWarn) this.emit('warn', `Redirect: ${cookies}`);
|
|
155
|
-
return cookies;
|
|
156
|
-
|
|
157
154
|
|
|
158
155
|
if (response.status === 302 && response.headers.location) {
|
|
159
156
|
// Login success — mamy redirect z "code="
|
|
@@ -169,6 +166,26 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
169
166
|
|
|
170
167
|
if (this.logWarn) this.emit('warn', `Redirect URL found code: ${getResp.data}, ${getResp.headers}`);
|
|
171
168
|
|
|
169
|
+
const listDevicesData = await this.client.get(ApiUrlsHome.GetUserContext, {
|
|
170
|
+
method: 'GET',
|
|
171
|
+
baseURL: ApiUrlsHome.BaseURL,
|
|
172
|
+
timeout: 25000,
|
|
173
|
+
headers: {
|
|
174
|
+
'Accept': '*/*',
|
|
175
|
+
'Accept-Language': 'en-US,en;q=0.9',
|
|
176
|
+
'User-Agent': 'homebridge-melcloud-control/4.0.0',
|
|
177
|
+
'DNT': '1',
|
|
178
|
+
'Origin': 'https://melcloudhome.com',
|
|
179
|
+
'Referer': 'https://melcloudhome.com/dashboard',
|
|
180
|
+
'Sec-Fetch-Dest': 'empty',
|
|
181
|
+
'Sec-Fetch-Mode': 'cors',
|
|
182
|
+
'Sec-Fetch-Site': 'same-origin',
|
|
183
|
+
'X-CSRF': '1'
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
const buildingsList = listDevicesData.data.buildings;
|
|
187
|
+
if (this.logDebug) this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`);
|
|
188
|
+
|
|
172
189
|
const match = redirectUrl.match(/[?&]code=([^&]+)/);
|
|
173
190
|
if (match) {
|
|
174
191
|
const code = match[1];
|