hoffmation-base 3.2.22 → 3.2.24
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.
|
@@ -45,7 +45,21 @@ class TemperatureSensor {
|
|
|
45
45
|
this.lastSeen = utils_1.Utils.nowMS();
|
|
46
46
|
let correctedValue = val;
|
|
47
47
|
if (this.outdoorTemperatureCorrectionCoefficient !== 0 && weather_1.WeatherService.currentTemp !== interfaces_1.UNDEFINED_TEMP_VALUE) {
|
|
48
|
-
|
|
48
|
+
const tempDiff = 21 - weather_1.WeatherService.currentTemp;
|
|
49
|
+
// Use degressive correction: full coefficient up to 10K diff (=11°C outdoor), then reduce
|
|
50
|
+
// This prevents over-correction at very low outdoor temperatures
|
|
51
|
+
const maxLinearDiff = 10;
|
|
52
|
+
if (tempDiff <= maxLinearDiff) {
|
|
53
|
+
correctedValue = val + this.outdoorTemperatureCorrectionCoefficient * tempDiff;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Reduce coefficient for the portion beyond maxLinearDiff
|
|
57
|
+
// e.g. at 25K diff (=-4°C): first 10K at full coeff, remaining 15K at reduced coeff
|
|
58
|
+
const linearPart = maxLinearDiff * this.outdoorTemperatureCorrectionCoefficient;
|
|
59
|
+
const excessDiff = tempDiff - maxLinearDiff;
|
|
60
|
+
const reducedPart = excessDiff * this.outdoorTemperatureCorrectionCoefficient * 0.3;
|
|
61
|
+
correctedValue = val + linearPart + reducedPart;
|
|
62
|
+
}
|
|
49
63
|
}
|
|
50
64
|
this._temperature = correctedValue;
|
|
51
65
|
for (const cb of this._temperaturCallbacks) {
|