diff --git a/custom_components/versatile_thermostat/base_thermostat.py b/custom_components/versatile_thermostat/base_thermostat.py index 2a4a901..25bbebd 100644 --- a/custom_components/versatile_thermostat/base_thermostat.py +++ b/custom_components/versatile_thermostat/base_thermostat.py @@ -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 diff --git a/custom_components/versatile_thermostat/ema.py b/custom_components/versatile_thermostat/ema.py index 4f6950d..eb5bca4 100644 --- a/custom_components/versatile_thermostat/ema.py +++ b/custom_components/versatile_thermostat/ema.py @@ -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)