Maia comments: change MAX_ALPHA to 0.5, add slope calculation at each cycle.
This commit is contained in:
@@ -464,8 +464,8 @@ class BaseThermostat(ClimateEntity, RestoreEntity):
|
|||||||
self._cycle_min * 60,
|
self._cycle_min * 60,
|
||||||
# Needed for time calculation
|
# Needed for time calculation
|
||||||
get_tz(self._hass),
|
get_tz(self._hass),
|
||||||
# one digit after the coma for temperature
|
# two digits after the coma for temperature slope calculation
|
||||||
1,
|
2,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
@@ -2095,6 +2095,9 @@ class BaseThermostat(ClimateEntity, RestoreEntity):
|
|||||||
force,
|
force,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# calculate the smooth_temperature with EMA calculation
|
||||||
|
await self._async_manage_window_auto()
|
||||||
|
|
||||||
self.update_custom_attributes()
|
self.update_custom_attributes()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
# 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%,
|
# (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).
|
# 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:
|
class ExponentialMovingAverage:
|
||||||
@@ -73,11 +73,13 @@ class ExponentialMovingAverage:
|
|||||||
self._last_timestamp = timestamp
|
self._last_timestamp = timestamp
|
||||||
self._current_ema = new_ema
|
self._current_ema = new_ema
|
||||||
_LOGGER.debug(
|
_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,
|
self,
|
||||||
|
timestamp,
|
||||||
alpha,
|
alpha,
|
||||||
|
measurement,
|
||||||
self._current_ema,
|
self._current_ema,
|
||||||
self._last_timestamp,
|
new_ema,
|
||||||
)
|
)
|
||||||
|
|
||||||
return round(self._current_ema, self._precision)
|
return round(self._current_ema, self._precision)
|
||||||
|
|||||||
Reference in New Issue
Block a user