homebridge-melcloud-control 4.3.0-beta.30 → 4.3.0-beta.32

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/melcloudata.js +19 -6
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.30",
4
+ "version": "4.3.0-beta.32",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -114,10 +114,10 @@ class MelCloudAta extends EventEmitter {
114
114
  })
115
115
  .on('message', (message) => {
116
116
  const parsedMessage = JSON.parse(message);
117
- const messageData = parsed[0].Data;
118
- const unitId = messageData.id;
119
- const stringifyMessage = JSON.stringify(parsedMessage, null, 2);
120
- if (!this.logDebug) this.emit('warn', `Incoming message: ${stringifyMessage}`);
117
+ if (!this.logDebug) this.emit('warn', `Incoming message: ${JSON.stringify(parsedMessage, null, 2)}`);
118
+
119
+ const messageData = parsedMessage?.[0]?.Data;
120
+ const unitId = messageData?.id;
121
121
 
122
122
  switch (unitId) {
123
123
  case this.deviceId:
@@ -130,7 +130,8 @@ class MelCloudAta extends EventEmitter {
130
130
  break;
131
131
  case 'unitWiFiChanged':
132
132
  const state = Object.fromEntries(messageData.settings.map(s => [s.name, s.value]));
133
- Object.assign(deviceData.Device, state); //emit state this.emit('deviceState', deviceData);
133
+ Object.assign(deviceData.Device, state);
134
+ this.emit('deviceState', deviceData);
134
135
  break;
135
136
  }
136
137
  break;
@@ -354,8 +355,20 @@ class MelCloudAta extends EventEmitter {
354
355
  path = ApiUrlsHome.PutAta.replace('deviceid', deviceData.DeviceID);
355
356
  this.headers.Referer = ApiUrlsHome.Referers.PutDeviceSettings;
356
357
 
358
+ const payload1 = {
359
+ Data: {
360
+ id: deviceData.DeviceID,
361
+ unitType: 'ata',
362
+ settings: [
363
+ {
364
+ name: 'Power',
365
+ value: deviceData.Device.Power
366
+ }
367
+ ]
368
+ }
369
+ };
357
370
  try {
358
- this.socket.send(JSON.stringify(payload));
371
+ this.socket.send(JSON.stringify(payload1));
359
372
  return true;
360
373
  } catch (err) {
361
374
  if (this.logDebug) this.emit('debug', `Socket send error: ${err}`);