homebridge-melcloud-control 4.4.0-beta.5 → 4.4.0-beta.8
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 +1 -1
- package/src/deviceata.js +4 -4
- package/src/functions.js +27 -32
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.
|
|
4
|
+
"version": "4.4.0-beta.8",
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
@@ -237,48 +237,43 @@ class Functions extends EventEmitter {
|
|
|
237
237
|
})
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
|
+
async adjustTempProtection(oldMin, oldMax, newValue, type, minRangeMin, maxRangeMin, minRangeMax, maxRangeMax) {
|
|
241
|
+
let min = oldMin;
|
|
242
|
+
let max = oldMax;
|
|
240
243
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
// Otherwise lower min
|
|
254
|
-
const newMin = max - 2;
|
|
255
|
-
min = Math.max(newMin, 4);
|
|
244
|
+
if (type === "min") {
|
|
245
|
+
// clamp MIN
|
|
246
|
+
min = Math.min(Math.max(newValue, minRangeMin), maxRangeMin);
|
|
247
|
+
|
|
248
|
+
// ensure difference → raise max if needed
|
|
249
|
+
if (max - min < 2) {
|
|
250
|
+
max = Math.min(min + 2, maxRangeMax);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// if still too small difference → lower min
|
|
254
|
+
if (max - min < 2) {
|
|
255
|
+
min = Math.max(max - 2, minRangeMin);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
if (type === "max") {
|
|
260
|
+
// clamp MAX
|
|
261
|
+
max = Math.min(Math.max(newValue, minRangeMax), maxRangeMax);
|
|
262
|
+
|
|
263
|
+
// ensure difference → lower min if needed
|
|
264
|
+
if (max - min < 2) {
|
|
265
|
+
min = Math.max(max - 2, minRangeMin);
|
|
266
|
+
}
|
|
261
267
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
max = Math.min(Math.max(max, 33), 40);
|
|
266
|
-
|
|
267
|
-
// Ensure difference of at least 2 degrees
|
|
268
|
-
if (max - min < 2) {
|
|
269
|
-
// Try increasing max if possible
|
|
270
|
-
const newMax = min + 2;
|
|
271
|
-
if (newMax <= 40) {
|
|
272
|
-
max = newMax;
|
|
273
|
-
} else {
|
|
274
|
-
// Otherwise lower min
|
|
275
|
-
const newMin = max - 2;
|
|
276
|
-
min = Math.max(newMin, 31);
|
|
268
|
+
// if still too small difference → raise max
|
|
269
|
+
if (max - min < 2) {
|
|
270
|
+
max = Math.min(min + 2, maxRangeMax);
|
|
277
271
|
}
|
|
278
272
|
}
|
|
279
273
|
|
|
280
274
|
return { min, max };
|
|
281
275
|
}
|
|
276
|
+
|
|
282
277
|
}
|
|
283
278
|
|
|
284
279
|
export default Functions
|