From 685911a9aa4b0df71352317ff2f08c51099b7fae Mon Sep 17 00:00:00 2001 From: Jean-Marc Collin Date: Tue, 16 Jan 2024 18:30:52 +0000 Subject: [PATCH] Issue #343 - disable safety mode for outdoor thermometer --- .devcontainer/configuration.yaml | 2 ++ README-fr.md | 11 ++++++++++- README.md | 11 ++++++++++- custom_components/versatile_thermostat/__init__.py | 6 ++++++ .../versatile_thermostat/base_thermostat.py | 13 ++++++++----- custom_components/versatile_thermostat/const.py | 5 ++++- .../versatile_thermostat/underlyings.py | 2 +- .../versatile_thermostat/vtherm_api.py | 13 ++++++++++++- 8 files changed, 53 insertions(+), 10 deletions(-) diff --git a/.devcontainer/configuration.yaml b/.devcontainer/configuration.yaml index 52cc5e0..74cb9c7 100644 --- a/.devcontainer/configuration.yaml +++ b/.devcontainer/configuration.yaml @@ -28,6 +28,8 @@ versatile_thermostat: max_alpha: 0.6 halflife_sec: 301 precision: 3 + safety_mode: + check_outdoor_sensor: false input_number: fake_temperature_sensor1: diff --git a/README-fr.md b/README-fr.md index ca6c17d..1d03ffc 100644 --- a/README-fr.md +++ b/README-fr.md @@ -84,7 +84,7 @@ Ce composant personnalisé pour Home Assistant est une mise à niveau et est une > ![Nouveau](https://github.com/jmcollin78/versatile_thermostat/blob/main/images/new-icon.png?raw=true) _*Nouveautés*_ -> * **Release 5.3** : Ajout d'une fonction de pilotage d'une chaudière centrale [#234](https://github.com/jmcollin78/versatile_thermostat/issues/234). Plus d'infos ici: [Le contrôle d'une chaudière centrale](#le-contrôle-dune-chaudière-centrale), +> * **Release 5.3** : Ajout d'une fonction de pilotage d'une chaudière centrale [#234](https://github.com/jmcollin78/versatile_thermostat/issues/234) - plus d'infos ici: [Le contrôle d'une chaudière centrale](#le-contrôle-dune-chaudière-centrale). Ajout de la possibilité de désactiver le mode sécurité pour le thermomètre extérieur [#343](https://github.com/jmcollin78/versatile_thermostat/issues/343) > * **Release 5.2** : Ajout d'un `central_mode` permettant de piloter tous les VTherms de façon centralisée [#158](https://github.com/jmcollin78/versatile_thermostat/issues/158). > * **Release 5.1** : Limitation des valeurs envoyées aux valves et au température envoyées au climate sous-jacent. > * **Release 5.0** : Ajout d'une configuration centrale permettant de mettre en commun les attributs qui peuvent l'être [#239](https://github.com/jmcollin78/versatile_thermostat/issues/239). @@ -533,6 +533,15 @@ Mettre ce paramètre à ``0.00`` déclenchera le préréglage sécurité quelque Le quatrième param§tre (``security_default_on_percent``) est la valeur de ``on_percent`` qui sera utilisée lorsque le thermostat passe en mode ``security``. Si vous mettez ``0`` alors le thermostat sera coupé lorsqu'il passe en mode ``security``, mettre 0,2% par exemple permet de garder un peu de chauffage (20% dans ce cas), même en mode ``security``. Ca évite de retrouver son logement totalement gelé lors d'une panne de thermomètre. +Depuis la version 5.3 il est possible de désactiver la mise en sécurité suite à une absence de données du thermomètre extérieure. En effet, celui-ci ayant la plupart du temps un impact faible sur la régulation (dépendant de votre paramètrage), il est possible qu'il soit absent sans mettre en danger le logement. Pour cela, il faut ajouter les lignes suivantes dans votre `configuration.yaml` : +``` +versatile_thermostat: +... + safety_mode: + check_outdoor_sensor: false +``` +Par défaut, le thermomètre extérieur peut déclencher une mise en sécurité si il n'envoit plus de valeur. + Voir [exemple de réglages](#examples-tuning) pour avoir des exemples de réglage communs > ![Astuce](https://github.com/jmcollin78/versatile_thermostat/blob/main/images/tips.png?raw=true) _*Notes*_ diff --git a/README.md b/README.md index b57c53f..9d366da 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ This custom component for Home Assistant is an upgrade and is a complete rewrite of the component "Awesome thermostat" (see [Github](https://github.com/dadge/awesome_thermostat)) with addition of features. >![New](https://github.com/jmcollin78/versatile_thermostat/blob/main/images/new-icon.png?raw=true) _*News*_ -> * **Release 5.3**: Added a central boiler control function [#234](https://github.com/jmcollin78/versatile_thermostat/issues/234). More information here: [Controlling a central boiler](#controlling-a-central-boiler), +> * **Release 5.3**: Added a central boiler control function [#234](https://github.com/jmcollin78/versatile_thermostat/issues/234) - more information here: [Controlling a central boiler](#controlling-a-central-boiler). Added the ability to disable security mode for outdoor thermometer [#343](https://github.com/jmcollin78/versatile_thermostat/issues/343) > * **Release 5.2**: Added a `central_mode` allowing all VTherms to be controlled centrally [#158](https://github.com/jmcollin78/versatile_thermostat/issues/158). > * **Release 5.1**: Limitation of the values sent to the valves and the temperature sent to the underlying climate. > * **Release 5.0**: Added a central configuration allowing the sharing of attributes that can be shared [#239](https://github.com/jmcollin78/versatile_thermostat/issues/239). @@ -519,6 +519,15 @@ Setting this parameter to ``0.00`` will trigger the safety preset regardless of The fourth parameter (``security_default_on_percent``) is the ``on_percent`` value that will be used when the thermostat enters ``safety`` mode. If you put ``0`` then the thermostat will be cut off when it goes into ``safety`` mode, putting 0.2% for example allows you to keep a little heating (20% in this case), even in mode ``safety``. It avoids finding your home totally frozen during a thermometer failure. +Since version 5.3 it is possible to deactivate the safety device following a lack of data from the outdoor thermometer. Indeed, this most of the time having a low impact on regulation (depending on your settings), it is possible that it is absent without endangering the home. To do this, you must add the following lines to your `configuration.yaml`: +``` +versatile_thermostat: +... + safety_mode: + check_outdoor_sensor: false +``` +By default, the outdoor thermometer can trigger a trip if it no longer sends a value. + See [example tuning](#examples-tuning) for common tuning examples >![Tip](https://github.com/jmcollin78/versatile_thermostat/blob/main/images/tips.png?raw=true) _*Notes*_ diff --git a/custom_components/versatile_thermostat/__init__.py b/custom_components/versatile_thermostat/__init__.py index b0f4d79..733e895 100644 --- a/custom_components/versatile_thermostat/__init__.py +++ b/custom_components/versatile_thermostat/__init__.py @@ -24,6 +24,7 @@ from .const import ( CONF_AUTO_REGULATION_SLOW, CONF_AUTO_REGULATION_EXPERT, CONF_SHORT_EMA_PARAMS, + CONF_SAFETY_MODE, CONF_THERMOSTAT_CENTRAL_CONFIG, CONF_THERMOSTAT_TYPE, ) @@ -47,12 +48,17 @@ EMA_PARAM_SCHEMA = { vol.Required("precision"): cv.positive_int, } +SAFETY_MODE_PARAM_SCHEMA = { + vol.Required("check_outdoor_sensor"): bool, +} + CONFIG_SCHEMA = vol.Schema( { DOMAIN: vol.Schema( { CONF_AUTO_REGULATION_EXPERT: vol.Schema(SELF_REGULATION_PARAM_SCHEMA), CONF_SHORT_EMA_PARAMS: vol.Schema(EMA_PARAM_SCHEMA), + CONF_SAFETY_MODE: vol.Schema(SAFETY_MODE_PARAM_SCHEMA), } ), }, diff --git a/custom_components/versatile_thermostat/base_thermostat.py b/custom_components/versatile_thermostat/base_thermostat.py index 6a65c40..6d79628 100644 --- a/custom_components/versatile_thermostat/base_thermostat.py +++ b/custom_components/versatile_thermostat/base_thermostat.py @@ -1657,7 +1657,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity): # try to restart if we were in safety mode if self._security_state: - await self.check_security() + await self.check_safety() # check window_auto return await self._async_manage_window_auto() @@ -1684,7 +1684,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity): # try to restart if we were in safety mode if self._security_state: - await self.check_security() + await self.check_safety() except ValueError as ex: _LOGGER.error("Unable to update external temperature from sensor: %s", ex) @@ -2122,7 +2122,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity): """Get now. The local datetime or the overloaded _set_now date""" return self._now if self._now is not None else datetime.now(self._current_tz) - async def check_security(self) -> bool: + async def check_safety(self) -> bool: """Check if last temperature date is too long""" now = self.now delta_temp = ( @@ -2134,9 +2134,12 @@ class BaseThermostat(ClimateEntity, RestoreEntity): mode_cond = self._hvac_mode != HVACMode.OFF + api:VersatileThermostatAPI = VersatileThermostatAPI.get_vtherm_api() + is_outdoor_checked = not api.safety_mode or api.safety_mode.get('check_outdoor_sensor') != False + temp_cond: bool = ( delta_temp > self._security_delay_min - or delta_ext_temp > self._security_delay_min + or (is_outdoor_checked and delta_ext_temp > self._security_delay_min) ) climate_cond: bool = self.is_over_climate and self.hvac_action not in [ HVACAction.COOLING, @@ -2307,7 +2310,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity): _LOGGER.debug("%s - End of cycle (overpowering)", self) return True - security: bool = await self.check_security() + security: bool = await self.check_safety() if security and self.is_over_climate: _LOGGER.debug("%s - End of cycle (security and over climate)", self) return True diff --git a/custom_components/versatile_thermostat/const.py b/custom_components/versatile_thermostat/const.py index 26c1d5b..00cb671 100644 --- a/custom_components/versatile_thermostat/const.py +++ b/custom_components/versatile_thermostat/const.py @@ -105,7 +105,6 @@ CONF_AUTO_REGULATION_EXPERT = "auto_regulation_expert" CONF_AUTO_REGULATION_DTEMP = "auto_regulation_dtemp" CONF_AUTO_REGULATION_PERIOD_MIN = "auto_regulation_periode_min" CONF_INVERSE_SWITCH = "inverse_switch_command" -CONF_SHORT_EMA_PARAMS = "short_ema_params" CONF_AUTO_FAN_MODE = "auto_fan_mode" CONF_AUTO_FAN_NONE = "auto_fan_none" CONF_AUTO_FAN_LOW = "auto_fan_low" @@ -113,6 +112,10 @@ CONF_AUTO_FAN_MEDIUM = "auto_fan_medium" CONF_AUTO_FAN_HIGH = "auto_fan_high" CONF_AUTO_FAN_TURBO = "auto_fan_turbo" +# Global params into configuration.yaml +CONF_SHORT_EMA_PARAMS = "short_ema_params" +CONF_SAFETY_MODE = "safety_mode" + CONF_USE_MAIN_CENTRAL_CONFIG = "use_main_central_config" CONF_USE_TPI_CENTRAL_CONFIG = "use_tpi_central_config" CONF_USE_WINDOW_CENTRAL_CONFIG = "use_window_central_config" diff --git a/custom_components/versatile_thermostat/underlyings.py b/custom_components/versatile_thermostat/underlyings.py index f87d9ac..eb2a61f 100644 --- a/custom_components/versatile_thermostat/underlyings.py +++ b/custom_components/versatile_thermostat/underlyings.py @@ -356,7 +356,7 @@ class UnderlyingSwitch(UnderlyingEntity): _LOGGER.debug("%s - End of cycle (3)", self) return # safety mode could have change the on_time percent - await self._thermostat.check_security() + await self._thermostat.check_safety() time = self._on_time_sec action_label = "start" diff --git a/custom_components/versatile_thermostat/vtherm_api.py b/custom_components/versatile_thermostat/vtherm_api.py index 76e5203..cd1fed9 100644 --- a/custom_components/versatile_thermostat/vtherm_api.py +++ b/custom_components/versatile_thermostat/vtherm_api.py @@ -7,6 +7,7 @@ from .const import ( DOMAIN, CONF_AUTO_REGULATION_EXPERT, CONF_SHORT_EMA_PARAMS, + CONF_SAFETY_MODE, CONF_THERMOSTAT_TYPE, CONF_THERMOSTAT_CENTRAL_CONFIG, ) @@ -46,6 +47,7 @@ class VersatileThermostatAPI(dict): super().__init__() self._expert_params = None self._short_ema_params = None + self._safety_mode = None self._central_boiler_entity = None def find_central_configuration(self): @@ -88,6 +90,10 @@ class VersatileThermostatAPI(dict): if self._short_ema_params: _LOGGER.debug("We have found short ema params %s", self._short_ema_params) + self._safety_mode = config.get(CONF_SAFETY_MODE) + if self._safety_mode: + _LOGGER.debug("We have found safet_mode params %s", self._safety_mode) + def register_central_boiler(self, central_boiler_entity): """Register the central boiler entity. This is used by the CentralBoilerBinarySensor class to register itself at creation""" @@ -105,9 +111,14 @@ class VersatileThermostatAPI(dict): @property def short_ema_params(self): - """Get the self regulation params""" + """Get the short EMA params in expert mode""" return self._short_ema_params + @property + def safety_mode(self): + """Get the safety_mode params""" + return self._safety_mode + @property def hass(self): """Get the HomeAssistant object"""