homebridge-melcloud-control 4.3.0-beta.7 → 4.3.0-beta.8

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.3.0-beta.7",
4
+ "version": "4.3.0-beta.8",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -26,6 +26,7 @@ class MelCloudAta extends EventEmitter {
26
26
  //set default values
27
27
  this.deviceData = {};
28
28
  this.headers = {};
29
+ this.hash = null;
29
30
  this.start = true;
30
31
 
31
32
  //lock flag
@@ -60,6 +61,7 @@ class MelCloudAta extends EventEmitter {
60
61
  if (!devicesData) return;
61
62
 
62
63
  this.headers = devicesData.Headers;
64
+ this.hash = devicesData.Hash;
63
65
  const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
64
66
  if (this.accountType === 'melcloudhome') {
65
67
  deviceData.Scenes = devicesData.Scenes ?? [];
@@ -75,9 +77,7 @@ class MelCloudAta extends EventEmitter {
75
77
  deviceData.Device.DefaultCoolingSetTemperature = temps?.defaultCoolingSetTemperature ?? 24;
76
78
 
77
79
  if (this.start) {
78
- const hash = '2db32d6f-c19c-4b1f-a0dd-1915420a5152';
79
-
80
- const ws = new WebSocket(`wss://ws.melcloudhome.com/?hash=${hash}`, {
80
+ const ws = new WebSocket(`wss://ws.melcloudhome.com/?hash=${this.hash}`, {
81
81
  headers: {
82
82
  'Origin': 'https://melcloudhome.com',
83
83
  'Pragma': 'no-cache',
@@ -23,6 +23,7 @@ class MelCloudHome extends EventEmitter {
23
23
  this.buildingsFile = buildingsFile;
24
24
  this.devicesFile = devicesFile;
25
25
  this.headers = {};
26
+ this.hash = null;
26
27
 
27
28
  this.functions = new Functions(this.logWarn, this.logError, this.logDebug)
28
29
  .on('warn', warn => this.emit('warn', warn))
@@ -208,6 +209,7 @@ class MelCloudHome extends EventEmitter {
208
209
  devicesList.Devices = devices;
209
210
  devicesList.Scenes = scenes;
210
211
  devicesList.Headers = this.headers;
212
+ devicesList.Hash = this.hash;
211
213
 
212
214
  await this.functions.saveData(this.devicesFile, devicesList);
213
215
  if (this.logDebug) this.emit('debug', `${devicesCount} devices saved`);
@@ -278,17 +280,13 @@ class MelCloudHome extends EventEmitter {
278
280
 
279
281
  // === CDP session (modern API) ===
280
282
  const client = await page.createCDPSession();
281
- await client.send('Network.enable');
282
-
283
- let melcloudHash = null;
284
-
283
+ await client.send('Network.enable')
285
284
  client.on('Network.webSocketCreated', ({ url }) => {
286
285
  try {
287
286
  if (url.startsWith('wss://ws.melcloudhome.com/?hash=')) {
288
287
  const params = new URL(url).searchParams;
289
- melcloudHash = params.get('hash');
290
-
291
- this.emit('warn', `MelCloudHome WS hash detected: ${melcloudHash}`);
288
+ this.hash = params.get('hash');
289
+ if (this.logDebug) this.emit('debug', `MelCloudHome WS hash detected: ${melcloudHash}`);
292
290
  }
293
291
  } catch (err) {
294
292
  this.emit('error', `CDP WebSocketCreated handler error: ${err.message}`);