homebridge-melcloud-control 4.4.0-beta.13 → 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 +1 -1
- package/src/deviceata.js +4 -4
- package/src/functions.js +22 -10
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.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,37 +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
|
-
|
|
246
|
-
if (newValue !== oldMin) {
|
|
245
|
+
if (type === "min") {
|
|
247
246
|
min = Math.min(Math.max(newValue, minRangeMin), maxRangeMin);
|
|
248
247
|
|
|
249
|
-
// jeśli min rośnie i różnica < 2 → podbij max
|
|
250
248
|
if (min > oldMin && max - min < 2) {
|
|
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
|
+
|
|
256
|
+
return { min, max };
|
|
252
257
|
}
|
|
253
258
|
|
|
254
|
-
//
|
|
259
|
+
// min maleje → zwracamy tylko min
|
|
260
|
+
return { min };
|
|
255
261
|
}
|
|
256
|
-
|
|
257
|
-
|
|
262
|
+
|
|
263
|
+
if (type === "max") {
|
|
258
264
|
max = Math.min(Math.max(newValue, minRangeMax), maxRangeMax);
|
|
259
265
|
|
|
260
|
-
// jeśli max maleje i różnica < 2 → obniż min
|
|
261
266
|
if (max < oldMax && max - min < 2) {
|
|
262
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
|
+
|
|
274
|
+
return { min, max };
|
|
263
275
|
}
|
|
264
276
|
|
|
265
|
-
//
|
|
277
|
+
// max rośnie → zwracamy tylko max
|
|
278
|
+
return { max };
|
|
266
279
|
}
|
|
267
280
|
|
|
268
281
|
return { min, max };
|
|
269
282
|
}
|
|
270
283
|
|
|
271
|
-
|
|
272
284
|
}
|
|
273
285
|
|
|
274
286
|
export default Functions
|