homebridge-melcloud-control 4.2.9 → 4.3.0-beta.1
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 +3 -2
- package/src/melcloudata.js +29 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.0-beta.1",
|
|
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/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,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
25
26
|
//set default values
|
|
26
27
|
this.deviceData = {};
|
|
27
28
|
this.headers = {};
|
|
29
|
+
this.start = true;
|
|
28
30
|
|
|
29
31
|
//lock flag
|
|
30
32
|
this.locks = false;
|
|
@@ -52,6 +54,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
52
54
|
|
|
53
55
|
async checkState() {
|
|
54
56
|
try {
|
|
57
|
+
|
|
55
58
|
//read device info from file
|
|
56
59
|
const devicesData = await this.functions.readData(this.devicesFile, true);
|
|
57
60
|
if (!devicesData) return;
|
|
@@ -73,6 +76,32 @@ class MelCloudAta extends EventEmitter {
|
|
|
73
76
|
}
|
|
74
77
|
if (this.logDebug) this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
|
|
75
78
|
|
|
79
|
+
if (this.start) {
|
|
80
|
+
const hash = '2db32d6f-c19c-4b1f-a0dd-1915420a5152';
|
|
81
|
+
|
|
82
|
+
const ws = new WebSocket(`wss://ws.melcloudhome.com/?hash=${hash}`, {
|
|
83
|
+
headers: {
|
|
84
|
+
'Origin': 'https://melcloudhome.com',
|
|
85
|
+
'Pragma': 'no-cache',
|
|
86
|
+
'Cache-Control': 'no-cache'
|
|
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}`);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
76
105
|
//device
|
|
77
106
|
const serialNumber = deviceData.SerialNumber || '4.0.0';
|
|
78
107
|
const firmwareAppVersion = deviceData.Device?.FirmwareAppVersion || '4.0.0';
|