homebridge-melcloud-control 4.4.0-beta.5 → 4.4.0-beta.9
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 +18 -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.9",
|
|
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
|
@@ -238,47 +238,33 @@ class Functions extends EventEmitter {
|
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
async
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (
|
|
251
|
-
max =
|
|
252
|
-
} else {
|
|
253
|
-
// Otherwise lower min
|
|
254
|
-
const newMin = max - 2;
|
|
255
|
-
min = Math.max(newMin, 4);
|
|
241
|
+
async adjustTempProtection(oldMin, oldMax, newValue, type, minRangeMin, maxRangeMin, minRangeMax, maxRangeMax) {
|
|
242
|
+
let min = oldMin;
|
|
243
|
+
let max = oldMax;
|
|
244
|
+
|
|
245
|
+
if (type === "min") {
|
|
246
|
+
// użytkownik zmienia MIN
|
|
247
|
+
min = Math.min(Math.max(newValue, minRangeMin), maxRangeMin);
|
|
248
|
+
|
|
249
|
+
// jeśli różnica jest za mała → podnieś MAX
|
|
250
|
+
if (max - min < 2) {
|
|
251
|
+
max = Math.min(min + 2, maxRangeMax);
|
|
256
252
|
}
|
|
257
253
|
}
|
|
258
254
|
|
|
259
|
-
|
|
260
|
-
|
|
255
|
+
if (type === "max") {
|
|
256
|
+
// użytkownik zmienia MAX
|
|
257
|
+
max = Math.min(Math.max(newValue, minRangeMax), maxRangeMax);
|
|
261
258
|
|
|
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);
|
|
259
|
+
// jeśli różnica jest za mała → obniż MIN
|
|
260
|
+
if (max - min < 2) {
|
|
261
|
+
min = Math.max(max - 2, minRangeMin);
|
|
277
262
|
}
|
|
278
263
|
}
|
|
279
264
|
|
|
280
265
|
return { min, max };
|
|
281
266
|
}
|
|
267
|
+
|
|
282
268
|
}
|
|
283
269
|
|
|
284
270
|
export default Functions
|