Compare commits

...

3 Commits

Author SHA1 Message Date
Jean-Marc Collin e7656a4a43 Change reset cumulated_error formula 2024-02-02 20:56:23 +00:00
Jean-Marc Collin 99cfe81662 Bières ! 2024-01-30 18:21:36 +00:00
Jean-Marc Collin 229cb19a17 Algo fixes 2024-01-27 17:00:00 +00:00
6 changed files with 23 additions and 23 deletions
+1 -1
View File
@@ -128,7 +128,7 @@ En conséquence toute la phase de paramètrage d'un VTherm a été profondemment
**Note :** les copies d'écran de la configuration d'un VTherm n'ont pas été mises à jour.
# Merci pour la bière [buymecoffee](https://www.buymeacoffee.com/jmcollin78)
Un grand merci à @salabur, @pvince83, @bergoglio, @EPicLURcher, @ecolorado66, @Kriss1670, @maia, @f.maymil, @moutte69, @Jerome, @Gunnar M, @Greg.o, @John Burgess, @abyssmal, @capinfo26, @Helge, @MattG @Mexx62, @Someone, @Lajull, @giopeco pour les bières. Ca fait très plaisir et ça m'encourage à continuer !
Un grand merci à @salabur, @pvince83, @bergoglio, @EPicLURcher, @ecolorado66, @Kriss1670, @maia, @f.maymil, @moutte69, @Jerome, @Gunnar M, @Greg.o, @John Burgess, @abyssmal, @capinfo26, @Helge, @MattG @Mexx62, @Someone, @Lajull, @giopeco, @fredericselier, @philpagan pour les bières. Ca fait très plaisir et ça m'encourage à continuer !
# Quand l'utiliser et ne pas l'utiliser
+1 -1
View File
@@ -128,7 +128,7 @@ Consequently, the entire configuration phase of a VTherm has been profoundly mod
**Note:** the VTherm configuration screenshots have not been updated.
# Thanks for the beer [buymecoffee](https://www.buymeacoffee.com/jmcollin78)
Many thanks to @salabur, @pvince83, @bergoglio, @EPicLURcher, @ecolorado66, @Kriss1670, @maia, @f.maymil, @moutte69, @Jerome, @Gunnar M, @Greg.o, @John Burgess, @abyssmal, @capinfo26, @Helge, @MattG, @MattG, @Mexx62, @Someone, @Lajull, @giopeco for the beers. It's very nice and encourages me to continue!
Many thanks to @salabur, @pvince83, @bergoglio, @EPicLURcher, @ecolorado66, @Kriss1670, @maia, @f.maymil, @moutte69, @Jerome, @Gunnar M, @Greg.o, @John Burgess, @abyssmal, @capinfo26, @Helge, @MattG, @MattG, @Mexx62, @Someone, @Lajull, @giopeco, @fredericselier, @philpagan for the beers. It's very nice and encourages me to continue!
# When to use / not use
This thermostat can control 3 types of equipment:
@@ -1233,9 +1233,9 @@ class BaseThermostat(ClimateEntity, RestoreEntity):
)
# If AC is on maybe we have to change the temperature in force mode, but not in frost mode (there is no Frost protection possible in AC mode)
if self._hvac_mode == HVACMode.COOL:
if self._hvac_mode == HVACMode.COOL and self.preset_mode != PRESET_NONE:
if self.preset_mode != PRESET_FROST_PROTECTION:
await self._async_set_preset_mode_internal(self._attr_preset_mode, True)
await self._async_set_preset_mode_internal(self.preset_mode, True)
else:
await self._async_set_preset_mode_internal(PRESET_ECO, True, False)
@@ -47,10 +47,10 @@ class PITemperatureRegulator:
def set_target_temp(self, target_temp):
"""Set the new target_temp"""
self.target_temp = target_temp
# Do not reset the accumulated error
# Discussion #191. After a target change we should reset the accumulated error which is certainly wrong now.
if self.accumulated_error < 0:
self.accumulated_error = 0
# Discussion #384. Finally don't reset the accumulated error but smoothly reset it if the sign is inversed
# if self.accumulated_error < 0:
# self.accumulated_error = 0
def calculate_regulated_temperature(
self, room_temp: float, external_temp: float
@@ -71,6 +71,11 @@ class PITemperatureRegulator:
error = self.target_temp - room_temp
# Calculate the sum of error (I)
# Discussion #384. Finally don't reset the accumulated error but smoothly reset it if the sign is inversed
# If the error have change its sign, reset smoothly the accumulated error
if error * self.accumulated_error < 0:
self.accumulated_error = self.accumulated_error / 2.0
self.accumulated_error += error
# Capping of the error
@@ -91,8 +96,7 @@ class PITemperatureRegulator:
result = round(self.target_temp + total_offset, 1)
# TODO Change to debug after experimental
_LOGGER.info(
_LOGGER.debug(
"PITemperatureRegulator - Error: %.2f accumulated_error: %.2f offset: %.2f offset_ext: %.2f target_tem: %.1f regulatedTemp: %.1f",
error,
self.accumulated_error,
@@ -214,15 +214,12 @@ class ThermostatOverClimate(BaseThermostat):
)
)
):
offset_temp = self.current_temperature - device_temp
offset_temp = device_temp - self.current_temperature
if self.hvac_mode == HVACMode.COOL:
target_temp = self.regulated_target_temp - offset_temp
else:
target_temp = self.regulated_target_temp + offset_temp
target_temp = self.regulated_target_temp + offset_temp
_LOGGER.debug(
"%s - the device offset temp for regulation is %.2f - internal temp is %.2f. Nes target is %.2f",
"%s - The device offset temp for regulation is %.2f - internal temp is %.2f. New target is %.2f",
self,
offset_temp,
device_temp,
+7 -8
View File
@@ -127,9 +127,7 @@ async def test_over_climate_regulation(
# the regulated temperature should be under
assert entity.regulated_target_temp < entity.target_temperature
assert (
entity.regulated_target_temp == 18 - 2
) # normally 0.6 but round_to_nearest gives 0.5
assert entity.regulated_target_temp == 18 - 2.5
@pytest.mark.parametrize("expected_lingering_tasks", [True])
@@ -473,10 +471,11 @@ async def test_over_climate_regulation_use_device_temp(
)
# 3. change temperature so that the regulated temperature should slow down
# HVACMODE.HEAT
# room temp is 15
# target is 18
# internal heater temp is 13
fake_underlying_climate.set_current_temperature(13)
# internal heater temp is 20
fake_underlying_climate.set_current_temperature(20)
await entity.async_set_temperature(temperature=18)
await send_ext_temperature_change_event(entity, 9, event_timestamp)
@@ -498,7 +497,7 @@ async def test_over_climate_regulation_use_device_temp(
"set_temperature",
{
"entity_id": "climate.mock_climate",
"temperature": 21.4, # 19.4 + 2
"temperature": 24.4, # 19.4 + 5
"target_temp_high": 30,
"target_temp_low": 15,
},
@@ -524,7 +523,7 @@ async def test_over_climate_regulation_use_device_temp(
# the regulated temperature should be upper (device offset is +2)
assert entity.regulated_target_temp < entity.target_temperature
assert entity.regulated_target_temp == 22.9
assert entity.regulated_target_temp == 22.4
mock_service_call.assert_has_calls(
[
@@ -533,7 +532,7 @@ async def test_over_climate_regulation_use_device_temp(
"set_temperature",
{
"entity_id": "climate.mock_climate",
"temperature": 24.9, # 22.9 + 2° of offset
"temperature": 24.4, # 22.4 + 2° of offset
"target_temp_high": 30,
"target_temp_low": 15,
},