homebridge-melcloud-control 4.2.8 → 4.2.10
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/CHANGELOG.md +1 -1
- package/README.md +14 -14
- package/package.json +3 -2
- package/src/deviceata.js +2 -2
- package/src/deviceatw.js +1 -1
- package/src/deviceerv.js +1 -1
- package/src/melcloudata.js +16 -0
- package/src/melcloudhome.js +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -26,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
26
26
|
|
|
27
27
|
## Changes
|
|
28
28
|
|
|
29
|
-
- added option to set only switch for presets,
|
|
29
|
+
- added option to set only switch for presets, scenes, schedules or buttons
|
|
30
30
|
- readme updated
|
|
31
31
|
- cleanup
|
|
32
32
|
|
package/README.md
CHANGED
|
@@ -238,13 +238,13 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
238
238
|
| `user` | Here set the account username. |
|
|
239
239
|
| `passwd` | Here set the account password. |
|
|
240
240
|
| `language` | Here select the account language. |
|
|
241
|
-
| `type` | Here select the account type `None/Disabled`, `MELCloud`, `MELCloud Home`. |
|
|
241
|
+
| `type` | Here select the account type `0 - None/Disabled`, `1 - MELCloud`, `2 - MELCloud Home`. |
|
|
242
242
|
| `ataDevices[]` | Array of ATA devices created automatically after login to MELCloud from plugin config UI. |
|
|
243
243
|
| `ataDevices[].id` | Read only data, do not change it. |
|
|
244
244
|
| `ataDevices[].type` | Read only data, do not change it. |
|
|
245
245
|
| `ataDevices[].typeString` | Read only data, do not change it. |
|
|
246
246
|
| `ataDevices[].name` | Here You can change the `Accessory Name` which is exposed to the `Homebridge/HomeKit`. |
|
|
247
|
-
| `ataDevices[].displayType` | Here select device control mode `None/Disabled`, `Heater/Cooler`, `Thermostat`. |
|
|
247
|
+
| `ataDevices[].displayType` | Here select device control mode `0 - None/Disabled`, `1 - Heater/Cooler`, `2 - Thermostat`. |
|
|
248
248
|
| `ataDevices[].heatDryFanMode` | Here select the operatiing mode for `Heat`, if this mode is not supported, it will be disabled. |
|
|
249
249
|
| `ataDevices[].coolDryFanMode` | Here select the operatiing mode for `Cool`, if this mode is not supported, it will be disabled. |
|
|
250
250
|
| `ataDevices[].autoDryFanMode` | Here select the operatiing mode for `Auto`, if this mode is not supported, it will be disabled.. |
|
|
@@ -260,18 +260,18 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
260
260
|
| `ataDevices[].presets[]` | Array of ATA device `Presets` created automatically after login to MELCloud from plugin config UI. |
|
|
261
261
|
| `ataDevices[].presets[].id` | Read only data, do not change it. |
|
|
262
262
|
| `ataDevices[].presets[].name` | Here You can change the `Preset Name` which is exposed to the `Homebridge/HomeKit`. |
|
|
263
|
-
| `ataDevices[].presets[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch +Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
263
|
+
| `ataDevices[].presets[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch + Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
264
264
|
| `ataDevices[].schedules[]` | Array of ATA device `Schedules` created automatically after login to MELCloud Home from plugin config UI. |
|
|
265
265
|
| `ataDevices[].schedules[].id` | Read only data, do not change it. |
|
|
266
266
|
| `ataDevices[].schedules[].name` | Here You can change the `Schedule Name` which is exposed to the `Homebridge/HomeKit`. |
|
|
267
|
-
| `ataDevices[].schedules[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch +Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
267
|
+
| `ataDevices[].schedules[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch + Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
268
268
|
| `ataDevices[].scenes[].id` | Read only data, do not change it. |
|
|
269
269
|
| `ataDevices[].scenes[].name` | Here You can change the `Scene Name` which is exposed to the `Homebridge/HomeKit`. |
|
|
270
|
-
| `ataDevices[].scenes[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch +Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
270
|
+
| `ataDevices[].scenes[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch + Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
271
271
|
| `ataDevices[].buttonsSensors[]` | Array of buttons sensors. |
|
|
272
272
|
| `ataDevices[].buttonsSensors[].name` | Here set `Button Name` which You want expose to the `Homebridge/HomeKit`. |
|
|
273
273
|
| `ataDevices[].buttonsSensors[].mode` | Here select button mode, VH - Vane Horizontal, VV - Vane Horizontal. |
|
|
274
|
-
| `ataDevices[].buttonsSensors[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch +Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
274
|
+
| `ataDevices[].buttonsSensors[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch + Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
275
275
|
| `ataDevices[].buttonsSensors[].namePrefix` | Here enable/disable the accessory name as a prefix for button/sensor name. |
|
|
276
276
|
| `atwDevices[]` | Array of ATA devices created automatically after login to MELCloud from plugin config UI. |
|
|
277
277
|
| `atwDevices[].id` | Read only data, do not change it. |
|
|
@@ -297,18 +297,18 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
297
297
|
| `atwDevices[].presets[]` | Array of ATW device `Presets` created automatically after login to MELCloud from plugin config UI. |
|
|
298
298
|
| `atwDevices[].presets[].id` | Read only data, do not change it. |
|
|
299
299
|
| `atwDevices[].presets[].name` | Here You can change the `Preset Name` which is exposed to the `Homebridge/HomeKit`. |
|
|
300
|
-
| `atwDevices[].presets[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch +Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
300
|
+
| `atwDevices[].presets[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch + Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
301
301
|
| `atwDevices[].schedules[]` | Array of ATW device `Schedules` created automatically after login to MELCloud Home from plugin config UI. |
|
|
302
302
|
| `atwDevices[].schedules[].id` | Read only data, do not change it. |
|
|
303
303
|
| `atwDevices[].schedules[].name` | Here You can change the `Schedule Name` which is exposed to the `Homebridge/HomeKit`. |
|
|
304
|
-
| `atwDevices[].schedules[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch +Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
304
|
+
| `atwDevices[].schedules[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch + Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
305
305
|
| `atwDevices[].scenes[].id` | Read only data, do not change it. |
|
|
306
306
|
| `atwDevices[].scenes[].name` | Here You can change the `Scene Name` which is exposed to the `Homebridge/HomeKit`. |
|
|
307
|
-
| `atwDevices[].scenes[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch +Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
307
|
+
| `atwDevices[].scenes[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch + Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
308
308
|
| `atwDevices[].buttonsSensors[]` | Array of buttons sensors. |
|
|
309
309
|
| `atwDevices[].buttonsSensors[].name` | Here set `Button Name` which You want expose to the `Homebridge/HomeKit`. |
|
|
310
310
|
| `atwDevices[].buttonsSensors[].mode` | Here select button mode. |
|
|
311
|
-
| `atwDevices[].buttonsSensors[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch +Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
311
|
+
| `atwDevices[].buttonsSensors[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch + Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
312
312
|
| `atwDevices[].buttonsSensors[].namePrefix` | Here enable/disable the accessory name as a prefix for button/sensor name. |
|
|
313
313
|
| `ervDevices[]` | Array of ATA devices created automatically after login to MELCloud from plugin config UI. |
|
|
314
314
|
| `ervDevices[].id` | Read only data, do not change it. |
|
|
@@ -327,18 +327,18 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
327
327
|
| `ervDevices[].presets[]` | Array of ERV device `Presets` created automatically after login to MELCloud from plugin config UI. |
|
|
328
328
|
| `ervDevices[].presets[].id` | Read only data, do not change it. |
|
|
329
329
|
| `ervDevices[].presets[].name` | Here You can change the `Preset Name` which is exposed to the `Homebridge/HomeKit`. |
|
|
330
|
-
| `ervDevices[].presets[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch +Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
330
|
+
| `ervDevices[].presets[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch + Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
331
331
|
| `ervDevices[].schedules[]` | Array of ERV device `Schedules` created automatically after login to MELCloud Home from plugin config UI. |
|
|
332
332
|
| `ervDevices[].schedules[].id` | Read only data, do not change it. |
|
|
333
333
|
| `ervDevices[].schedules[].name` | Here You can change the `Schedule Name` which is exposed to the `Homebridge/HomeKit`. |
|
|
334
|
-
| `ervDevices[].schedules[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch +Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
334
|
+
| `ervDevices[].schedules[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch + Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
335
335
|
| `ervDevices[].scenes[].id` | Read only data, do not change it. |
|
|
336
336
|
| `ervDevices[].scenes[].name` | Here You can change the `Scene Name` which is exposed to the `Homebridge/HomeKit`. |
|
|
337
|
-
| `ervDevices[].scenes[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch +Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
337
|
+
| `ervDevices[].scenes[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch + Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
338
338
|
| `ervDevices[].buttonsSensors[]` | Array of buttons sensors. |
|
|
339
339
|
| `ervDevices[].buttonsSensors[].name` | Here set `Button Name` which You want expose to the `Homebridge/HomeKit`. |
|
|
340
340
|
| `ervDevices[].buttonsSensors[].mode` | Here select button mode. |
|
|
341
|
-
| `ervDevices[].buttonsSensors[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch +Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
341
|
+
| `ervDevices[].buttonsSensors[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`, `4 - Switch + Motion Sensor`, `5 - Switch + Occupancy Sensor`, `6 - Switch + Contact Sensor`, `7 - Switch`. |
|
|
342
342
|
| `ervDevices[].buttonsSensors[].namePrefix` | Here enable/disable the accessory name as a prefix for button/sensor name. |
|
|
343
343
|
| `refreshInterval` | Here set the background account data refresh time in (sec) , only for old MELCLoud, default `120s`. |
|
|
344
344
|
| `log{}` | Log object. |
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.2.
|
|
4
|
+
"version": "4.2.10",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"async-mqtt": "^2.6.3",
|
|
40
40
|
"axios": "^1.13.2",
|
|
41
41
|
"express": "^5.1.0",
|
|
42
|
-
"puppeteer": "^24.30.0"
|
|
42
|
+
"puppeteer": "^24.30.0",
|
|
43
|
+
"ws": "^8.18.3"
|
|
43
44
|
},
|
|
44
45
|
"keywords": [
|
|
45
46
|
"homebridge",
|
package/src/deviceata.js
CHANGED
|
@@ -1079,10 +1079,10 @@ class DeviceAta extends EventEmitter {
|
|
|
1079
1079
|
//control
|
|
1080
1080
|
if (button.displayType > 3) {
|
|
1081
1081
|
if (this.logDebug) this.emit('debug', `Prepare button control ${name} service`);
|
|
1082
|
-
const buttonControlService = new
|
|
1082
|
+
const buttonControlService = new Service.Switch(serviceName, `buttonControlService${deviceId} ${i}`);
|
|
1083
1083
|
buttonControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1084
1084
|
buttonControlService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
1085
|
-
buttonControlService.getCharacteristic(Characteristic
|
|
1085
|
+
buttonControlService.getCharacteristic(Characteristic.On)
|
|
1086
1086
|
.onGet(async () => {
|
|
1087
1087
|
const state = button.state;
|
|
1088
1088
|
return state;
|
package/src/deviceatw.js
CHANGED
|
@@ -1346,7 +1346,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1346
1346
|
//control
|
|
1347
1347
|
if (button.displayType > 3) {
|
|
1348
1348
|
if (this.logDebug) this.emit('debug', `Prepare button control ${name} service`);
|
|
1349
|
-
const buttonControlService = new
|
|
1349
|
+
const buttonControlService = new Service.Switch(serviceName1, `buttonControlService${deviceId} ${i}`);
|
|
1350
1350
|
buttonControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1351
1351
|
buttonControlService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
|
|
1352
1352
|
buttonControlService.getCharacteristic(Characteristic.On)
|
package/src/deviceerv.js
CHANGED
|
@@ -1006,7 +1006,7 @@ class DeviceErv extends EventEmitter {
|
|
|
1006
1006
|
//control
|
|
1007
1007
|
if (button.displayType > 3) {
|
|
1008
1008
|
if (this.logDebug) this.emit('debug', `Prepare button control ${name} service`);
|
|
1009
|
-
const buttonControlService = new
|
|
1009
|
+
const buttonControlService = new Service.Switch(serviceName1, `buttonControlService${deviceId} ${i}`);
|
|
1010
1010
|
buttonControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1011
1011
|
buttonControlService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
|
|
1012
1012
|
buttonControlService.getCharacteristic(Characteristic.On)
|
package/src/melcloudata.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import WebSocket from 'ws';
|
|
1
2
|
import axios from 'axios';
|
|
2
3
|
import EventEmitter from 'events';
|
|
3
4
|
import ImpulseGenerator from './impulsegenerator.js';
|
|
@@ -25,6 +26,9 @@ class MelCloudAta extends EventEmitter {
|
|
|
25
26
|
//set default values
|
|
26
27
|
this.deviceData = {};
|
|
27
28
|
this.headers = {};
|
|
29
|
+
this.hash = null;
|
|
30
|
+
this.socket = null;
|
|
31
|
+
this.socketConnected = false;
|
|
28
32
|
|
|
29
33
|
//lock flag
|
|
30
34
|
this.locks = false;
|
|
@@ -50,13 +54,24 @@ class MelCloudAta extends EventEmitter {
|
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
|
|
57
|
+
cleanupSocket = () => {
|
|
58
|
+
if (this.heartbeat) {
|
|
59
|
+
clearInterval(this.heartbeat);
|
|
60
|
+
this.heartbeat = null;
|
|
61
|
+
}
|
|
62
|
+
this.socket = null;
|
|
63
|
+
this.socketConnected = false;
|
|
64
|
+
};
|
|
65
|
+
|
|
53
66
|
async checkState() {
|
|
54
67
|
try {
|
|
68
|
+
|
|
55
69
|
//read device info from file
|
|
56
70
|
const devicesData = await this.functions.readData(this.devicesFile, true);
|
|
57
71
|
if (!devicesData) return;
|
|
58
72
|
|
|
59
73
|
this.headers = devicesData.Headers;
|
|
74
|
+
this.hash = devicesData.Hash;
|
|
60
75
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
61
76
|
if (this.accountType === 'melcloudhome') {
|
|
62
77
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
@@ -70,6 +85,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
70
85
|
const temps = await this.functions.readData(this.defaultTempsFile, true);
|
|
71
86
|
deviceData.Device.DefaultHeatingSetTemperature = temps?.defaultHeatingSetTemperature ?? 20;
|
|
72
87
|
deviceData.Device.DefaultCoolingSetTemperature = temps?.defaultCoolingSetTemperature ?? 24;
|
|
88
|
+
|
|
73
89
|
}
|
|
74
90
|
if (this.logDebug) this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
|
|
75
91
|
|
package/src/melcloudhome.js
CHANGED
|
@@ -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`);
|
|
@@ -276,6 +278,21 @@ class MelCloudHome extends EventEmitter {
|
|
|
276
278
|
page.setDefaultTimeout(GLOBAL_TIMEOUT);
|
|
277
279
|
page.setDefaultNavigationTimeout(GLOBAL_TIMEOUT);
|
|
278
280
|
|
|
281
|
+
// === CDP session ===
|
|
282
|
+
const client = await page.createCDPSession();
|
|
283
|
+
await client.send('Network.enable')
|
|
284
|
+
client.on('Network.webSocketCreated', ({ url }) => {
|
|
285
|
+
try {
|
|
286
|
+
if (url.startsWith('wss://ws.melcloudhome.com/?hash=')) {
|
|
287
|
+
const params = new URL(url).searchParams;
|
|
288
|
+
this.hash = params.get('hash');
|
|
289
|
+
if (this.logDebug) this.emit('debug', `MelCloudHome WS hash detected: ${melcloudHash}`);
|
|
290
|
+
}
|
|
291
|
+
} catch (err) {
|
|
292
|
+
this.emit('error', `CDP WebSocketCreated handler error: ${err.message}`);
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
279
296
|
try {
|
|
280
297
|
await page.goto(ApiUrlsHome.BaseURL, { waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT });
|
|
281
298
|
} catch (error) {
|