homebridge-melcloud-control 4.9.2-beta.6 → 4.9.2-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/CHANGELOG.md +2 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/constants.js +1 -0
- package/src/melcloudhome.js +14 -10
package/CHANGELOG.md
CHANGED
|
@@ -24,10 +24,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
24
24
|
- For plugin < v4.6.0 use Homebridge UI <= v5.5.0
|
|
25
25
|
- For plugin >= v4.6.0 use Homebridge UI >= v5.13.0
|
|
26
26
|
|
|
27
|
-
# [4.
|
|
27
|
+
# [4.10.0] - (16.04.2026)
|
|
28
28
|
|
|
29
29
|
## Changes
|
|
30
30
|
|
|
31
|
+
- added web socket for real time data refresh with MELCloud Home
|
|
31
32
|
- cleanup
|
|
32
33
|
|
|
33
34
|
# [4.9.1] - (15.04.2026)
|
package/index.js
CHANGED
|
@@ -83,7 +83,7 @@ class MelCloudPlatform {
|
|
|
83
83
|
melCloudClass = new MelCloud(account, true);
|
|
84
84
|
break;
|
|
85
85
|
case 'melcloudhome':
|
|
86
|
-
timmers = [{ name: 'checkDevicesList', sampling:
|
|
86
|
+
timmers = [{ name: 'checkDevicesList', sampling: 10000 }];
|
|
87
87
|
melCloudClass = new MelCloudHome(account, true);
|
|
88
88
|
break;
|
|
89
89
|
default:
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.9.2-beta.
|
|
4
|
+
"version": "4.9.2-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",
|
package/src/constants.js
CHANGED
package/src/melcloudhome.js
CHANGED
|
@@ -16,10 +16,12 @@ class MelCloudHome extends EventEmitter {
|
|
|
16
16
|
|
|
17
17
|
this.user = account.user;
|
|
18
18
|
this.passwd = account.passwd;
|
|
19
|
+
this.logSuccess = account.log?.success;
|
|
19
20
|
this.logInfo = account.log?.info;
|
|
20
21
|
this.logWarn = account.log?.warn;
|
|
21
22
|
this.logError = account.log?.error;
|
|
22
23
|
this.logDebug = account.log?.debug;
|
|
24
|
+
this.pluginStart = pluginStart;
|
|
23
25
|
|
|
24
26
|
this.functions = new Functions(this.logWarn, this.logError, this.logDebug)
|
|
25
27
|
.on('warn', warn => this.emit('warn', warn))
|
|
@@ -85,7 +87,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
85
87
|
if (this.logError) this.emit('error', `connectSocket: cannot get WS hash: ${err.message}`);
|
|
86
88
|
this.connecting = false;
|
|
87
89
|
this.scheduleReconnect();
|
|
88
|
-
return
|
|
90
|
+
return;
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
const url = `${ApiUrls.Home.WebSocket}${hash}`;
|
|
@@ -95,7 +97,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
95
97
|
'Cache-Control': 'no-cache',
|
|
96
98
|
};
|
|
97
99
|
|
|
98
|
-
if (
|
|
100
|
+
if (this.logDebug) this.emit('debug', `Connecting WebSocket: ${url.slice(0, 60)}...`);
|
|
99
101
|
|
|
100
102
|
try {
|
|
101
103
|
const ws = new WebSocket(url, { headers });
|
|
@@ -106,7 +108,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
106
108
|
try { ws.close(); } catch { /* ignoruj */ }
|
|
107
109
|
})
|
|
108
110
|
.on('close', () => {
|
|
109
|
-
if (
|
|
111
|
+
if (this.logDebug) this.emit('debug', 'Web socket closed');
|
|
110
112
|
this.cleanupSocket();
|
|
111
113
|
this.scheduleReconnect();
|
|
112
114
|
})
|
|
@@ -118,7 +120,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
118
120
|
clearTimeout(this.reconnectTimer);
|
|
119
121
|
this.reconnectTimer = null;
|
|
120
122
|
}
|
|
121
|
-
if (
|
|
123
|
+
if (this.logSuccess) this.emit('success', 'Web Socket Connected');
|
|
122
124
|
|
|
123
125
|
// Heartbeat co 30s
|
|
124
126
|
this.heartbeat = setInterval(() => {
|
|
@@ -129,12 +131,12 @@ class MelCloudHome extends EventEmitter {
|
|
|
129
131
|
}, 30_000);
|
|
130
132
|
})
|
|
131
133
|
.on('pong', () => {
|
|
132
|
-
if (
|
|
134
|
+
if (this.logDebug) this.emit('debug', 'Web socket received heartbeat');
|
|
133
135
|
})
|
|
134
136
|
.on('message', (message) => {
|
|
135
137
|
try {
|
|
136
138
|
const parsedMessage = JSON.parse(message);
|
|
137
|
-
if (
|
|
139
|
+
if (this.logDebug) this.emit('debug', `Web socket incoming message: ${JSON.stringify(parsedMessage, null, 2)}`);
|
|
138
140
|
|
|
139
141
|
// Format: array, pierwszy element ma Data.id
|
|
140
142
|
const messageData = parsedMessage?.[0]?.Data;
|
|
@@ -423,14 +425,16 @@ class MelCloudHome extends EventEmitter {
|
|
|
423
425
|
this.ensureClient();
|
|
424
426
|
this.attachTokenInterceptors();
|
|
425
427
|
this.emit('client', this.client);
|
|
426
|
-
const webSocket = await this.connectSocket().catch(err => {
|
|
427
|
-
if (this.logError) this.emit('error', `Initial WebSocket connect failed: ${err.message}`);
|
|
428
|
-
});
|
|
429
428
|
|
|
430
|
-
|
|
429
|
+
if (this.pluginStart) {
|
|
430
|
+
await this.connectSocket().catch(err => {
|
|
431
|
+
if (this.logError) this.emit('error', `Initial WebSocket connect failed: ${err.message}`);
|
|
432
|
+
});
|
|
433
|
+
}
|
|
431
434
|
}
|
|
432
435
|
|
|
433
436
|
connectInfo.State = exchangeRes;
|
|
437
|
+
connectInfo.Status = exchangeRes ? 'Connect Success' : 'Connect Failed';
|
|
434
438
|
|
|
435
439
|
return connectInfo;
|
|
436
440
|
}
|