Co-authored-by: Jean-Marc Collin <jean-marc.collin-extern@renault.com>
This commit is contained in:
@@ -3,10 +3,12 @@ default_config:
|
|||||||
logger:
|
logger:
|
||||||
default: warning
|
default: warning
|
||||||
logs:
|
logs:
|
||||||
custom_components.versatile_thermostat: info
|
custom_components.versatile_thermostat: debug
|
||||||
custom_components.versatile_thermostat.underlyings: info
|
# custom_components.versatile_thermostat.underlyings: info
|
||||||
custom_components.versatile_thermostat.climate: info
|
# custom_components.versatile_thermostat.climate: info
|
||||||
custom_components.versatile_thermostat.base_thermostat: debug
|
# custom_components.versatile_thermostat.base_thermostat: debug
|
||||||
|
custom_components.versatile_thermostat.sensor: info
|
||||||
|
custom_components.versatile_thermostat.binary_sensor: info
|
||||||
|
|
||||||
# If you need to debug uncommment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
|
# If you need to debug uncommment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
|
||||||
debugpy:
|
debugpy:
|
||||||
@@ -175,7 +177,7 @@ input_datetime:
|
|||||||
has_time: true
|
has_time: true
|
||||||
|
|
||||||
recorder:
|
recorder:
|
||||||
commit_interval: 1
|
commit_interval: 0
|
||||||
include:
|
include:
|
||||||
domains:
|
domains:
|
||||||
- input_boolean
|
- input_boolean
|
||||||
@@ -184,6 +186,9 @@ recorder:
|
|||||||
- climate
|
- climate
|
||||||
- sensor
|
- sensor
|
||||||
- binary_sensor
|
- binary_sensor
|
||||||
|
- number
|
||||||
|
- input_select
|
||||||
|
- versatile_thermostat
|
||||||
|
|
||||||
template:
|
template:
|
||||||
- binary_sensor:
|
- binary_sensor:
|
||||||
|
|||||||
@@ -2302,12 +2302,12 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
|
|||||||
self._security_state = True
|
self._security_state = True
|
||||||
self.save_hvac_mode()
|
self.save_hvac_mode()
|
||||||
self.save_preset_mode()
|
self.save_preset_mode()
|
||||||
|
if self._prop_algorithm:
|
||||||
|
self._prop_algorithm.set_security(self._security_default_on_percent)
|
||||||
await self._async_set_preset_mode_internal(PRESET_SECURITY)
|
await self._async_set_preset_mode_internal(PRESET_SECURITY)
|
||||||
# Turn off the underlying climate or heater if security default on_percent is 0
|
# Turn off the underlying climate or heater if security default on_percent is 0
|
||||||
if self.is_over_climate or self._security_default_on_percent <= 0.0:
|
if self.is_over_climate or self._security_default_on_percent <= 0.0:
|
||||||
await self.async_set_hvac_mode(HVACMode.OFF, False)
|
await self.async_set_hvac_mode(HVACMode.OFF, False)
|
||||||
if self._prop_algorithm:
|
|
||||||
self._prop_algorithm.set_security(self._security_default_on_percent)
|
|
||||||
|
|
||||||
self.send_event(
|
self.send_event(
|
||||||
EventType.SECURITY_EVENT,
|
EventType.SECURITY_EVENT,
|
||||||
@@ -2334,12 +2334,12 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
|
|||||||
self._saved_preset_mode,
|
self._saved_preset_mode,
|
||||||
)
|
)
|
||||||
self._security_state = False
|
self._security_state = False
|
||||||
|
if self._prop_algorithm:
|
||||||
|
self._prop_algorithm.unset_security()
|
||||||
# Restore hvac_mode if previously saved
|
# Restore hvac_mode if previously saved
|
||||||
if self.is_over_climate or self._security_default_on_percent <= 0.0:
|
if self.is_over_climate or self._security_default_on_percent <= 0.0:
|
||||||
await self.restore_hvac_mode(False)
|
await self.restore_hvac_mode(False)
|
||||||
await self.restore_preset_mode()
|
await self.restore_preset_mode()
|
||||||
if self._prop_algorithm:
|
|
||||||
self._prop_algorithm.unset_security()
|
|
||||||
self.send_event(
|
self.send_event(
|
||||||
EventType.SECURITY_EVENT,
|
EventType.SECURITY_EVENT,
|
||||||
{
|
{
|
||||||
@@ -2569,7 +2569,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
|
|||||||
"""update the entity if the config entry have been updated
|
"""update the entity if the config entry have been updated
|
||||||
Note: this don't work either
|
Note: this don't work either
|
||||||
"""
|
"""
|
||||||
_LOGGER.info("%s - The config entry have been updated")
|
_LOGGER.info("%s - The config entry have been updated", self)
|
||||||
|
|
||||||
async def service_set_presence(self, presence: str):
|
async def service_set_presence(self, presence: str):
|
||||||
"""Called by a service call:
|
"""Called by a service call:
|
||||||
|
|||||||
@@ -24,16 +24,19 @@ class PropAlgorithm:
|
|||||||
tpi_coef_ext,
|
tpi_coef_ext,
|
||||||
cycle_min: int,
|
cycle_min: int,
|
||||||
minimal_activation_delay: int,
|
minimal_activation_delay: int,
|
||||||
|
vtherm_entity_id: str = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialisation of the Proportional Algorithm"""
|
"""Initialisation of the Proportional Algorithm"""
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Creation new PropAlgorithm function_type: %s, tpi_coef_int: %s, tpi_coef_ext: %s, cycle_min:%d, minimal_activation_delay:%d", # pylint: disable=line-too-long
|
"%s - Creation new PropAlgorithm function_type: %s, tpi_coef_int: %s, tpi_coef_ext: %s, cycle_min:%d, minimal_activation_delay:%d", # pylint: disable=line-too-long
|
||||||
|
vtherm_entity_id,
|
||||||
function_type,
|
function_type,
|
||||||
tpi_coef_int,
|
tpi_coef_int,
|
||||||
tpi_coef_ext,
|
tpi_coef_ext,
|
||||||
cycle_min,
|
cycle_min,
|
||||||
minimal_activation_delay,
|
minimal_activation_delay,
|
||||||
)
|
)
|
||||||
|
self._vtherm_entity_id = vtherm_entity_id
|
||||||
self._function = function_type
|
self._function = function_type
|
||||||
self._tpi_coef_int = tpi_coef_int
|
self._tpi_coef_int = tpi_coef_int
|
||||||
self._tpi_coef_ext = tpi_coef_ext
|
self._tpi_coef_ext = tpi_coef_ext
|
||||||
@@ -57,7 +60,10 @@ class PropAlgorithm:
|
|||||||
if target_temp is None or current_temp is None:
|
if target_temp is None or current_temp is None:
|
||||||
log = _LOGGER.debug if hvac_mode == HVACMode.OFF else _LOGGER.warning
|
log = _LOGGER.debug if hvac_mode == HVACMode.OFF else _LOGGER.warning
|
||||||
log(
|
log(
|
||||||
"Proportional algorithm: calculation is not possible cause target_temp or current_temp is null. Heating/cooling will be disabled" # pylint: disable=line-too-long
|
"%s - Proportional algorithm: calculation is not possible cause target_temp (%s) or current_temp (%s) is null. Heating/cooling will be disabled. This could be normal at startup", # pylint: disable=line-too-long
|
||||||
|
self._vtherm_entity_id,
|
||||||
|
target_temp,
|
||||||
|
current_temp,
|
||||||
)
|
)
|
||||||
self._calculated_on_percent = 0
|
self._calculated_on_percent = 0
|
||||||
else:
|
else:
|
||||||
@@ -83,7 +89,8 @@ class PropAlgorithm:
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Proportional algorithm: unknown %s function. Heating will be disabled",
|
"%s - Proportional algorithm: unknown %s function. Heating will be disabled",
|
||||||
|
self._vtherm_entity_id,
|
||||||
self._function,
|
self._function,
|
||||||
)
|
)
|
||||||
self._calculated_on_percent = 0
|
self._calculated_on_percent = 0
|
||||||
@@ -91,7 +98,8 @@ class PropAlgorithm:
|
|||||||
self._calculate_internal()
|
self._calculate_internal()
|
||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"heating percent calculated for current_temp %.1f, ext_current_temp %.1f and target_temp %.1f is %.2f, on_time is %d (sec), off_time is %d (sec)", # pylint: disable=line-too-long
|
"%s - heating percent calculated for current_temp %.1f, ext_current_temp %.1f and target_temp %.1f is %.2f, on_time is %d (sec), off_time is %d (sec)", # pylint: disable=line-too-long
|
||||||
|
self._vtherm_entity_id,
|
||||||
current_temp if current_temp else -9999.0,
|
current_temp if current_temp else -9999.0,
|
||||||
ext_current_temp if ext_current_temp else -9999.0,
|
ext_current_temp if ext_current_temp else -9999.0,
|
||||||
target_temp if target_temp else -9999.0,
|
target_temp if target_temp else -9999.0,
|
||||||
@@ -110,11 +118,12 @@ class PropAlgorithm:
|
|||||||
self._calculated_on_percent = 0
|
self._calculated_on_percent = 0
|
||||||
|
|
||||||
if self._security:
|
if self._security:
|
||||||
_LOGGER.debug(
|
|
||||||
"Security is On using the default_on_percent %f",
|
|
||||||
self._default_on_percent,
|
|
||||||
)
|
|
||||||
self._on_percent = self._default_on_percent
|
self._on_percent = self._default_on_percent
|
||||||
|
_LOGGER.info(
|
||||||
|
"%s - Security is On using the default_on_percent %f",
|
||||||
|
self._vtherm_entity_id,
|
||||||
|
self._on_percent,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Security is Off using the calculated_on_percent %f",
|
"Security is Off using the calculated_on_percent %f",
|
||||||
@@ -128,13 +137,8 @@ class PropAlgorithm:
|
|||||||
if self._on_time_sec < self._minimal_activation_delay:
|
if self._on_time_sec < self._minimal_activation_delay:
|
||||||
if self._on_time_sec > 0:
|
if self._on_time_sec > 0:
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"No heating period due to heating period too small (%f < %f)",
|
"%s - No heating period due to heating period too small (%f < %f)",
|
||||||
self._on_time_sec,
|
self._vtherm_entity_id,
|
||||||
self._minimal_activation_delay,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
_LOGGER.debug(
|
|
||||||
"No heating period due to heating period too small (%f < %f)",
|
|
||||||
self._on_time_sec,
|
self._on_time_sec,
|
||||||
self._minimal_activation_delay,
|
self._minimal_activation_delay,
|
||||||
)
|
)
|
||||||
@@ -144,12 +148,18 @@ class PropAlgorithm:
|
|||||||
|
|
||||||
def set_security(self, default_on_percent: float):
|
def set_security(self, default_on_percent: float):
|
||||||
"""Set a default value for on_percent (used for safety mode)"""
|
"""Set a default value for on_percent (used for safety mode)"""
|
||||||
|
_LOGGER.info(
|
||||||
|
"%s - Proportional Algo - set security to ON", self._vtherm_entity_id
|
||||||
|
)
|
||||||
self._security = True
|
self._security = True
|
||||||
self._default_on_percent = default_on_percent
|
self._default_on_percent = default_on_percent
|
||||||
self._calculate_internal()
|
self._calculate_internal()
|
||||||
|
|
||||||
def unset_security(self):
|
def unset_security(self):
|
||||||
"""Unset the safety mode"""
|
"""Unset the safety mode"""
|
||||||
|
_LOGGER.info(
|
||||||
|
"%s - Proportional Algo - set security to OFF", self._vtherm_entity_id
|
||||||
|
)
|
||||||
self._security = False
|
self._security = False
|
||||||
self._calculate_internal()
|
self._calculate_internal()
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ class ThermostatOverSwitch(BaseThermostat[UnderlyingSwitch]):
|
|||||||
self._tpi_coef_ext,
|
self._tpi_coef_ext,
|
||||||
self._cycle_min,
|
self._cycle_min,
|
||||||
self._minimal_activation_delay,
|
self._minimal_activation_delay,
|
||||||
|
self.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
lst_switches = [config_entry.get(CONF_HEATER)]
|
lst_switches = [config_entry.get(CONF_HEATER)]
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ class ThermostatOverValve(BaseThermostat[UnderlyingValve]): # pylint: disable=a
|
|||||||
self._tpi_coef_ext,
|
self._tpi_coef_ext,
|
||||||
self._cycle_min,
|
self._cycle_min,
|
||||||
self._minimal_activation_delay,
|
self._minimal_activation_delay,
|
||||||
|
self.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
lst_valves = [config_entry.get(CONF_VALVE)]
|
lst_valves = [config_entry.get(CONF_VALVE)]
|
||||||
|
|||||||
Reference in New Issue
Block a user