Maia comments: change MAX_ALPHA to 0.5, add slope calculation at each cycle.

This commit is contained in:
Jean-Marc Collin
2023-11-21 18:56:26 +00:00
parent ae568c8be2
commit 9e15aa48b9
2 changed files with 10 additions and 5 deletions

View File

@@ -464,8 +464,8 @@ class BaseThermostat(ClimateEntity, RestoreEntity):
self._cycle_min * 60,
# Needed for time calculation
get_tz(self._hass),
# one digit after the coma for temperature
1,
# two digits after the coma for temperature slope calculation
2,
)
_LOGGER.debug(
@@ -2095,6 +2095,9 @@ class BaseThermostat(ClimateEntity, RestoreEntity):
force,
)
# calculate the smooth_temperature with EMA calculation
await self._async_manage_window_auto()
self.update_custom_attributes()
return True

View File

@@ -14,7 +14,7 @@ MIN_TIME_DECAY_SEC = 0
# For example when using a half life of 10 minutes a measurement that is 60 minutes ago
# (if there's nothing inbetween) would contribute to the smoothed value with 1,5%,
# giving the current measurement 98,5% relevance. It could be wise to limit the alpha to e.g. 4x the half life (=0.9375).
MAX_ALPHA = 0.9375
MAX_ALPHA = 0.5
class ExponentialMovingAverage:
@@ -73,11 +73,13 @@ class ExponentialMovingAverage:
self._last_timestamp = timestamp
self._current_ema = new_ema
_LOGGER.debug(
"%s - alpha=%.2f new_ema=%.2f last_timestamp=%s",
"%s - timestamp=%s alpha=%.2f measurement=%.2f current_ema=%.2f new_ema=%.2f",
self,
timestamp,
alpha,
measurement,
self._current_ema,
self._last_timestamp,
new_ema,
)
return round(self._current_ema, self._precision)