Change algo using underlying internal temp
This commit is contained in:
@@ -194,8 +194,45 @@ class ThermostatOverClimate(BaseThermostat):
|
||||
|
||||
self._last_regulation_change = now
|
||||
for under in self._underlyings:
|
||||
# issue 348 - use device temperature if configured as offset
|
||||
offset_temp = 0
|
||||
device_temp = 0
|
||||
if (
|
||||
# regulation can use the device_temp
|
||||
self.auto_regulation_use_device_temp
|
||||
# and we have access to the device temp
|
||||
and (device_temp := under.underlying_current_temperature) is not None
|
||||
# and target is not reach (ie we need regulation)
|
||||
and (
|
||||
(
|
||||
self.hvac_mode == HVACMode.COOL
|
||||
and self.target_temperature < self.current_temperature
|
||||
)
|
||||
or (
|
||||
self.hvac_mode == HVACMode.HEAT
|
||||
and self.target_temperature > self.current_temperature
|
||||
)
|
||||
)
|
||||
):
|
||||
offset_temp = self.current_temperature - device_temp
|
||||
|
||||
if self.hvac_mode == HVACMode.COOL:
|
||||
target_temp = self.regulated_target_temp - offset_temp
|
||||
else:
|
||||
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",
|
||||
self,
|
||||
offset_temp,
|
||||
device_temp,
|
||||
target_temp,
|
||||
)
|
||||
|
||||
await under.set_temperature(
|
||||
self.regulated_target_temp, self._attr_max_temp, self._attr_min_temp
|
||||
target_temp,
|
||||
self._attr_max_temp,
|
||||
self._attr_min_temp,
|
||||
)
|
||||
|
||||
async def _send_auto_fan_mode(self):
|
||||
|
||||
@@ -568,23 +568,9 @@ class UnderlyingClimate(UnderlyingEntity):
|
||||
if not self.is_initialized:
|
||||
return
|
||||
|
||||
# issue 348 - use device temperature if configured as offset
|
||||
offset_temp = 0
|
||||
if self._thermostat.auto_regulation_use_device_temp and hasattr(
|
||||
self._underlying_climate, "current_temperature"
|
||||
):
|
||||
device_temp = self._underlying_climate.current_temperature
|
||||
offset_temp = device_temp - self._thermostat.current_temperature
|
||||
_LOGGER.debug(
|
||||
"%s - the device offset temp for regulation is %.2f - internal temp is %.2f",
|
||||
self,
|
||||
offset_temp,
|
||||
device_temp,
|
||||
)
|
||||
|
||||
data = {
|
||||
ATTR_ENTITY_ID: self._entity_id,
|
||||
"temperature": self.cap_sent_value(temperature + offset_temp),
|
||||
"temperature": self.cap_sent_value(temperature),
|
||||
"target_temp_high": max_temp,
|
||||
"target_temp_low": min_temp,
|
||||
}
|
||||
@@ -686,6 +672,18 @@ class UnderlyingClimate(UnderlyingEntity):
|
||||
return False
|
||||
return self._underlying_climate.is_aux_heat
|
||||
|
||||
@property
|
||||
def underlying_current_temperature(self) -> float | None:
|
||||
"""Get the underlying current_temperature if it exists
|
||||
and if initialized"""
|
||||
if not self.is_initialized:
|
||||
return None
|
||||
|
||||
if not hasattr(self._underlying_climate, "current_temperature"):
|
||||
return None
|
||||
|
||||
return self._underlying_climate.current_temperature
|
||||
|
||||
def turn_aux_heat_on(self) -> None:
|
||||
"""Turn auxiliary heater on."""
|
||||
if not self.is_initialized:
|
||||
|
||||
Reference in New Issue
Block a user