Compare commits

..

4 Commits

Author SHA1 Message Date
Jean-Marc Collin 668053b352 Fix unit_test 2024-10-07 05:22:57 +00:00
Jean-Marc Collin 6ff9ff1ee5 Fix variables in error log 2024-10-07 04:52:33 +00:00
Jean-Marc Collin 3f95ed74f4 FIX TypeError: '>' not supported between instances of 'float' and 'NoneType' error message 2024-10-06 09:04:47 +00:00
Jean-Marc Collin 6e42904ddf Issue #518 - Fix ThermostatOverClimate object has no attribute __attr_preset_modes 2024-10-06 08:58:58 +00:00
3 changed files with 32 additions and 19 deletions
@@ -13,7 +13,6 @@ from homeassistant.util import dt as dt_util
from homeassistant.core import (
HomeAssistant,
callback,
CoreState,
Event,
State,
)
@@ -57,7 +56,6 @@ from homeassistant.const import (
STATE_UNKNOWN,
STATE_OFF,
STATE_ON,
EVENT_HOMEASSISTANT_START,
STATE_HOME,
STATE_NOT_HOME,
)
@@ -299,7 +297,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
self._presets: dict[str, Any] = {} # presets
self._presets_away: dict[str, Any] = {} # presets_away
self._attr_preset_modes: list[str] | None
self._attr_preset_modes: list[str] = []
self._use_central_config_temperature = False
@@ -2183,7 +2181,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
new_central_mode,
)
first_init = self._last_central_mode == None
first_init = self._last_central_mode is None
self._last_central_mode = new_central_mode
@@ -142,7 +142,17 @@ class ThermostatOverClimate(BaseThermostat[UnderlyingClimate]):
"""Sends the regulated temperature to all underlying"""
if self.hvac_mode == HVACMode.OFF:
_LOGGER.debug("%s - don't send regulated temperature cause VTherm is off ")
_LOGGER.debug(
"%s - don't send regulated temperature cause VTherm is off ", self
)
return
if self.target_temperature is None:
_LOGGER.warning(
"%s - don't send regulated temperature cause VTherm target_temp (%s) is None. This should be a temporary warning message.",
self,
self.target_temperature,
)
return
_LOGGER.info(
@@ -169,16 +179,17 @@ class ThermostatOverClimate(BaseThermostat[UnderlyingClimate]):
# use _attr_target_temperature_step to round value if _auto_regulation_dtemp is equal to 0
regulation_step = self._auto_regulation_dtemp if self._auto_regulation_dtemp else self._attr_target_temperature_step
_LOGGER.debug("%s - usage of regulation_step: %.2f ",
self,
regulation_step)
new_regulated_temp = round_to_nearest(
self._regulation_algo.calculate_regulated_temperature(
self.current_temperature, self._cur_ext_temp
),
regulation_step,
)
_LOGGER.debug("%s - usage regulation_step: %.2f ", self, regulation_step)
if self.current_temperature is not None:
new_regulated_temp = round_to_nearest(
self._regulation_algo.calculate_regulated_temperature(
self.current_temperature, self._cur_ext_temp
),
regulation_step,
)
else:
new_regulated_temp = self.target_temperature
dtemp = new_regulated_temp - self._regulated_target_temp
if not force and abs(dtemp) < self._auto_regulation_dtemp:
@@ -203,8 +214,10 @@ class ThermostatOverClimate(BaseThermostat[UnderlyingClimate]):
offset_temp = 0
device_temp = 0
if (
# current_temperature is set
self.current_temperature is not None
# regulation can use the device_temp
self.auto_regulation_use_device_temp
and 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)
+5 -3
View File
@@ -12,12 +12,14 @@ from homeassistant.components.climate import (
SERVICE_SET_TEMPERATURE,
)
from homeassistant.config_entries import SOURCE_USER, ConfigEntry
from homeassistant.data_entry_flow import FlowResultType
from custom_components.versatile_thermostat.config_flow import (
VersatileThermostatBaseConfigFlow,
)
from custom_components.versatile_thermostat.thermostat_valve import ThermostatOverValve
from custom_components.versatile_thermostat.thermostat_switch import (
ThermostatOverSwitch,
)
from .commons import *
logging.getLogger().setLevel(logging.DEBUG)