homebridge-melcloud-control 4.4.0-beta.11 → 4.4.0-beta.12

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.4.0-beta.11",
4
+ "version": "4.4.0-beta.12",
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/deviceatw.js CHANGED
@@ -1115,8 +1115,10 @@ class DeviceAtw extends EventEmitter {
1115
1115
  })
1116
1116
  .onSet(async (value) => {
1117
1117
  try {
1118
- deviceData.FrostProtection.Max = value;
1119
- if (this.logInfo) this.emit('info', `Set frost protection max. temperature: ${value}${this.accessory.temperatureUnit}`);
1118
+ let { min, max } = await this.functions.adjustTempProtection(deviceData.FrostProtection.Min, deviceData.FrostProtection.Max, value, 4, 14, 6, 16);
1119
+ deviceData.FrostProtection.Min = min;
1120
+ deviceData.FrostProtection.Max = max;
1121
+ if (this.logInfo) this.emit('info', `Set frost protection max. temperature: ${max}${this.accessory.temperatureUnit}`);
1120
1122
  await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'frostprotection');
1121
1123
  } catch (error) {
1122
1124
  if (this.logWarn) this.emit('warn', `Set frost protection max. temperature error: ${error}`);
@@ -1134,8 +1136,10 @@ class DeviceAtw extends EventEmitter {
1134
1136
  })
1135
1137
  .onSet(async (value) => {
1136
1138
  try {
1137
- deviceData.FrostProtection.Min = value;
1138
- if (this.logInfo) this.emit('info', `Set frost protection min. temperature: ${value}${this.accessory.temperatureUnit}`);
1139
+ let { min, max } = await this.functions.adjustTempProtection(deviceData.FrostProtection.Min, deviceData.FrostProtection.Max, value, 4, 14, 6, 16);
1140
+ deviceData.FrostProtection.Min = min;
1141
+ deviceData.FrostProtection.Max = max;
1142
+ if (this.logInfo) this.emit('info', `Set frost protection min. temperature: ${min}${this.accessory.temperatureUnit}`);
1139
1143
  await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'frostprotection');
1140
1144
  } catch (error) {
1141
1145
  if (this.logWarn) this.emit('warn', `Set frost protection min. temperature error: ${error}`);
@@ -2189,7 +2193,7 @@ class DeviceAtw extends EventEmitter {
2189
2193
  if (this.frostProtectionSupport && frostProtection.Enabled !== null) {
2190
2194
  this.frostProtectionControlService?.updateCharacteristic(Characteristic.Active, frostProtection.Enabled);
2191
2195
  this.frostProtectionControlService?.updateCharacteristic(Characteristic.CurrentHeaterCoolerState, frostProtection.Active ? 2 : 1);
2192
- this.frostProtectionControlService?.updateCharacteristic(Characteristic.TargetHeaterCoolerState, frostProtection.Active ? 2 : 1);
2196
+ this.frostProtectionControlService?.updateCharacteristic(Characteristic.TargetHeaterCoolerState, 0);
2193
2197
  this.frostProtectionControlService?.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature);
2194
2198
  this.frostProtectionControlService?.updateCharacteristic(Characteristic.CoolingThresholdTemperature, frostProtection.Max);
2195
2199
  this.frostProtectionControlService?.updateCharacteristic(Characteristic.HeatingThresholdTemperature, frostProtection.Min);
package/src/functions.js CHANGED
@@ -242,29 +242,23 @@ class Functions extends EventEmitter {
242
242
  let min = oldMin;
243
243
  let max = oldMax;
244
244
 
245
- // Wykryj, którą wartość zmieniono
246
- if (newValue !== oldMin) {
245
+ if (newValue !== oldMin && newValue !== oldMax) {
246
+ // jeśli wartość różna od obu – traktujemy jako min
247
+ min = Math.min(Math.max(newValue, minRangeMin), maxRangeMin);
248
+ if (max - min < 2) max = Math.min(min + 2, maxRangeMax);
249
+ } else if (newValue !== oldMin) {
247
250
  // użytkownik zmienił MIN
248
251
  min = Math.min(Math.max(newValue, minRangeMin), maxRangeMin);
249
-
250
- if (max - min < 2) {
251
- // podnieś MAX, ale nie przekraczając maxRangeMax
252
- max = Math.min(min + 2, maxRangeMax);
253
- }
252
+ if (max - min < 2) max = Math.min(min + 2, maxRangeMax);
254
253
  } else if (newValue !== oldMax) {
255
254
  // użytkownik zmienił MAX
256
255
  max = Math.min(Math.max(newValue, minRangeMax), maxRangeMax);
257
-
258
- if (max - min < 2) {
259
- // obniż MIN, ale nie przekraczając minRangeMin
260
- min = Math.max(max - 2, minRangeMin);
261
- }
256
+ if (max - min < 2) min = Math.max(max - 2, minRangeMin);
262
257
  }
263
258
 
264
259
  return { min, max };
265
260
  }
266
261
 
267
-
268
262
  }
269
263
 
270
264
  export default Functions