homebridge-melcloud-control 4.4.0-beta.14 → 4.4.0-beta.15

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.14",
4
+ "version": "4.4.0-beta.15",
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
@@ -758,7 +758,7 @@ class DeviceAta extends EventEmitter {
758
758
  })
759
759
  .onSet(async (value) => {
760
760
  try {
761
- let { min, max } = await this.functions.adjustTempProtection(deviceData.FrostProtection.Min, deviceData.FrostProtection.Max, value, 4, 14, 6, 16);
761
+ let { min, max } = await this.functions.adjustTempProtection(deviceData.FrostProtection.Min, deviceData.FrostProtection.Max, value, 'max', 4, 14, 6, 16);
762
762
  deviceData.FrostProtection.Min = min;
763
763
  deviceData.FrostProtection.Max = max;
764
764
  if (this.logInfo) this.emit('info', `Set frost protection max. temperature: ${max}${this.accessory.temperatureUnit}`);
@@ -779,7 +779,7 @@ class DeviceAta extends EventEmitter {
779
779
  })
780
780
  .onSet(async (value) => {
781
781
  try {
782
- let { min, max } = await this.functions.adjustTempProtection(deviceData.FrostProtection.Min, deviceData.FrostProtection.Max, value, 4, 14, 6, 16);
782
+ let { min, max } = await this.functions.adjustTempProtection(deviceData.FrostProtection.Min, deviceData.FrostProtection.Max, value, 'min', 4, 14, 6, 16);
783
783
  deviceData.FrostProtection.Min = min;
784
784
  deviceData.FrostProtection.Max = max;
785
785
  if (this.logInfo) this.emit('info', `Set frost protection min. temperature: ${min}${this.accessory.temperatureUnit}`);
@@ -877,7 +877,7 @@ class DeviceAta extends EventEmitter {
877
877
  })
878
878
  .onSet(async (value) => {
879
879
  try {
880
- let { min, max } = await this.functions.adjustTempProtection(deviceData.OverheatProtection.Min, deviceData.OverheatProtection.Max, value, 31, 38, 33, 40);
880
+ let { min, max } = await this.functions.adjustTempProtection(deviceData.OverheatProtection.Min, deviceData.OverheatProtection.Max, value, 'max', 31, 38, 33, 40);
881
881
  deviceData.OverheatProtection.Min = min;
882
882
  deviceData.OverheatProtection.Max = max;
883
883
  if (this.logInfo) this.emit('info', `Set overheat protection max. temperature: ${max}${this.accessory.temperatureUnit}`);
@@ -898,7 +898,7 @@ class DeviceAta extends EventEmitter {
898
898
  })
899
899
  .onSet(async (value) => {
900
900
  try {
901
- let { min, max } = await this.functions.adjustTempProtection(deviceData.OverheatProtection.Min, deviceData.OverheatProtection.Max, value, 31, 38, 33, 40);
901
+ let { min, max } = await this.functions.adjustTempProtection(deviceData.OverheatProtection.Min, deviceData.OverheatProtection.Max, value, 'min', 31, 38, 33, 40);
902
902
  deviceData.OverheatProtection.Min = min;
903
903
  deviceData.OverheatProtection.Max = max;
904
904
  if (this.logInfo) this.emit('info', `Set overheat protection min. temperature: ${min}${this.accessory.temperatureUnit}`);
package/src/functions.js CHANGED
@@ -238,42 +238,49 @@ class Functions extends EventEmitter {
238
238
  );
239
239
  }
240
240
 
241
- async adjustTempProtection(oldMin, oldMax, newValue, minRangeMin, maxRangeMin, minRangeMax, maxRangeMax) {
241
+ async adjustTempProtection(oldMin, oldMax, newValue, type, minRangeMin, maxRangeMin, minRangeMax, maxRangeMax) {
242
242
  let min = oldMin;
243
243
  let max = oldMax;
244
244
 
245
- if (newValue !== oldMin) {
246
- // użytkownik zmienił MIN
245
+ if (type === "min") {
247
246
  min = Math.min(Math.max(newValue, minRangeMin), maxRangeMin);
248
247
 
249
248
  if (min > oldMin && max - min < 2) {
250
- // podbij max minimalnie potrzebną wartość
251
249
  max = Math.min(min + 2, maxRangeMax);
250
+
251
+ // jeśli max uderza w górną granicę → obniż min o 2
252
+ if (max === maxRangeMax && max - min < 2) {
253
+ min = Math.max(min - 2, minRangeMin);
254
+ }
255
+
252
256
  return { min, max };
253
257
  }
258
+
254
259
  // min maleje → zwracamy tylko min
255
260
  return { min };
256
261
  }
257
262
 
258
- if (newValue !== oldMax) {
259
- // użytkownik zmienił MAX
263
+ if (type === "max") {
260
264
  max = Math.min(Math.max(newValue, minRangeMax), maxRangeMax);
261
265
 
262
266
  if (max < oldMax && max - min < 2) {
263
- // obniż min minimalnie potrzebną wartość
264
267
  min = Math.max(max - 2, minRangeMin);
268
+
269
+ // jeśli min uderza w dolną granicę → podbij max o 2
270
+ if (min === minRangeMin && max - min < 2) {
271
+ max = Math.min(max + 2, maxRangeMax);
272
+ }
273
+
265
274
  return { min, max };
266
275
  }
276
+
267
277
  // max rośnie → zwracamy tylko max
268
278
  return { max };
269
279
  }
270
280
 
271
- // brak zmiany
272
281
  return { min, max };
273
282
  }
274
283
 
275
-
276
-
277
284
  }
278
285
 
279
286
  export default Functions