homebridge-melcloud-control 4.0.0-beta.261 → 4.0.0-beta.263

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.
Files changed (2) hide show
  1. package/package.json +3 -2
  2. package/src/melcloud.js +13 -11
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.261",
4
+ "version": "4.0.0-beta.263",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -42,7 +42,8 @@
42
42
  "puppeteer": "^24.26.1",
43
43
  "axios-cookiejar-support": "^6.0.4",
44
44
  "tough-cookie": "^6.0.0",
45
- "cheerio": "^1.1.2"
45
+ "cheerio": "^1.1.2",
46
+ "node-fetch": "^3.3.2"
46
47
  },
47
48
  "keywords": [
48
49
  "homebridge",
package/src/melcloud.js CHANGED
@@ -177,14 +177,6 @@ class MelCloud extends EventEmitter {
177
177
  }
178
178
 
179
179
  // MELCloud Home
180
- async connectToMelCloudHome2() {
181
- const oauth = new MelCloudHomeToken();
182
- this.tokens = await oauth.getTokensWithCredentials(this.user, this.passwd);
183
- this.emit('warn', `Token ${JSON.stringify(this.tokens, null, 2)}`);
184
- //this.axiosInstance.defaults.headers['Authorization'] = `Bearer ${this.tokens.accessToken}`;
185
- return false;
186
- }
187
-
188
180
  async checkMelcloudHomeDevicesList(contextKey) {
189
181
  try {
190
182
  const axiosInstance = axios.create({
@@ -300,10 +292,20 @@ class MelCloud extends EventEmitter {
300
292
  await page.goto(ApiUrlsHome.BaseURL, { waitUntil: 'networkidle2' });
301
293
 
302
294
  // Kliknięcie przycisku logowania
303
- const loginBtn = await page.$x("//button[contains(text(),'Log In') or contains(text(),'Zaloguj')]");
304
- if (loginBtn.length === 0) throw new Error('Login button not found');
295
+ const buttons = await page.$$('button.btn--blue');
296
+ let loginBtn = null;
297
+
298
+ for (const btn of buttons) {
299
+ const text = await page.evaluate(el => el.textContent, btn);
300
+ if (text.trim() === 'Zaloguj' || text.trim() === 'Log In') {
301
+ loginBtn = btn;
302
+ break;
303
+ }
304
+ }
305
+
306
+ if (!loginBtn) throw new Error('Login button not found');
305
307
  await Promise.all([
306
- loginBtn[0].click(),
308
+ loginBtn.click(),
307
309
  page.waitForNavigation({ waitUntil: 'networkidle2' })
308
310
  ]);
309
311