homebridge-melcloud-control 4.3.9-beta.11 → 4.3.9-beta.13

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.9-beta.11",
4
+ "version": "4.3.9-beta.13",
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
@@ -1398,10 +1398,10 @@ class DeviceAta extends EventEmitter {
1398
1398
  const supportsCool1 = deviceData.Device[supportCoolKey];
1399
1399
  const supportsCool = this.coolDryFanMode >= 1 && supportsCool1;
1400
1400
  const numberOfFanSpeeds = supportsFanSpeed ? deviceData.Device.NumberOfFanSpeeds : 0;
1401
- const minTempHeat = 10;
1402
- const maxTempHeat = 31;
1403
- const minTempCoolDryAuto = 16;
1404
- const maxTempCoolDryAuto = 31;
1401
+ const minTempHeat = deviceData.Device.MinTempHeat ?? 10;
1402
+ const maxTempHeat = deviceData.Device.MaxTempHeat ?? 31;
1403
+ const minTempCoolDryAuto = deviceData.Device.MinTempAutomatic ?? 16;
1404
+ const maxTempCoolDryAuto = deviceData.Device.MaxTempAutomatic ?? 31;
1405
1405
 
1406
1406
  //device state
1407
1407
  const power = deviceData.Device.Power ?? false;
@@ -35,7 +35,7 @@ class MelCloudAta extends EventEmitter {
35
35
  deviceData.Scenes = devicesData.Scenes ?? [];
36
36
 
37
37
  //update state
38
- if (!this.logDebug) this.emit('debug', `Request update device settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
38
+ if (!this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
39
39
  await this.updateState(deviceData);
40
40
  }).on('webSocket', async (parsedMessage) => {
41
41
  try {
@@ -54,21 +54,20 @@ class MelCloudAta extends EventEmitter {
54
54
  //update values
55
55
  for (const [key, value] of Object.entries(settings)) {
56
56
  if (!this.functions.isValidValue(value)) continue;
57
- let parsedValue = this.functions.convertValue(value);
58
57
 
59
58
  //update holiday mode
60
59
  if (key === 'HolidayMode') {
61
- deviceData.HolidayMode.Enabled = parsedValue;
60
+ deviceData.HolidayMode.Enabled = value;
62
61
  continue;
63
62
  }
64
63
 
65
64
  //update device settings
66
65
  if (key in deviceData.Device) {
67
- deviceData.Device[key] = parsedValue;
66
+ deviceData.Device[key] = value;
68
67
  }
69
68
  }
70
69
 
71
- if (!this.logDebug) this.emit('debug', `WS update device settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
70
+ if (!this.logDebug) this.emit('debug', `WS update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
72
71
  updateState = true;
73
72
  break;
74
73
  case 'unitHolidayModeTriggered':
@@ -82,12 +81,12 @@ class MelCloudAta extends EventEmitter {
82
81
  updateState = true;
83
82
  break;
84
83
  default:
85
- if (this.logDebug) this.emit('debug', `Unit ${unitId}, received unknown message type: ${stringifyMessage}`);
84
+ if (this.logDebug) this.emit('debug', `Unit ${unitId}, received unknown message type: ${parsedMessage}`);
86
85
  return;
87
86
  }
88
87
  break;
89
88
  default:
90
- if (this.logDebug) this.emit('debug', `Incoming unknown unit id: ${stringifyMessage}`);
89
+ if (this.logDebug) this.emit('debug', `Incoming unknown unit id: ${parsedMessage}`);
91
90
  return;
92
91
  }
93
92
 
@@ -35,7 +35,7 @@ class MelCloudAtw extends EventEmitter {
35
35
  deviceData.Scenes = devicesData.Scenes ?? [];
36
36
 
37
37
  //update state
38
- if (this.logDebug) this.emit('debug', `Request update device settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
38
+ if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
39
39
  await this.updateState(deviceData);
40
40
  }).on('webSocket', async (parsedMessage) => {
41
41
  try {
@@ -54,21 +54,20 @@ class MelCloudAtw extends EventEmitter {
54
54
  //update values
55
55
  for (const [key, value] of Object.entries(settings)) {
56
56
  if (!this.functions.isValidValue(value)) continue;
57
- let parsedValue = this.functions.convertValue(value);
58
57
 
59
58
  //update holiday mode
60
59
  if (key === 'HolidayMode') {
61
- deviceData.HolidayMode.Enabled = parsedValue;
60
+ deviceData.HolidayMode.Enabled = value;
62
61
  continue;
63
62
  }
64
63
 
65
64
  //update device settings
66
65
  if (key in deviceData.Device) {
67
- deviceData.Device[key] = parsedValue;
66
+ deviceData.Device[key] = value;
68
67
  }
69
68
  }
70
69
 
71
- if (this.logDebug) this.emit('debug', `WS update device settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
70
+ if (this.logDebug) this.emit('debug', `WS update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
72
71
  updateState = true;
73
72
  break;
74
73
  case 'unitHolidayModeTriggered':
@@ -82,12 +81,12 @@ class MelCloudAtw extends EventEmitter {
82
81
  updateState = true;
83
82
  break;
84
83
  default:
85
- if (this.logDebug) this.emit('debug', `Unit ${unitId}, received unknown message type: ${stringifyMessage}`);
84
+ if (this.logDebug) this.emit('debug', `Unit ${unitId}, received unknown message type: ${parsedMessage}`);
86
85
  return;
87
86
  }
88
87
  break;
89
88
  default:
90
- if (this.logDebug) this.emit('debug', `Incoming unknown unit id: ${stringifyMessage}`);
89
+ if (this.logDebug) this.emit('debug', `Incoming unknown unit id: ${parsedMessage}`);
91
90
  return;
92
91
  }
93
92
 
@@ -99,7 +98,7 @@ class MelCloudAtw extends EventEmitter {
99
98
  });
100
99
  }
101
100
 
102
- async updateState(deviceData) {
101
+ async updateState(deviceData, type) {
103
102
  try {
104
103
  if (this.accountType === 'melcloudhome') {
105
104
  deviceData.Device.OperationMode = HeatPump.OperationModeMapStringToEnum[deviceData.Device.OperationMode] ?? deviceData.Device.OperationMode;
@@ -35,7 +35,7 @@ class MelCloudErv extends EventEmitter {
35
35
  deviceData.Scenes = devicesData.Scenes ?? [];
36
36
 
37
37
  //update state
38
- if (this.logDebug) this.emit('debug', `Request update device settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
38
+ if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
39
39
  await this.updateState(deviceData);
40
40
  }).on('webSocket', async (parsedMessage) => {
41
41
  try {
@@ -54,21 +54,20 @@ class MelCloudErv extends EventEmitter {
54
54
  //update values
55
55
  for (const [key, value] of Object.entries(settings)) {
56
56
  if (!this.functions.isValidValue(value)) continue;
57
- let parsedValue = this.functions.convertValue(value);
58
57
 
59
58
  //update holiday mode
60
59
  if (key === 'HolidayMode') {
61
- deviceData.HolidayMode.Enabled = parsedValue;
60
+ deviceData.HolidayMode.Enabled = value;
62
61
  continue;
63
62
  }
64
63
 
65
64
  //update device settings
66
65
  if (key in deviceData.Device) {
67
- deviceData.Device[key] = parsedValue;
66
+ deviceData.Device[key] = value;
68
67
  }
69
68
  }
70
69
 
71
- if (this.logDebug) this.emit('debug', `WS update device settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
70
+ if (this.logDebug) this.emit('debug', `WS update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
72
71
  updateState = true;
73
72
  break;
74
73
  case 'unitHolidayModeTriggered':
@@ -82,12 +81,12 @@ class MelCloudErv extends EventEmitter {
82
81
  updateState = true;
83
82
  break;
84
83
  default:
85
- if (this.logDebug) this.emit('debug', `Unit ${unitId}, received unknown message type: ${stringifyMessage}`);
84
+ if (this.logDebug) this.emit('debug', `Unit ${unitId}, received unknown message type: ${parsedMessage}`);
86
85
  return;
87
86
  }
88
87
  break;
89
88
  default:
90
- if (this.logDebug) this.emit('debug', `Incoming unknown unit id: ${stringifyMessage}`);
89
+ if (this.logDebug) this.emit('debug', `Incoming unknown unit id: ${parsedMessage}`);
91
90
  return;
92
91
  }
93
92
 
@@ -99,7 +98,7 @@ class MelCloudErv extends EventEmitter {
99
98
  });
100
99
  }
101
100
 
102
- async updateState(deviceData) {
101
+ async updateState(deviceData, type) {
103
102
  try {
104
103
  if (this.accountType === 'melcloudhome') {
105
104
  //read default temps
@@ -135,24 +135,13 @@ class MelCloudHome extends EventEmitter {
135
135
 
136
136
  const devices = buildingsList.flatMap(building => {
137
137
  // Funkcja kapitalizująca klucze obiektu
138
- const capitalizeKeys = obj =>
139
- Object.fromEntries(
140
- Object.entries(obj).map(([key, value]) => [
141
- key.charAt(0).toUpperCase() + key.slice(1),
142
- value
143
- ])
144
- );
138
+ const capitalizeKeys = obj => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key.charAt(0).toUpperCase() + key.slice(1), value]));
145
139
 
146
140
  // Rekurencyjna kapitalizacja kluczy w obiekcie lub tablicy
147
141
  const capitalizeKeysDeep = obj => {
148
142
  if (Array.isArray(obj)) return obj.map(capitalizeKeysDeep);
149
143
  if (obj && typeof obj === 'object') {
150
- return Object.fromEntries(
151
- Object.entries(obj).map(([key, value]) => [
152
- key.charAt(0).toUpperCase() + key.slice(1),
153
- capitalizeKeysDeep(value)
154
- ])
155
- );
144
+ return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key.charAt(0).toUpperCase() + key.slice(1), capitalizeKeysDeep(value)]));
156
145
  }
157
146
  return obj;
158
147
  };