homebridge-melcloud-control 4.3.0-beta.44 → 4.3.0-beta.46
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 +14 -11
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.46",
|
|
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;
|
|
@@ -136,7 +142,9 @@ class MelCloudAta extends EventEmitter {
|
|
|
136
142
|
})
|
|
137
143
|
.on('message', (message) => {
|
|
138
144
|
const parsedMessage = JSON.parse(message);
|
|
139
|
-
|
|
145
|
+
const stringifyMessage = JSON.stringify(parsedMessage, null, 2);
|
|
146
|
+
if (this.logDebug) this.emit('debug', `Incoming message: ${stringifyMessage}`);
|
|
147
|
+
if (parsedMessage.message === 'Forbidden') return;
|
|
140
148
|
|
|
141
149
|
const messageData = parsedMessage?.[0]?.Data;
|
|
142
150
|
const unitId = messageData?.id;
|
|
@@ -157,19 +165,18 @@ class MelCloudAta extends EventEmitter {
|
|
|
157
165
|
|
|
158
166
|
this.emit('deviceState', deviceData);
|
|
159
167
|
break;
|
|
160
|
-
case '
|
|
161
|
-
|
|
162
|
-
Object.assign(deviceData.Device, state);
|
|
168
|
+
case 'unitWifiSignalChanged':
|
|
169
|
+
Object.assign(deviceData, messageData.rssi);
|
|
163
170
|
|
|
164
171
|
this.emit('deviceState', deviceData);
|
|
165
172
|
break;
|
|
166
173
|
default:
|
|
167
|
-
if (this.logWarn) this.emit('warn', `
|
|
174
|
+
if (this.logWarn) this.emit('warn', `Unit ${unitId}, received unknown message type: ${stringifyMessage}`);
|
|
168
175
|
return;
|
|
169
176
|
}
|
|
170
177
|
break;
|
|
171
178
|
default:
|
|
172
|
-
if (this.logWarn) this.emit('warn', `Incoming unknown unit id: ${
|
|
179
|
+
if (this.logWarn) this.emit('warn', `Incoming unknown unit id: ${stringifyMessage}`);
|
|
173
180
|
return;
|
|
174
181
|
}
|
|
175
182
|
});
|
|
@@ -220,11 +227,6 @@ class MelCloudAta extends EventEmitter {
|
|
|
220
227
|
this.emit('mqtt', 'State', deviceData.Device);
|
|
221
228
|
}
|
|
222
229
|
|
|
223
|
-
//check state changes
|
|
224
|
-
const deviceDataHasNotChanged = JSON.stringify(deviceData) === JSON.stringify(this.deviceData);
|
|
225
|
-
if (deviceDataHasNotChanged) return;
|
|
226
|
-
this.deviceData = deviceData;
|
|
227
|
-
|
|
228
230
|
//emit info
|
|
229
231
|
this.emit('deviceInfo', indoor.model, outdoor.model, serialNumber, firmwareAppVersion);
|
|
230
232
|
|
|
@@ -365,6 +367,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
365
367
|
break;
|
|
366
368
|
}
|
|
367
369
|
|
|
370
|
+
//sens payload
|
|
368
371
|
this.headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
369
372
|
this.headers.Origin = ApiUrlsHome.Origin;
|
|
370
373
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|