homebridge-melcloud-control 4.3.0-beta.43 → 4.3.0-beta.45
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 +10 -22
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.45",
|
|
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
|
@@ -136,7 +136,9 @@ class MelCloudAta extends EventEmitter {
|
|
|
136
136
|
})
|
|
137
137
|
.on('message', (message) => {
|
|
138
138
|
const parsedMessage = JSON.parse(message);
|
|
139
|
-
|
|
139
|
+
const stringifyMessage = JSON.stringify(parsedMessage, null, 2);
|
|
140
|
+
if (this.logDebug) this.emit('warn', `Incoming message: ${stringifyMessage}`);
|
|
141
|
+
if (parsedMessage.message === 'Forbidden') return;
|
|
140
142
|
|
|
141
143
|
const messageData = parsedMessage?.[0]?.Data;
|
|
142
144
|
const unitId = messageData?.id;
|
|
@@ -163,8 +165,14 @@ class MelCloudAta extends EventEmitter {
|
|
|
163
165
|
|
|
164
166
|
this.emit('deviceState', deviceData);
|
|
165
167
|
break;
|
|
168
|
+
default:
|
|
169
|
+
if (this.logWarn) this.emit('warn', `Unit ${unitId}, received unknown message type: ${stringifyMessage}`);
|
|
170
|
+
return;
|
|
166
171
|
}
|
|
167
172
|
break;
|
|
173
|
+
default:
|
|
174
|
+
if (this.logWarn) this.emit('warn', `Incoming unknown unit id: ${stringifyMessage}`);
|
|
175
|
+
return;
|
|
168
176
|
}
|
|
169
177
|
});
|
|
170
178
|
} catch (error) {
|
|
@@ -330,8 +338,6 @@ class MelCloudAta extends EventEmitter {
|
|
|
330
338
|
this.headers.Referer = ApiUrlsHome.Referers.GetPutScenes;
|
|
331
339
|
break;
|
|
332
340
|
default:
|
|
333
|
-
if (!this.socket || this.socket.readyState !== WebSocket.OPEN) return;
|
|
334
|
-
|
|
335
341
|
if (displayType === 1 && deviceData.Device.OperationMode === 8) {
|
|
336
342
|
deviceData.Device.SetTemperature = (deviceData.Device.DefaultCoolingSetTemperature + deviceData.Device.DefaultHeatingSetTemperature) / 2;
|
|
337
343
|
|
|
@@ -358,25 +364,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
358
364
|
path = ApiUrlsHome.PutAta.replace('deviceid', deviceData.DeviceID);
|
|
359
365
|
this.headers.Referer = ApiUrlsHome.Referers.PutDeviceSettings;
|
|
360
366
|
updateState = false;
|
|
361
|
-
|
|
362
|
-
const settings = [
|
|
363
|
-
{ "name": "Power", "value": deviceData.Device.Power },
|
|
364
|
-
{ "name": "SetTemperature", "value": deviceData.Device.SetTemperature },
|
|
365
|
-
{ "name": "SetFanSpeed", "value": deviceData.Device.SetFanSpeed },
|
|
366
|
-
{ "name": "OperationMode", "value": deviceData.Device.OperationMode },
|
|
367
|
-
{ "name": "VaneHorizontalDirection", "value": deviceData.Device.VaneHorizontalDirection },
|
|
368
|
-
{ "name": "VaneVerticalDirection", "value": deviceData.Device.VaneVerticalDirection }
|
|
369
|
-
]
|
|
370
|
-
const payload1 = [
|
|
371
|
-
{
|
|
372
|
-
Data: {
|
|
373
|
-
id: deviceData.DeviceID, // Twój ID jednostki
|
|
374
|
-
settings: settings // czyli tablica: [{ name, value }, ...]
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
];
|
|
378
|
-
this.socket.send(JSON.stringify(payload1));
|
|
379
|
-
return;
|
|
367
|
+
break;
|
|
380
368
|
}
|
|
381
369
|
|
|
382
370
|
this.headers['Content-Type'] = 'application/json; charset=utf-8';
|