homebridge-melcloud-control 4.3.0-beta.21 → 4.3.0-beta.23
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/index.js +1 -1
- package/package.json +1 -1
- package/src/melcloudata.js +1 -8
- package/src/melcloudhome.js +14 -3
package/index.js
CHANGED
|
@@ -194,7 +194,7 @@ class MelCloudPlatform {
|
|
|
194
194
|
|
|
195
195
|
//start impulse generators\
|
|
196
196
|
await configuredDevice.startStopImpulseGenerator(true, [{ name: 'checkState', sampling: deviceRefreshInterval }]);
|
|
197
|
-
const timmers = accountType === 'melcloudhome' ? [{ name: 'connect', sampling:
|
|
197
|
+
const timmers = accountType === 'melcloudhome' ? [{ name: 'connect', sampling: 3600000 }, { name: 'checkDevicesList', sampling: 3000 }] : [{ name: 'checkDevicesList', sampling: refreshInterval }];
|
|
198
198
|
await melCloud.impulseGenerator.state(true, timmers, false);
|
|
199
199
|
|
|
200
200
|
//stop impulse generator
|
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.23",
|
|
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
|
@@ -26,7 +26,6 @@ class MelCloudAta extends EventEmitter {
|
|
|
26
26
|
//set default values
|
|
27
27
|
this.deviceData = {};
|
|
28
28
|
this.headers = {};
|
|
29
|
-
this.hash = null;
|
|
30
29
|
this.socket = null;
|
|
31
30
|
this.socketConnected = false;
|
|
32
31
|
|
|
@@ -82,13 +81,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
82
81
|
deviceData.Device.VaneHorizontalDirection = AirConditioner.VaneHorizontalDirectionMapStringToEnum[deviceData.Device.VaneHorizontalDirection] ?? deviceData.Device.VaneHorizontalDirection;
|
|
83
82
|
|
|
84
83
|
if (!this.socketConnected) {
|
|
85
|
-
const socket = new WebSocket(`wss://ws.melcloudhome.com/?hash=${devicesData.
|
|
86
|
-
headers: {
|
|
87
|
-
'Origin': 'https://melcloudhome.com',
|
|
88
|
-
'Pragma': 'no-cache',
|
|
89
|
-
'Cache-Control': 'no-cache'
|
|
90
|
-
}
|
|
91
|
-
})
|
|
84
|
+
const socket = new WebSocket(`wss://ws.melcloudhome.com/?hash=${devicesData.WsHeaders.hash}`, { headers: WsHeaders.headers })
|
|
92
85
|
.on('error', (error) => {
|
|
93
86
|
if (this.logDebug) this.emit('debug', `Socket error: ${error}`);
|
|
94
87
|
socket.close();
|
package/src/melcloudhome.js
CHANGED
|
@@ -23,7 +23,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
23
23
|
this.buildingsFile = buildingsFile;
|
|
24
24
|
this.devicesFile = devicesFile;
|
|
25
25
|
this.headers = {};
|
|
26
|
-
this.
|
|
26
|
+
this.wsHeaders = {};
|
|
27
27
|
|
|
28
28
|
this.functions = new Functions(this.logWarn, this.logError, this.logDebug)
|
|
29
29
|
.on('warn', warn => this.emit('warn', warn))
|
|
@@ -209,7 +209,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
209
209
|
devicesList.Devices = devices;
|
|
210
210
|
devicesList.Scenes = scenes;
|
|
211
211
|
devicesList.Headers = this.headers;
|
|
212
|
-
devicesList.
|
|
212
|
+
devicesList.WsHeaders = this.wsHeaders;
|
|
213
213
|
|
|
214
214
|
await this.functions.saveData(this.devicesFile, devicesList);
|
|
215
215
|
if (this.logDebug) this.emit('debug', `${devicesCount} devices saved`);
|
|
@@ -279,13 +279,14 @@ class MelCloudHome extends EventEmitter {
|
|
|
279
279
|
page.setDefaultNavigationTimeout(GLOBAL_TIMEOUT);
|
|
280
280
|
|
|
281
281
|
// === CDP session ===
|
|
282
|
+
let hash = null;
|
|
282
283
|
const client = await page.createCDPSession();
|
|
283
284
|
await client.send('Network.enable')
|
|
284
285
|
client.on('Network.webSocketCreated', ({ url }) => {
|
|
285
286
|
try {
|
|
286
287
|
if (url.startsWith('wss://ws.melcloudhome.com/?hash=')) {
|
|
287
288
|
const params = new URL(url).searchParams;
|
|
288
|
-
|
|
289
|
+
hash = params.get('hash');
|
|
289
290
|
if (this.logDebug) this.emit('debug', `MelCloudHome WS hash detected: ${melcloudHash}`);
|
|
290
291
|
}
|
|
291
292
|
} catch (err) {
|
|
@@ -373,6 +374,16 @@ class MelCloudHome extends EventEmitter {
|
|
|
373
374
|
headers: headers
|
|
374
375
|
})
|
|
375
376
|
|
|
377
|
+
this.wsHeaders = {
|
|
378
|
+
hash: hash,
|
|
379
|
+
headers: {
|
|
380
|
+
'Origin': ApiUrlsHome.BaseURL,
|
|
381
|
+
'Pragma': 'no-cache',
|
|
382
|
+
'Cache-Control': 'no-cache'
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
|
|
376
387
|
accountInfo.State = true;
|
|
377
388
|
accountInfo.Info = 'Connect to MELCloud Home Success';
|
|
378
389
|
await this.functions.saveData(this.accountFile, accountInfo);
|