homebridge-melcloud-control 4.3.0-beta.45 → 4.3.0-beta.47
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 +1 -1
- package/src/melcloudata.js +12 -10
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.47",
|
|
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
|
@@ -91,6 +91,12 @@ class MelCloudAta extends EventEmitter {
|
|
|
91
91
|
|
|
92
92
|
this.headers = devicesData.Headers;
|
|
93
93
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
94
|
+
|
|
95
|
+
//check state changes
|
|
96
|
+
const deviceDataHasNotChanged = JSON.stringify(deviceData) === JSON.stringify(this.deviceData);
|
|
97
|
+
if (deviceDataHasNotChanged) return;
|
|
98
|
+
this.deviceData = deviceData;
|
|
99
|
+
|
|
94
100
|
if (this.accountType === 'melcloudhome') {
|
|
95
101
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
96
102
|
deviceData.Device.OperationMode = AirConditioner.OperationModeMapStringToEnum[deviceData.Device.OperationMode] ?? deviceData.Device.OperationMode;
|
|
@@ -137,12 +143,13 @@ class MelCloudAta extends EventEmitter {
|
|
|
137
143
|
.on('message', (message) => {
|
|
138
144
|
const parsedMessage = JSON.parse(message);
|
|
139
145
|
const stringifyMessage = JSON.stringify(parsedMessage, null, 2);
|
|
140
|
-
if (this.logDebug) this.emit('
|
|
146
|
+
if (this.logDebug) this.emit('debug', `Incoming message: ${stringifyMessage}`);
|
|
141
147
|
if (parsedMessage.message === 'Forbidden') return;
|
|
142
148
|
|
|
143
149
|
const messageData = parsedMessage?.[0]?.Data;
|
|
144
|
-
|
|
150
|
+
if (!messageData) return;
|
|
145
151
|
|
|
152
|
+
const unitId = messageData?.id;
|
|
146
153
|
switch (unitId) {
|
|
147
154
|
case this.deviceId:
|
|
148
155
|
const messageType = parsedMessage[0].messageType;
|
|
@@ -159,9 +166,8 @@ class MelCloudAta extends EventEmitter {
|
|
|
159
166
|
|
|
160
167
|
this.emit('deviceState', deviceData);
|
|
161
168
|
break;
|
|
162
|
-
case '
|
|
163
|
-
|
|
164
|
-
Object.assign(deviceData.Device, state);
|
|
169
|
+
case 'unitWifiSignalChanged':
|
|
170
|
+
Object.assign(deviceData, messageData.rssi);
|
|
165
171
|
|
|
166
172
|
this.emit('deviceState', deviceData);
|
|
167
173
|
break;
|
|
@@ -222,11 +228,6 @@ class MelCloudAta extends EventEmitter {
|
|
|
222
228
|
this.emit('mqtt', 'State', deviceData.Device);
|
|
223
229
|
}
|
|
224
230
|
|
|
225
|
-
//check state changes
|
|
226
|
-
const deviceDataHasNotChanged = JSON.stringify(deviceData) === JSON.stringify(this.deviceData);
|
|
227
|
-
if (deviceDataHasNotChanged) return;
|
|
228
|
-
this.deviceData = deviceData;
|
|
229
|
-
|
|
230
231
|
//emit info
|
|
231
232
|
this.emit('deviceInfo', indoor.model, outdoor.model, serialNumber, firmwareAppVersion);
|
|
232
233
|
|
|
@@ -367,6 +368,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
367
368
|
break;
|
|
368
369
|
}
|
|
369
370
|
|
|
371
|
+
//sens payload
|
|
370
372
|
this.headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
371
373
|
this.headers.Origin = ApiUrlsHome.Origin;
|
|
372
374
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|