homebridge-melcloud-control 4.4.0-beta.11 → 4.4.0-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.4.0-beta.11",
4
+ "version": "4.4.0-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/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,23 +242,27 @@ class Functions extends EventEmitter {
242
242
  let min = oldMin;
243
243
  let max = oldMax;
244
244
 
245
- // Wykryj, którą wartość zmieniono
245
+ // Zmiana MIN
246
246
  if (newValue !== oldMin) {
247
- // użytkownik zmienił MIN
248
247
  min = Math.min(Math.max(newValue, minRangeMin), maxRangeMin);
249
248
 
250
- if (max - min < 2) {
251
- // podnieś MAX, ale nie przekraczając maxRangeMax
249
+ // jeśli min rośnie i różnica < 2 → podbij max
250
+ if (min > oldMin && max - min < 2) {
252
251
  max = Math.min(min + 2, maxRangeMax);
253
252
  }
254
- } else if (newValue !== oldMax) {
255
- // użytkownik zmienił MAX
253
+
254
+ // jeśli min maleje → nic nie ruszamy w max
255
+ }
256
+ // Zmiana MAX
257
+ else if (newValue !== oldMax) {
256
258
  max = Math.min(Math.max(newValue, minRangeMax), maxRangeMax);
257
259
 
258
- if (max - min < 2) {
259
- // obniż MIN, ale nie przekraczając minRangeMin
260
+ // jeśli max maleje i różnica < 2 → obniż min
261
+ if (max < oldMax && max - min < 2) {
260
262
  min = Math.max(max - 2, minRangeMin);
261
263
  }
264
+
265
+ // jeśli max rośnie → nic nie ruszamy w min
262
266
  }
263
267
 
264
268
  return { min, max };