From 3219fd293ed5cec76df850ef97b3810e4d1e7a2e Mon Sep 17 00:00:00 2001 From: Jean-Marc Collin Date: Sun, 27 Oct 2024 10:42:30 +0000 Subject: [PATCH] With config flow ok --- .../versatile_thermostat/config_flow.py | 19 ++++++++++++++----- .../versatile_thermostat/const.py | 8 ++++---- .../versatile_thermostat/strings.json | 8 ++++---- .../versatile_thermostat/translations/en.json | 8 ++++---- .../versatile_thermostat/translations/fr.json | 8 ++++---- 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/custom_components/versatile_thermostat/config_flow.py b/custom_components/versatile_thermostat/config_flow.py index 60664a8..ae46080 100644 --- a/custom_components/versatile_thermostat/config_flow.py +++ b/custom_components/versatile_thermostat/config_flow.py @@ -128,6 +128,11 @@ class VersatileThermostatBaseConfigFlow(FlowHandler): and self._infos.get(CONF_CENTRAL_BOILER_DEACTIVATION_SRV) is not None ) + self._infos[CONF_USE_AUTO_START_STOP_FEATURE] = ( + self._infos.get(CONF_USE_AUTO_START_STOP_FEATURE) is True + and self._infos.get(CONF_THERMOSTAT_TYPE) == CONF_THERMOSTAT_CLIMATE + ) + def _init_central_config_flags(self, infos): """Initialisation of central configuration flags""" is_empty: bool = not bool(infos) @@ -413,11 +418,6 @@ class VersatileThermostatBaseConfigFlow(FlowHandler): ]: menu_options.append("presets") - if self._infos[CONF_THERMOSTAT_TYPE] in [ - CONF_THERMOSTAT_CLIMATE, - ]: - menu_options.append("auto_start_stop") - if ( is_central_config and self._infos.get(CONF_USE_CENTRAL_BOILER_FEATURE) is True @@ -436,6 +436,13 @@ class VersatileThermostatBaseConfigFlow(FlowHandler): if self._infos[CONF_USE_PRESENCE_FEATURE] is True: menu_options.append("presence") + if self._infos.get(CONF_USE_AUTO_START_STOP_FEATURE) is True and self._infos[ + CONF_THERMOSTAT_TYPE + ] in [ + CONF_THERMOSTAT_CLIMATE, + ]: + menu_options.append("auto_start_stop") + menu_options.append("advanced") if self.check_config_complete(self._infos): @@ -886,6 +893,8 @@ class VersatileThermostatOptionsFlowHandler( if not self._infos[CONF_USE_CENTRAL_BOILER_FEATURE]: self._infos[CONF_CENTRAL_BOILER_ACTIVATION_SRV] = None self._infos[CONF_CENTRAL_BOILER_DEACTIVATION_SRV] = None + if not self._infos[CONF_USE_AUTO_START_STOP_FEATURE]: + self._infos[CONF_AUTO_START_STOP_LEVEL] = AUTO_START_STOP_LEVEL_NONE _LOGGER.info( "Recreating entry %s due to configuration change. New config is now: %s", diff --git a/custom_components/versatile_thermostat/const.py b/custom_components/versatile_thermostat/const.py index f9d9784..4935c0e 100644 --- a/custom_components/versatile_thermostat/const.py +++ b/custom_components/versatile_thermostat/const.py @@ -147,10 +147,10 @@ CONF_USED_BY_CENTRAL_BOILER = "used_by_controls_central_boiler" CONF_WINDOW_ACTION = "window_action" CONF_AUTO_START_STOP_LEVEL = "auto_start_stop_level" -AUTO_START_STOP_LEVEL_NONE = "none" -AUTO_START_STOP_LEVEL_SLOW = "slow" -AUTO_START_STOP_LEVEL_MEDIUM = "medium" -AUTO_START_STOP_LEVEL_FAST = "fast" +AUTO_START_STOP_LEVEL_NONE = "auto_start_stop_none" +AUTO_START_STOP_LEVEL_SLOW = "auto_start_stop_slow" +AUTO_START_STOP_LEVEL_MEDIUM = "auto_start_stop_medium" +AUTO_START_STOP_LEVEL_FAST = "auto_start_stop_fast" CONF_AUTO_START_STOP_LEVELS = [ AUTO_START_STOP_LEVEL_NONE, AUTO_START_STOP_LEVEL_SLOW, diff --git a/custom_components/versatile_thermostat/strings.json b/custom_components/versatile_thermostat/strings.json index 3d015b2..b72d6a1 100644 --- a/custom_components/versatile_thermostat/strings.json +++ b/custom_components/versatile_thermostat/strings.json @@ -521,10 +521,10 @@ }, "auto_start_stop": { "options": { - "none": "No auto start/stop", - "slow": "Slow detection", - "medium": "Medium detection", - "fast": "Fast detection" + "auto_start_stop_none": "No auto start/stop", + "auto_start_stop_slow": "Slow detection", + "auto_start_stop_medium": "Medium detection", + "auto_start_stop_fast": "Fast detection" } } }, diff --git a/custom_components/versatile_thermostat/translations/en.json b/custom_components/versatile_thermostat/translations/en.json index 3d015b2..b72d6a1 100644 --- a/custom_components/versatile_thermostat/translations/en.json +++ b/custom_components/versatile_thermostat/translations/en.json @@ -521,10 +521,10 @@ }, "auto_start_stop": { "options": { - "none": "No auto start/stop", - "slow": "Slow detection", - "medium": "Medium detection", - "fast": "Fast detection" + "auto_start_stop_none": "No auto start/stop", + "auto_start_stop_slow": "Slow detection", + "auto_start_stop_medium": "Medium detection", + "auto_start_stop_fast": "Fast detection" } } }, diff --git a/custom_components/versatile_thermostat/translations/fr.json b/custom_components/versatile_thermostat/translations/fr.json index dae2483..eadb5a5 100644 --- a/custom_components/versatile_thermostat/translations/fr.json +++ b/custom_components/versatile_thermostat/translations/fr.json @@ -539,10 +539,10 @@ }, "auto_start_stop": { "options": { - "none": "No auto start/stop", - "slow": "Slow detection", - "medium": "Medium detection", - "fast": "Fast detection" + "auto_start_stop_none": "No auto start/stop", + "auto_start_stop_slow": "Slow detection", + "auto_start_stop_medium": "Medium detection", + "auto_start_stop_fast": "Fast detection" } } },