homebridge-melcloud-control 4.3.0-beta.40 → 4.3.0-beta.42

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.3.0-beta.40",
4
+ "version": "4.3.0-beta.42",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -153,7 +153,6 @@ class MelCloudAta extends EventEmitter {
153
153
  else if (!isNaN(value) && value !== "") parsedValue = Number(value);
154
154
  return [name, parsedValue];
155
155
  }));
156
-
157
156
  Object.assign(deviceData.Device, settings);
158
157
 
159
158
  this.emit('deviceState', deviceData);
@@ -331,6 +330,8 @@ class MelCloudAta extends EventEmitter {
331
330
  this.headers.Referer = ApiUrlsHome.Referers.GetPutScenes;
332
331
  break;
333
332
  default:
333
+ if (!this.socket || this.socket.readyState !== WebSocket.OPEN) return;
334
+
334
335
  if (displayType === 1 && deviceData.Device.OperationMode === 8) {
335
336
  deviceData.Device.SetTemperature = (deviceData.Device.DefaultCoolingSetTemperature + deviceData.Device.DefaultHeatingSetTemperature) / 2;
336
337
 
@@ -357,7 +358,27 @@ class MelCloudAta extends EventEmitter {
357
358
  path = ApiUrlsHome.PutAta.replace('deviceid', deviceData.DeviceID);
358
359
  this.headers.Referer = ApiUrlsHome.Referers.PutDeviceSettings;
359
360
  updateState = false;
360
- break;
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
+ messageType: "SetUnitState",
373
+ Data: {
374
+ id: deviceData.DeviceID, // Twój ID jednostki
375
+ unitType: "ata", // tak jak incoming
376
+ settings: settings // czyli tablica: [{ name, value }, ...]
377
+ }
378
+ }
379
+ ];
380
+ this.socket.send(JSON.stringify(payload1));
381
+ return;
361
382
  }
362
383
 
363
384
  this.headers['Content-Type'] = 'application/json; charset=utf-8';
@@ -287,7 +287,7 @@ class MelCloudHome extends EventEmitter {
287
287
  if (url.startsWith('wss://ws.melcloudhome.com/?hash=')) {
288
288
  const params = new URL(url).searchParams;
289
289
  hash = params.get('hash');
290
- if (this.logDebug) this.emit('debug', `MelCloudHome WS hash detected: ${melcloudHash}`);
290
+ if (this.logDebug) this.emit('debug', `MelCloudHome WS hash detected: ${hash}`);
291
291
  }
292
292
  } catch (err) {
293
293
  this.emit('error', `CDP WebSocketCreated handler error: ${err.message}`);