homebridge-melcloud-control 4.3.0-beta.4 → 4.3.0-beta.6
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/melcloudata.js +24 -24
- package/src/melcloudhome.js +11 -12
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.3.0-beta.
|
|
4
|
+
"version": "4.3.0-beta.6",
|
|
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/melcloudata.js
CHANGED
|
@@ -73,34 +73,34 @@ class MelCloudAta extends EventEmitter {
|
|
|
73
73
|
const temps = await this.functions.readData(this.defaultTempsFile, true);
|
|
74
74
|
deviceData.Device.DefaultHeatingSetTemperature = temps?.defaultHeatingSetTemperature ?? 20;
|
|
75
75
|
deviceData.Device.DefaultCoolingSetTemperature = temps?.defaultCoolingSetTemperature ?? 24;
|
|
76
|
-
}
|
|
77
|
-
if (this.logDebug) this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
if (this.start) {
|
|
78
|
+
const hash = '2db32d6f-c19c-4b1f-a0dd-1915420a5152';
|
|
81
79
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
89
|
-
ws.on('open', () => {
|
|
90
|
-
if (!this.logDebug) this.emit('warn', `Connected to MelCloudHome WebSocket`);
|
|
91
|
-
this.start = false;
|
|
92
|
-
})
|
|
93
|
-
.on('message', (data) => {
|
|
94
|
-
if (!this.logDebug) this.emit('warn', `Incoming message:', ${data.toString()}`);
|
|
95
|
-
})
|
|
96
|
-
.on('close', () => {
|
|
97
|
-
if (!this.logDebug) this.emit('warn', `Connection closed`);
|
|
98
|
-
})
|
|
99
|
-
.on('error', (error) => {
|
|
100
|
-
if (!this.logDebug) this.emit('warn', `Connected error: ${error}`);
|
|
80
|
+
const ws = new WebSocket(`wss://ws.melcloudhome.com/?hash=${hash}`, {
|
|
81
|
+
headers: {
|
|
82
|
+
'Origin': 'https://melcloudhome.com',
|
|
83
|
+
'Pragma': 'no-cache',
|
|
84
|
+
'Cache-Control': 'no-cache'
|
|
85
|
+
}
|
|
101
86
|
});
|
|
102
|
-
|
|
87
|
+
ws.on('open', () => {
|
|
88
|
+
if (!this.logDebug) this.emit('warn', `Connected to MelCloudHome WebSocket`);
|
|
89
|
+
this.start = false;
|
|
90
|
+
})
|
|
91
|
+
.on('message', (data) => {
|
|
92
|
+
if (!this.logDebug) this.emit('warn', `Incoming message:', ${data.toString()}`);
|
|
93
|
+
})
|
|
94
|
+
.on('close', () => {
|
|
95
|
+
if (!this.logDebug) this.emit('warn', `Connection closed`);
|
|
96
|
+
})
|
|
97
|
+
.on('error', (error) => {
|
|
98
|
+
if (!this.logDebug) this.emit('warn', `Connected error: ${error}`);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
103
101
|
|
|
102
|
+
}
|
|
103
|
+
if (this.logDebug) this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
|
|
104
104
|
|
|
105
105
|
//device
|
|
106
106
|
const serialNumber = deviceData.SerialNumber || '4.0.0';
|
package/src/melcloudhome.js
CHANGED
|
@@ -273,18 +273,6 @@ class MelCloudHome extends EventEmitter {
|
|
|
273
273
|
const page = await browser.newPage();
|
|
274
274
|
page.on('error', error => this.emit('error', `Page crashed: ${error.message}`));
|
|
275
275
|
page.on('pageerror', error => this.emit('error', `Browser error: ${error.message}`));
|
|
276
|
-
// Zmienna na znaleziony hash
|
|
277
|
-
let melcloudHash = null;
|
|
278
|
-
|
|
279
|
-
// Nasłuchuj WebSocketów
|
|
280
|
-
page.on('request', req => {
|
|
281
|
-
if (req.url().startsWith('wss://ws.melcloudhome.com/?hash=')) {
|
|
282
|
-
const url = req.url();
|
|
283
|
-
const params = new URL(url).searchParams;
|
|
284
|
-
melcloudHash = params.get('hash');
|
|
285
|
-
if (!this.logDebug) this.emit('warn', `FOUND HASH: ${melcloudHash}`);
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
276
|
page.setDefaultTimeout(GLOBAL_TIMEOUT);
|
|
289
277
|
page.setDefaultNavigationTimeout(GLOBAL_TIMEOUT);
|
|
290
278
|
|
|
@@ -325,6 +313,17 @@ class MelCloudHome extends EventEmitter {
|
|
|
325
313
|
}
|
|
326
314
|
await Promise.race([Promise.all([submitButton.click(), page.waitForNavigation({ waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT / 3 })]), new Promise(r => setTimeout(r, GLOBAL_TIMEOUT / 3))]);
|
|
327
315
|
|
|
316
|
+
// Nasłuchuj WebSocketów
|
|
317
|
+
let melcloudHash = null;
|
|
318
|
+
page.on('request', req => {
|
|
319
|
+
if (req.url().startsWith('wss://ws.melcloudhome.com/?hash=')) {
|
|
320
|
+
const url = req.url();
|
|
321
|
+
const params = new URL(url).searchParams;
|
|
322
|
+
melcloudHash = params.get('hash');
|
|
323
|
+
if (!this.logDebug) this.emit('warn', `FOUND HASH: ${melcloudHash}`);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
|
|
328
327
|
// Extract cookies
|
|
329
328
|
let c1 = null, c2 = null;
|
|
330
329
|
const start = Date.now();
|