homebridge-melcloud-control 4.2.5-beta.31 → 4.2.5-beta.33

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.2.5-beta.31",
4
+ "version": "4.2.5-beta.33",
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/deviceata.js CHANGED
@@ -931,6 +931,8 @@ class DeviceAta extends EventEmitter {
931
931
  if (this.logDebug) this.emit('debug', `Prepare schedules services`);
932
932
  this.scheduleSensorServices = [];
933
933
  this.schedules.forEach((schedule, i) => {
934
+ const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
935
+
934
936
  //get preset name
935
937
  const name = schedule.name;
936
938
 
@@ -959,7 +961,7 @@ class DeviceAta extends EventEmitter {
959
961
  try {
960
962
  deviceData.ScheduleEnabled = state;
961
963
  if (this.logInfo) this.emit('info', `Schedules: ${state ? 'Enabled' : 'Disabled'}`);
962
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'schedule');
964
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'schedule', scheduleData);
963
965
  } catch (error) {
964
966
  if (this.logWarn) this.emit('warn', `Set schedules error: ${error}`);
965
967
  };
@@ -1678,7 +1680,7 @@ class DeviceAta extends EventEmitter {
1678
1680
  this.schedules.forEach((schedule, i) => {
1679
1681
  const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
1680
1682
  const characteristicType = schedule.characteristicType;
1681
- schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
1683
+ schedule.state = scheduleEnabled ? (scheduleData.Enabled ?? false) : false;
1682
1684
 
1683
1685
  //control
1684
1686
  if (i === 0) {
@@ -1697,7 +1699,7 @@ class DeviceAta extends EventEmitter {
1697
1699
  if (this.scenes.length > 0) {
1698
1700
  this.scenes.forEach((scene, i) => {
1699
1701
  const sceneData = scenesOnServer.find(s => s.Id === scene.id);
1700
- scene.state = sceneData.Enabled;
1702
+ scene.state = sceneData.Enabled ?? false;
1701
1703
 
1702
1704
  //control
1703
1705
  if (scene.displayType > 3) {
package/src/deviceatw.js CHANGED
@@ -1251,6 +1251,8 @@ class DeviceAtw extends EventEmitter {
1251
1251
  this.scheduleSensorServices = [];
1252
1252
  this.schedules.forEach((schedule, i) => {
1253
1253
  //get preset name
1254
+ const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
1255
+
1254
1256
  const name = schedule.name;
1255
1257
 
1256
1258
  //get preset name prefix
@@ -1278,7 +1280,7 @@ class DeviceAtw extends EventEmitter {
1278
1280
  try {
1279
1281
  deviceData.ScheduleEnabled = state;
1280
1282
  if (this.logInfo) this.emit('info', `Schedules: ${state ? 'Enabled' : 'Disabled'}`);
1281
- await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, 'schedule');
1283
+ await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, 'schedule', scheduleData);
1282
1284
  } catch (error) {
1283
1285
  if (this.logWarn) this.emit('warn', `Set schedules error: ${error}`);
1284
1286
  };
@@ -2151,7 +2153,7 @@ class DeviceAtw extends EventEmitter {
2151
2153
  this.schedules.forEach((schedule, i) => {
2152
2154
  const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
2153
2155
  const characteristicType = schedule.characteristicType;
2154
- schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
2156
+ schedule.state = scheduleEnabled ? (scheduleData.Enabled ?? false) : false;
2155
2157
 
2156
2158
  //control
2157
2159
  if (i === 0) {
package/src/deviceerv.js CHANGED
@@ -854,6 +854,8 @@ class DeviceErv extends EventEmitter {
854
854
  if (this.logDebug) this.emit('debug', `Prepare schedules services`);
855
855
  this.scheduleSensorServices = [];
856
856
  this.schedules.forEach((schedule, i) => {
857
+ const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
858
+
857
859
  //get preset name
858
860
  const name = schedule.name;
859
861
 
@@ -882,7 +884,7 @@ class DeviceErv extends EventEmitter {
882
884
  try {
883
885
  deviceData.ScheduleEnabled = state;
884
886
  if (this.logInfo) this.emit('info', `Schedules: ${state ? 'Enabled' : 'Disabled'}`);
885
- await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'schedule');
887
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'schedule', scheduleData);
886
888
  } catch (error) {
887
889
  if (this.logWarn) this.emit('warn', `Set schedule serror: ${error}`);
888
890
  };
@@ -1436,7 +1438,7 @@ class DeviceErv extends EventEmitter {
1436
1438
  this.schedules.forEach((schedule, i) => {
1437
1439
  const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
1438
1440
  const characteristicType = schedule.characteristicType;
1439
- schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
1441
+ schedule.state = scheduleEnabled ? (scheduleData.Enabled ?? false) : false;
1440
1442
 
1441
1443
  //control
1442
1444
  if (i === 0) {
@@ -97,15 +97,18 @@ class MelCloudAta extends EventEmitter {
97
97
  //display info if units are not configured in MELCloud service
98
98
  if (unitsCount === 0 && this.logDebug) if (this.logDebug) this.emit('debug', `Units are not configured in MELCloud service`);
99
99
 
100
+ //filter info
101
+ const { Device: _ignored, ...info } = deviceData;
102
+
100
103
  //restFul
101
104
  if (this.restFulEnabled) {
102
- this.emit('restFul', 'info', deviceData);
105
+ this.emit('restFul', 'info', info);
103
106
  this.emit('restFul', 'state', deviceData.Device);
104
107
  }
105
108
 
106
109
  //mqtt
107
110
  if (this.mqttEnabled) {
108
- this.emit('mqtt', 'Info', deviceData);
111
+ this.emit('mqtt', 'Info', info);
109
112
  this.emit('mqtt', 'State', deviceData.Device);
110
113
  }
111
114
 
@@ -23,7 +23,7 @@ class MelCloudAtw extends EventEmitter {
23
23
  .on('debug', debug => this.emit('debug', debug));
24
24
 
25
25
  //set default values
26
- this.devicesData = {};
26
+ this.deviceData = {};
27
27
  this.headers = {};
28
28
 
29
29
  //lock flags
@@ -90,22 +90,25 @@ class MelCloudAtw extends EventEmitter {
90
90
  //display info if units are not configured in MELCloud service
91
91
  if (unitsCount === 0 && this.logDebug) if (this.logDebug) this.emit('debug', `Units are not configured in MELCloud service`);
92
92
 
93
+ //filter info
94
+ const { Device: _ignored, ...info } = deviceData;
95
+
93
96
  //restFul
94
97
  if (this.restFulEnabled) {
95
- this.emit('restFul', 'info', deviceData);
98
+ this.emit('restFul', 'info', info);
96
99
  this.emit('restFul', 'state', deviceData.Device);
97
100
  }
98
101
 
99
102
  //mqtt
100
103
  if (this.mqttEnabled) {
101
- this.emit('mqtt', 'Info', deviceData);
104
+ this.emit('mqtt', 'Info', info);
102
105
  this.emit('mqtt', 'State', deviceData.Device);
103
106
  }
104
107
 
105
108
  //check state changes
106
- const deviceDataHasNotChanged = JSON.stringify(devicesData) === JSON.stringify(this.devicesData);
109
+ const deviceDataHasNotChanged = JSON.stringify(deviceData) === JSON.stringify(this.deviceData);
107
110
  if (deviceDataHasNotChanged) return;
108
- this.devicesData = devicesData;
111
+ this.deviceData = deviceData;
109
112
 
110
113
  //emit info
111
114
  this.emit('deviceInfo', indoor.model, outdoor.model, serialNumber, firmwareAppVersion, hasHotWaterTank, hasZone2);
@@ -23,7 +23,7 @@ class MelCloudErv extends EventEmitter {
23
23
  .on('debug', debug => this.emit('debug', debug));
24
24
 
25
25
  //set default values
26
- this.devicesData = {};
26
+ this.deviceData = {};
27
27
  this.headers = {};
28
28
 
29
29
  //lock flags
@@ -92,22 +92,25 @@ class MelCloudErv extends EventEmitter {
92
92
  //display info if units are not configured in MELCloud service
93
93
  if (unitsCount === 0 && this.logDebug) if (this.logDebug) this.emit('debug', `Units are not configured in MELCloud service`);
94
94
 
95
+ //filter info
96
+ const { Device: _ignored, ...info } = deviceData;
97
+
95
98
  //restFul
96
99
  if (this.restFulEnabled) {
97
- this.emit('restFul', 'info', deviceData);
100
+ this.emit('restFul', 'info', info);
98
101
  this.emit('restFul', 'state', deviceData.Device);
99
102
  }
100
103
 
101
104
  //mqtt
102
105
  if (this.mqttEnabled) {
103
- this.emit('mqtt', 'Info', deviceData);
106
+ this.emit('mqtt', 'Info', info);
104
107
  this.emit('mqtt', 'State', deviceData.Device);
105
108
  }
106
109
 
107
110
  //check state changes
108
- const deviceDataHasNotChanged = JSON.stringify(devicesData) === JSON.stringify(this.devicesData);
111
+ const deviceDataHasNotChanged = JSON.stringify(deviceData) === JSON.stringify(this.deviceData);
109
112
  if (deviceDataHasNotChanged) return;
110
- this.devicesData = devicesData;
113
+ this.deviceData = deviceData;
111
114
 
112
115
  //emit info
113
116
  this.emit('deviceInfo', indoor.model, outdoor.model, serialNumber, firmwareAppVersion);