diff --git a/custom_components/versatile_thermostat/base_thermostat.py b/custom_components/versatile_thermostat/base_thermostat.py index e9a0dc7..9e70229 100644 --- a/custom_components/versatile_thermostat/base_thermostat.py +++ b/custom_components/versatile_thermostat/base_thermostat.py @@ -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) diff --git a/custom_components/versatile_thermostat/pi_algorithm.py b/custom_components/versatile_thermostat/pi_algorithm.py index 7edd1a7..89c1027 100644 --- a/custom_components/versatile_thermostat/pi_algorithm.py +++ b/custom_components/versatile_thermostat/pi_algorithm.py @@ -91,8 +91,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, diff --git a/custom_components/versatile_thermostat/thermostat_climate.py b/custom_components/versatile_thermostat/thermostat_climate.py index f5b4776..8189683 100644 --- a/custom_components/versatile_thermostat/thermostat_climate.py +++ b/custom_components/versatile_thermostat/thermostat_climate.py @@ -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, diff --git a/tests/test_auto_regulation.py b/tests/test_auto_regulation.py index bf3ab00..375952a 100644 --- a/tests/test_auto_regulation.py +++ b/tests/test_auto_regulation.py @@ -473,10 +473,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 +499,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, },