homebridge-melcloud-control 4.0.0-beta.352 → 4.0.0-beta.354

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.352",
4
+ "version": "4.0.0-beta.354",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -153,7 +153,6 @@ class MelCloudHomeToken extends EventEmitter {
153
153
  validateStatus: status => [200, 302, 400].includes(status),
154
154
  });
155
155
 
156
- if (this.logWarn) this.emit('warn', `Response: ${response}`);
157
156
 
158
157
  if (response.status === 302 && response.headers.location) {
159
158
  // Login success — mamy redirect z "code="
@@ -168,17 +167,20 @@ class MelCloudHomeToken extends EventEmitter {
168
167
  withCredentials: true,
169
168
  });
170
169
 
171
- if (this.logWarn) this.emit('warn', `ResponseL: ${getResp}`);
172
-
173
- const match = redirectUrl.match(/[?&]code=([^&]+)/);
174
- if (match) {
175
- const code = match[1];
176
- if (this.logWarn) this.emit('warn', `Redirect URL found code: ${code}`);
177
- return code;
178
- } else {
179
- if (this.logWarn) this.emit('warn', `Redirect URL found, but no "code=" param: ${redirectUrl}`);
180
- return null;
181
- }
170
+ // --- Krok 3: GET dashboard po zalogowaniu ---
171
+ const dashboardResp = await axios.get('https://melcloudhome.com/dashboard', {
172
+ headers: { 'User-Agent': MOBILE_USER_AGENT }
173
+ });
174
+
175
+ // --- Krok 4: Pobierz cookies z dashboard ---
176
+ const dashboardCookies = await jar.getCookies('https://melcloudhome.com/dashboard');
177
+ // Możemy zwrócić jako string do użycia w nagłówku:
178
+ const cookieHeader = dashboardCookies.map(c => `${c.key}=${c.value}`).join('; ');
179
+
180
+ const cookies = dashboardCookies.map(c => `${c.key}=${c.value}`);
181
+
182
+ if (this.logWarn) this.emit('warn', `Response: ${dashboardResp.data}, ${dashboardResp.headers}, ${cookies}`);
183
+ return cookies
182
184
  }
183
185
 
184
186
  if (response.status === 400) if (this.logWarn) this.emit('warn', `Login failed (bad request or invalid credentials: ${response.data}`);