Test with reset of error when changing the target temperature. For @pbranly configuration
This commit is contained in:
@@ -48,7 +48,8 @@ class PITemperatureRegulator:
|
|||||||
"""Set the new target_temp"""
|
"""Set the new target_temp"""
|
||||||
self.target_temp = target_temp
|
self.target_temp = target_temp
|
||||||
# Do not reset the accumulated error
|
# Do not reset the accumulated error
|
||||||
# self.accumulated_error = 0
|
# Discussion #191. After a target change we should reset the accumulated error which is certainly wrong now.
|
||||||
|
self.accumulated_error = 0
|
||||||
|
|
||||||
def calculate_regulated_temperature(
|
def calculate_regulated_temperature(
|
||||||
self, internal_temp: float, external_temp: float
|
self, internal_temp: float, external_temp: float
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ async def test_over_climate_regulation_limitations(
|
|||||||
await send_ext_temperature_change_event(entity, 10, event_timestamp)
|
await send_ext_temperature_change_event(entity, 10, event_timestamp)
|
||||||
|
|
||||||
# the regulated temperature should be under
|
# the regulated temperature should be under
|
||||||
assert entity.regulated_target_temp == old_regulated_temp
|
assert entity.regulated_target_temp <= old_regulated_temp
|
||||||
|
|
||||||
# change temperature so that dtemp > 0.5 and time is > period_min (+ 3min)
|
# change temperature so that dtemp > 0.5 and time is > period_min (+ 3min)
|
||||||
event_timestamp = now - timedelta(minutes=12)
|
event_timestamp = now - timedelta(minutes=12)
|
||||||
@@ -363,12 +363,12 @@ async def test_over_climate_regulation_limitations(
|
|||||||
"custom_components.versatile_thermostat.commons.NowClass.get_now",
|
"custom_components.versatile_thermostat.commons.NowClass.get_now",
|
||||||
return_value=event_timestamp,
|
return_value=event_timestamp,
|
||||||
):
|
):
|
||||||
await send_temperature_change_event(entity, 17, event_timestamp)
|
await send_temperature_change_event(entity, 16, event_timestamp)
|
||||||
await send_ext_temperature_change_event(entity, 12, event_timestamp)
|
await send_ext_temperature_change_event(entity, 12, event_timestamp)
|
||||||
|
|
||||||
# the regulated should have been done
|
# the regulated should have been done
|
||||||
assert entity.regulated_target_temp != old_regulated_temp
|
assert entity.regulated_target_temp != old_regulated_temp
|
||||||
assert entity.regulated_target_temp > entity.target_temperature
|
assert entity.regulated_target_temp >= entity.target_temperature
|
||||||
assert (
|
assert (
|
||||||
entity.regulated_target_temp == 17 + 0.5
|
entity.regulated_target_temp == 17 + 0.5
|
||||||
) # 0.7 without round_to_nearest
|
) # 0.7 without round_to_nearest
|
||||||
|
|||||||
Reference in New Issue
Block a user