Compare commits
2 Commits
3.8.0.beta
...
3.8.0.beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
663a13809c | ||
|
|
3c497d24fb |
@@ -227,13 +227,23 @@ class RegulationParamLight:
|
||||
""" Light parameters for regulation"""
|
||||
kp:float = 0.2
|
||||
ki:float = 0.05
|
||||
k_ext:float = 0.05
|
||||
offset_max:float = 1.5
|
||||
stabilization_threshold:float = 0.1
|
||||
accumulated_error_threshold:float = 10
|
||||
|
||||
|
||||
class RegulationParamMedium:
|
||||
""" Light parameters for regulation"""
|
||||
kp:float = 0.3
|
||||
ki:float = 0.05
|
||||
k_ext:float = 0.1
|
||||
offset_max:float = 2
|
||||
stabilization_threshold:float = 0.1
|
||||
accumulated_error_threshold:float = 20
|
||||
|
||||
|
||||
class RegulationParamMedium:
|
||||
class RegulationParamStrong:
|
||||
""" Medium parameters for regulation"""
|
||||
kp:float = 0.4
|
||||
ki:float = 0.08
|
||||
@@ -242,7 +252,8 @@ class RegulationParamMedium:
|
||||
stabilization_threshold:float = 0.1
|
||||
accumulated_error_threshold:float = 25
|
||||
|
||||
class RegulationParamStrong:
|
||||
# Not used now
|
||||
class RegulationParamVeryStrong:
|
||||
""" Strong parameters for regulation"""
|
||||
kp:float = 0.6
|
||||
ki:float = 0.1
|
||||
|
||||
@@ -29,7 +29,8 @@ class PITemperatureRegulator:
|
||||
def set_target_temp(self, target_temp):
|
||||
""" Set the new target_temp"""
|
||||
self.target_temp = target_temp
|
||||
self.accumulated_error = 0
|
||||
# Do not reset the accumulated error
|
||||
# self.accumulated_error = 0
|
||||
|
||||
def calculate_regulated_temperature(self, internal_temp: float, external_temp:float): # pylint: disable=unused-argument
|
||||
""" Calculate a new target_temp given some temperature"""
|
||||
|
||||
@@ -87,9 +87,9 @@ class ThermostatOverClimate(BaseThermostat):
|
||||
await super()._async_internal_set_temperature(temperature)
|
||||
|
||||
self._regulation_algo.set_target_temp(self.target_temperature)
|
||||
await self._send_regulated_temperature()
|
||||
await self._send_regulated_temperature(force=True)
|
||||
|
||||
async def _send_regulated_temperature(self):
|
||||
async def _send_regulated_temperature(self, force=False):
|
||||
""" Sends the regulated temperature to all underlying """
|
||||
if not self._regulated_target_temp:
|
||||
self._regulated_target_temp = self.target_temperature
|
||||
@@ -99,13 +99,13 @@ class ThermostatOverClimate(BaseThermostat):
|
||||
self._auto_regulation_dtemp)
|
||||
dtemp = new_regulated_temp - self._regulated_target_temp
|
||||
|
||||
if abs(dtemp) < self._auto_regulation_dtemp:
|
||||
if not force and abs(dtemp) < self._auto_regulation_dtemp:
|
||||
_LOGGER.debug("%s - dtemp (%.1f) is < %.1f -> forget the regulation send", self, dtemp, self._auto_regulation_dtemp)
|
||||
return
|
||||
|
||||
now:datetime = NowClass.get_now(self._hass)
|
||||
period = float((now - self._last_regulation_change).total_seconds()) / 60.
|
||||
if period < self._auto_regulation_period_min:
|
||||
if not force and period < self._auto_regulation_period_min:
|
||||
_LOGGER.debug("%s - period (%.1f) is < %.0f -> forget the regulation send", self, period, self._auto_regulation_period_min)
|
||||
return
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ from custom_components.versatile_thermostat.const import (
|
||||
PRESET_AWAY_SUFFIX,
|
||||
CONF_CLIMATE,
|
||||
CONF_AUTO_REGULATION_MODE,
|
||||
CONF_AUTO_REGULATION_MEDIUM,
|
||||
CONF_AUTO_REGULATION_STRONG,
|
||||
CONF_AUTO_REGULATION_NONE,
|
||||
CONF_AUTO_REGULATION_DTEMP,
|
||||
CONF_AUTO_REGULATION_PERIOD_MIN
|
||||
@@ -127,7 +127,7 @@ MOCK_TH_OVER_SWITCH_TPI_CONFIG = {
|
||||
MOCK_TH_OVER_CLIMATE_TYPE_CONFIG = {
|
||||
CONF_CLIMATE: "climate.mock_climate",
|
||||
CONF_AC_MODE: False,
|
||||
CONF_AUTO_REGULATION_MODE: CONF_AUTO_REGULATION_MEDIUM,
|
||||
CONF_AUTO_REGULATION_MODE: CONF_AUTO_REGULATION_STRONG,
|
||||
CONF_AUTO_REGULATION_DTEMP: 0.5,
|
||||
CONF_AUTO_REGULATION_PERIOD_MIN: 2
|
||||
}
|
||||
@@ -141,7 +141,7 @@ MOCK_TH_OVER_CLIMATE_TYPE_NOT_REGULATED_CONFIG = {
|
||||
MOCK_TH_OVER_CLIMATE_TYPE_AC_CONFIG = {
|
||||
CONF_CLIMATE: "climate.mock_climate",
|
||||
CONF_AC_MODE: True,
|
||||
CONF_AUTO_REGULATION_MODE: CONF_AUTO_REGULATION_MEDIUM,
|
||||
CONF_AUTO_REGULATION_MODE: CONF_AUTO_REGULATION_STRONG,
|
||||
CONF_AUTO_REGULATION_DTEMP: 0.5,
|
||||
CONF_AUTO_REGULATION_PERIOD_MIN: 1
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ async def test_over_climate_regulation(hass: HomeAssistant, skip_hass_states_is_
|
||||
assert entity.hvac_mode is HVACMode.HEAT
|
||||
assert entity.hvac_action == HVACAction.OFF
|
||||
|
||||
assert entity.regulated_target_temp is entity.min_temp
|
||||
assert entity.regulated_target_temp == entity.min_temp
|
||||
|
||||
await send_temperature_change_event(entity, 15, event_timestamp)
|
||||
await send_ext_temperature_change_event(entity, 10, event_timestamp)
|
||||
@@ -296,8 +296,8 @@ async def test_over_climate_regulation_limitations(hass: HomeAssistant, skip_has
|
||||
fake_underlying_climate.set_hvac_action(HVACAction.HEATING) # simulate under heating
|
||||
assert entity.hvac_action == HVACAction.HEATING
|
||||
|
||||
# the regulated temperature should be unchanged
|
||||
assert entity.regulated_target_temp == 15
|
||||
# the regulated temperature will change because when we set temp manually it is forced
|
||||
assert entity.regulated_target_temp == 20.
|
||||
|
||||
# set manual target temp (at now - 18) -> the regulation should be taken into account
|
||||
event_timestamp = now - timedelta(minutes=18)
|
||||
@@ -306,7 +306,7 @@ async def test_over_climate_regulation_limitations(hass: HomeAssistant, skip_has
|
||||
):
|
||||
await entity.async_set_temperature(temperature=17)
|
||||
assert entity.regulated_target_temp > entity.target_temperature
|
||||
assert entity.regulated_target_temp == 18+0.5 # In medium we could go up to +3 degre. 0.7 without round_to_nearest
|
||||
assert entity.regulated_target_temp == 18+1 # In strong we could go up to +3 degre. 0.7 without round_to_nearest
|
||||
old_regulated_temp = entity.regulated_target_temp
|
||||
|
||||
# change temperature so that dtemp < 0.5 and time is > period_min (+ 3min)
|
||||
@@ -331,4 +331,4 @@ async def test_over_climate_regulation_limitations(hass: HomeAssistant, skip_has
|
||||
# the regulated should have been done
|
||||
assert entity.regulated_target_temp != old_regulated_temp
|
||||
assert entity.regulated_target_temp > entity.target_temperature
|
||||
assert entity.regulated_target_temp == 17 + 0.5 # 0.7 without round_to_nearest
|
||||
assert entity.regulated_target_temp == 17 + 1 # 0.7 without round_to_nearest
|
||||
Reference in New Issue
Block a user