homebridge-melcloud-control 4.0.0-beta.364 → 4.0.0-beta.366

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.0.0-beta.364",
4
+ "version": "4.0.0-beta.366",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -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,25 @@ 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
+ baseURL: ApiUrlsHome.BaseURL,
171
+ timeout: 25000,
172
+ headers: {
173
+ 'Accept': '*/*',
174
+ 'Accept-Language': 'en-US,en;q=0.9',
175
+ 'User-Agent': 'homebridge-melcloud-control/4.0.0',
176
+ 'DNT': '1',
177
+ 'Origin': 'https://melcloudhome.com',
178
+ 'Referer': 'https://melcloudhome.com/dashboard',
179
+ 'Sec-Fetch-Dest': 'empty',
180
+ 'Sec-Fetch-Mode': 'cors',
181
+ 'Sec-Fetch-Site': 'same-origin',
182
+ 'X-CSRF': '1'
183
+ }
184
+ });
185
+ const buildingsList = listDevicesData.data.buildings;
186
+ if (this.logDebug) this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`);
187
+
172
188
  const match = redirectUrl.match(/[?&]code=([^&]+)/);
173
189
  if (match) {
174
190
  const code = match[1];