From 3356489f9ddd03f9c86d049b7b3166903085b0f9 Mon Sep 17 00:00:00 2001 From: Jean-Marc Collin Date: Sun, 29 Oct 2023 17:11:02 +0000 Subject: [PATCH] Add translations --- .../versatile_thermostat/config_flow.py | 14 +- .../versatile_thermostat/const.py | 10 +- .../versatile_thermostat/strings.json | 18 +- .../thermostat_climate.py | 350 +++++++++--------- .../versatile_thermostat/translations/fr.json | 24 +- .../versatile_thermostat/translations/it.json | 18 +- tests/test_pi.py | 2 +- 7 files changed, 242 insertions(+), 194 deletions(-) diff --git a/custom_components/versatile_thermostat/config_flow.py b/custom_components/versatile_thermostat/config_flow.py index 1987242..306f6e2 100644 --- a/custom_components/versatile_thermostat/config_flow.py +++ b/custom_components/versatile_thermostat/config_flow.py @@ -1,6 +1,4 @@ -# pylint: disable=line-too-long -# pylint: disable=too-many-lines -# pylint: disable=invalid-name +# pylint: disable=line-too-long, too-many-lines, invalid-name """Config flow for Versatile Thermostat integration.""" from __future__ import annotations @@ -101,6 +99,9 @@ from .const import ( CONF_VALVE_2, CONF_VALVE_3, CONF_VALVE_4, + CONF_AUTO_REGULATION_MODES, + CONF_AUTO_REGULATION_MODE, + CONF_AUTO_REGULATION_NONE, UnknownEntity, WindowOpenDetectionMethod, ) @@ -256,6 +257,13 @@ class VersatileThermostatBaseConfigFlow(FlowHandler): selector.EntitySelectorConfig(domain=CLIMATE_DOMAIN), ), vol.Optional(CONF_AC_MODE, default=False): cv.boolean, + vol.Optional( + CONF_AUTO_REGULATION_MODE, default=CONF_AUTO_REGULATION_NONE + ): selector.SelectSelector( + selector.SelectSelectorConfig( + options=CONF_AUTO_REGULATION_MODES, translation_key="auto_regulation_mode" + ) + ), } ) diff --git a/custom_components/versatile_thermostat/const.py b/custom_components/versatile_thermostat/const.py index 202aaf8..ee9f3b3 100644 --- a/custom_components/versatile_thermostat/const.py +++ b/custom_components/versatile_thermostat/const.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long """Constants for the Versatile Thermostat integration.""" from enum import Enum @@ -82,6 +83,11 @@ CONF_VALVE = "valve_entity_id" CONF_VALVE_2 = "valve_entity2_id" CONF_VALVE_3 = "valve_entity3_id" CONF_VALVE_4 = "valve_entity4_id" +CONF_AUTO_REGULATION_MODE= "auto_regulation_mode" +CONF_AUTO_REGULATION_NONE= "auto_regulation_none" +CONF_AUTO_REGULATION_LIGHT= "auto_regulation_light" +CONF_AUTO_REGULATION_MEDIUM= "auto_regulation_medium" +CONF_AUTO_REGULATION_STRONG= "auto_regulation_strong" CONF_PRESETS = { p: f"{p}_temp" @@ -183,7 +189,7 @@ ALL_CONF = ( CONF_VALVE_2, CONF_VALVE_3, CONF_VALVE_4, - + CONF_AUTO_REGULATION_MODE ] + CONF_PRESETS_VALUES + CONF_PRESETS_AWAY_VALUES @@ -195,6 +201,8 @@ CONF_FUNCTIONS = [ PROPORTIONAL_FUNCTION_TPI, ] +CONF_AUTO_REGULATION_MODES = [CONF_AUTO_REGULATION_LIGHT, CONF_AUTO_REGULATION_MEDIUM, CONF_AUTO_REGULATION_STRONG] + CONF_THERMOSTAT_TYPES = [CONF_THERMOSTAT_SWITCH, CONF_THERMOSTAT_CLIMATE, CONF_THERMOSTAT_VALVE] SUPPORT_FLAGS = ClimateEntityFeature.TARGET_TEMPERATURE diff --git a/custom_components/versatile_thermostat/strings.json b/custom_components/versatile_thermostat/strings.json index 0db2ed6..96788ff 100644 --- a/custom_components/versatile_thermostat/strings.json +++ b/custom_components/versatile_thermostat/strings.json @@ -38,7 +38,8 @@ "valve_entity_id": "1rst valve number", "valve_entity2_id": "2nd valve number", "valve_entity3_id": "3rd valve number", - "valve_entity4_id": "4th valve number" + "valve_entity4_id": "4th valve number", + "auto_regulation_mode": "Self-regulation" }, "data_description": { "heater_entity_id": "Mandatory heater entity id", @@ -54,7 +55,8 @@ "valve_entity_id": "1rst valve number entity id", "valve_entity2_id": "2nd valve number entity id", "valve_entity3_id": "3rd valve number entity id", - "valve_entity4_id": "4th valve number entity id" + "valve_entity4_id": "4th valve number entity id", + "auto_regulation_mode": "Auto adjustment of the target temperature" } }, "tpi": { @@ -199,7 +201,8 @@ "valve_entity_id": "1rst valve number", "valve_entity2_id": "2nd valve number", "valve_entity3_id": "3rd valve number", - "valve_entity4_id": "4th valve number" + "valve_entity4_id": "4th valve number", + "auto_regulation_mode": "Self-regulation" }, "data_description": { "heater_entity_id": "Mandatory heater entity id", @@ -215,7 +218,8 @@ "valve_entity_id": "1rst valve number entity id", "valve_entity2_id": "2nd valve number entity id", "valve_entity3_id": "3rd valve number entity id", - "valve_entity4_id": "4th valve number entity id" + "valve_entity4_id": "4th valve number entity id", + "auto_regulation_mode": "Auto adjustment of the target temperature" } }, "tpi": { @@ -329,6 +333,12 @@ "thermostat_over_climate": "Thermostat over a climate", "thermostat_over_valve": "Thermostat over a valve" } + }, + "auto_regulation_mode": { + "auto_regulation_strong": "Strong", + "auto_regulation_medium": "Medium", + "auto_regulation_light": "Light", + "auto_regulation_none": "No auto-regulation" } }, "entity": { diff --git a/custom_components/versatile_thermostat/thermostat_climate.py b/custom_components/versatile_thermostat/thermostat_climate.py index ae669e7..38a1f0d 100644 --- a/custom_components/versatile_thermostat/thermostat_climate.py +++ b/custom_components/versatile_thermostat/thermostat_climate.py @@ -55,180 +55,6 @@ class ThermostatOverClimate(BaseThermostat): return HVACAction.IDLE return HVACAction.OFF - @property - def hvac_modes(self): - """List of available operation modes.""" - if self.underlying_entity(0): - return self.underlying_entity(0).hvac_modes - else: - return super.hvac_modes - - @property - def mean_cycle_power(self) -> float | None: - """Returns the mean power consumption during the cycle""" - return None - - @property - def fan_mode(self) -> str | None: - """Return the fan setting. - - Requires ClimateEntityFeature.FAN_MODE. - """ - if self.underlying_entity(0): - return self.underlying_entity(0).fan_mode - - return None - - @property - def fan_modes(self) -> list[str] | None: - """Return the list of available fan modes. - - Requires ClimateEntityFeature.FAN_MODE. - """ - if self.underlying_entity(0): - return self.underlying_entity(0).fan_modes - - return [] - - @property - def swing_mode(self) -> str | None: - """Return the swing setting. - - Requires ClimateEntityFeature.SWING_MODE. - """ - if self.underlying_entity(0): - return self.underlying_entity(0).swing_mode - - return None - - @property - def swing_modes(self) -> list[str] | None: - """Return the list of available swing modes. - - Requires ClimateEntityFeature.SWING_MODE. - """ - if self.underlying_entity(0): - return self.underlying_entity(0).swing_modes - - return None - - @property - def temperature_unit(self) -> str: - """Return the unit of measurement.""" - if self.underlying_entity(0): - return self.underlying_entity(0).temperature_unit - - return self._unit - - @property - def supported_features(self): - """Return the list of supported features.""" - if self.underlying_entity(0): - return self.underlying_entity(0).supported_features | self._support_flags - - return self._support_flags - - @property - def target_temperature_step(self) -> float | None: - """Return the supported step of target temperature.""" - if self.underlying_entity(0): - return self.underlying_entity(0).target_temperature_step - - return None - - @property - def target_temperature_high(self) -> float | None: - """Return the highbound target temperature we try to reach. - - Requires ClimateEntityFeature.TARGET_TEMPERATURE_RANGE. - """ - if self.underlying_entity(0): - return self.underlying_entity(0).target_temperature_high - - return None - - @property - def target_temperature_low(self) -> float | None: - """Return the lowbound target temperature we try to reach. - - Requires ClimateEntityFeature.TARGET_TEMPERATURE_RANGE. - """ - if self.underlying_entity(0): - return self.underlying_entity(0).target_temperature_low - - return None - - @property - def is_aux_heat(self) -> bool | None: - """Return true if aux heater. - - Requires ClimateEntityFeature.AUX_HEAT. - """ - if self.underlying_entity(0): - return self.underlying_entity(0).is_aux_heat - - return None - - @overrides - def turn_aux_heat_on(self) -> None: - """Turn auxiliary heater on.""" - if self.underlying_entity(0): - return self.underlying_entity(0).turn_aux_heat_on() - - raise NotImplementedError() - - @overrides - async def async_turn_aux_heat_on(self) -> None: - """Turn auxiliary heater on.""" - for under in self._underlyings: - await under.async_turn_aux_heat_on() - - @overrides - def turn_aux_heat_off(self) -> None: - """Turn auxiliary heater off.""" - for under in self._underlyings: - return under.turn_aux_heat_off() - - @overrides - async def async_turn_aux_heat_off(self) -> None: - """Turn auxiliary heater off.""" - for under in self._underlyings: - await under.async_turn_aux_heat_off() - - @overrides - async def async_set_fan_mode(self, fan_mode): - """Set new target fan mode.""" - _LOGGER.info("%s - Set fan mode: %s", self, fan_mode) - if fan_mode is None: - return - - for under in self._underlyings: - await under.set_fan_mode(fan_mode) - self._fan_mode = fan_mode - self.async_write_ha_state() - - @overrides - async def async_set_humidity(self, humidity: int): - """Set new target humidity.""" - _LOGGER.info("%s - Set fan mode: %s", self, humidity) - if humidity is None: - return - for under in self._underlyings: - await under.set_humidity(humidity) - self._humidity = humidity - self.async_write_ha_state() - - @overrides - async def async_set_swing_mode(self, swing_mode): - """Set new target swing operation.""" - _LOGGER.info("%s - Set fan mode: %s", self, swing_mode) - if swing_mode is None: - return - for under in self._underlyings: - await under.set_swing_mode(swing_mode) - self._swing_mode = swing_mode - self.async_write_ha_state() - @overrides async def _async_internal_set_temperature(self, temperature): """Set the target temperature and the target temperature of underlying climate if any""" @@ -259,6 +85,8 @@ class ThermostatOverClimate(BaseThermostat): ) ) + + @overrides async def async_added_to_hass(self): """Run when entity about to be added.""" @@ -523,3 +351,177 @@ class ThermostatOverClimate(BaseThermostat): changes = True await end_climate_changed(changes) + + @property + def hvac_modes(self): + """List of available operation modes.""" + if self.underlying_entity(0): + return self.underlying_entity(0).hvac_modes + else: + return super.hvac_modes + + @property + def mean_cycle_power(self) -> float | None: + """Returns the mean power consumption during the cycle""" + return None + + @property + def fan_mode(self) -> str | None: + """Return the fan setting. + + Requires ClimateEntityFeature.FAN_MODE. + """ + if self.underlying_entity(0): + return self.underlying_entity(0).fan_mode + + return None + + @property + def fan_modes(self) -> list[str] | None: + """Return the list of available fan modes. + + Requires ClimateEntityFeature.FAN_MODE. + """ + if self.underlying_entity(0): + return self.underlying_entity(0).fan_modes + + return [] + + @property + def swing_mode(self) -> str | None: + """Return the swing setting. + + Requires ClimateEntityFeature.SWING_MODE. + """ + if self.underlying_entity(0): + return self.underlying_entity(0).swing_mode + + return None + + @property + def swing_modes(self) -> list[str] | None: + """Return the list of available swing modes. + + Requires ClimateEntityFeature.SWING_MODE. + """ + if self.underlying_entity(0): + return self.underlying_entity(0).swing_modes + + return None + + @property + def temperature_unit(self) -> str: + """Return the unit of measurement.""" + if self.underlying_entity(0): + return self.underlying_entity(0).temperature_unit + + return self._unit + + @property + def supported_features(self): + """Return the list of supported features.""" + if self.underlying_entity(0): + return self.underlying_entity(0).supported_features | self._support_flags + + return self._support_flags + + @property + def target_temperature_step(self) -> float | None: + """Return the supported step of target temperature.""" + if self.underlying_entity(0): + return self.underlying_entity(0).target_temperature_step + + return None + + @property + def target_temperature_high(self) -> float | None: + """Return the highbound target temperature we try to reach. + + Requires ClimateEntityFeature.TARGET_TEMPERATURE_RANGE. + """ + if self.underlying_entity(0): + return self.underlying_entity(0).target_temperature_high + + return None + + @property + def target_temperature_low(self) -> float | None: + """Return the lowbound target temperature we try to reach. + + Requires ClimateEntityFeature.TARGET_TEMPERATURE_RANGE. + """ + if self.underlying_entity(0): + return self.underlying_entity(0).target_temperature_low + + return None + + @property + def is_aux_heat(self) -> bool | None: + """Return true if aux heater. + + Requires ClimateEntityFeature.AUX_HEAT. + """ + if self.underlying_entity(0): + return self.underlying_entity(0).is_aux_heat + + return None + + @overrides + def turn_aux_heat_on(self) -> None: + """Turn auxiliary heater on.""" + if self.underlying_entity(0): + return self.underlying_entity(0).turn_aux_heat_on() + + raise NotImplementedError() + + @overrides + async def async_turn_aux_heat_on(self) -> None: + """Turn auxiliary heater on.""" + for under in self._underlyings: + await under.async_turn_aux_heat_on() + + @overrides + def turn_aux_heat_off(self) -> None: + """Turn auxiliary heater off.""" + for under in self._underlyings: + return under.turn_aux_heat_off() + + @overrides + async def async_turn_aux_heat_off(self) -> None: + """Turn auxiliary heater off.""" + for under in self._underlyings: + await under.async_turn_aux_heat_off() + + @overrides + async def async_set_fan_mode(self, fan_mode): + """Set new target fan mode.""" + _LOGGER.info("%s - Set fan mode: %s", self, fan_mode) + if fan_mode is None: + return + + for under in self._underlyings: + await under.set_fan_mode(fan_mode) + self._fan_mode = fan_mode + self.async_write_ha_state() + + @overrides + async def async_set_humidity(self, humidity: int): + """Set new target humidity.""" + _LOGGER.info("%s - Set fan mode: %s", self, humidity) + if humidity is None: + return + for under in self._underlyings: + await under.set_humidity(humidity) + self._humidity = humidity + self.async_write_ha_state() + + @overrides + async def async_set_swing_mode(self, swing_mode): + """Set new target swing operation.""" + _LOGGER.info("%s - Set fan mode: %s", self, swing_mode) + if swing_mode is None: + return + for under in self._underlyings: + await under.set_swing_mode(swing_mode) + self._swing_mode = swing_mode + self.async_write_ha_state() diff --git a/custom_components/versatile_thermostat/translations/fr.json b/custom_components/versatile_thermostat/translations/fr.json index b2b23f7..c30b9dc 100644 --- a/custom_components/versatile_thermostat/translations/fr.json +++ b/custom_components/versatile_thermostat/translations/fr.json @@ -38,7 +38,8 @@ "valve_entity_id": "1ère valve number", "valve_entity2_id": "2ème valve number", "valve_entity3_id": "3ème valve number", - "valve_entity4_id": "4ème valve number" + "valve_entity4_id": "4ème valve number", + "auto_regulation_mode": "Auto-regulation" }, "data_description": { "heater_entity_id": "Entity id du 1er radiateur obligatoire", @@ -54,7 +55,8 @@ "valve_entity_id": "Entity id de la 1ère valve", "valve_entity2_id": "Entity id de la 2ème valve", "valve_entity3_id": "Entity id de la 3ème valve", - "valve_entity4_id": "Entity id de la 4ème valve" + "valve_entity4_id": "Entity id de la 4ème valve", + "auto_regulation_mode": "Ajustement automatique de la consigne" } }, "tpi": { @@ -197,10 +199,11 @@ "climate_entity3_id": "3ème thermostat sous-jacent", "climate_entity4_id": "4ème thermostat sous-jacent", "ac_mode": "AC mode ?", - "valve_entity_id": "1ère valve number", - "valve_entity2_id": "2ème valve number", - "valve_entity3_id": "3ème valve number", - "valve_entity4_id": "4ème valve number" + "valve_entity_id": "1ère valve", + "valve_entity2_id": "2ème valve", + "valve_entity3_id": "3ème valve", + "valve_entity4_id": "4ème valve", + "auto_regulation_mode": "Auto-regulation" }, "data_description": { "heater_entity_id": "Entity id du 1er radiateur obligatoire", @@ -216,7 +219,8 @@ "valve_entity_id": "Entity id de la 1ère valve", "valve_entity2_id": "Entity id de la 2ème valve", "valve_entity3_id": "Entity id de la 3ème valve", - "valve_entity4_id": "Entity id de la 4ème valve" + "valve_entity4_id": "Entity id de la 4ème valve", + "auto_regulation_mode": "Ajustement automatique de la consigne" } }, "tpi": { @@ -330,6 +334,12 @@ "thermostat_over_climate": "Thermostat sur un autre thermostat", "thermostat_over_valve": "Thermostat sur une valve" } + }, + "auto_regulation_mode": { + "auto_regulation_strong": "Forte", + "auto_regulation_medium": "Moyenne", + "auto_regulation_light": "Légère", + "auto_regulation_none": "Aucune" } }, "entity": { diff --git a/custom_components/versatile_thermostat/translations/it.json b/custom_components/versatile_thermostat/translations/it.json index e7f5230..a03a5f2 100644 --- a/custom_components/versatile_thermostat/translations/it.json +++ b/custom_components/versatile_thermostat/translations/it.json @@ -38,7 +38,8 @@ "valve_entity_id": "Primo valvola numero", "valve_entity2_id": "Secondo valvola numero", "valve_entity3_id": "Terzo valvola numero", - "valve_entity4_id": "Quarto valvola numero" + "valve_entity4_id": "Quarto valvola numero", + "auto_regulation_mode": "Autoregolamentazione" }, "data_description": { "heater_entity_id": "Entity id obbligatoria del primo riscaldatore", @@ -54,7 +55,8 @@ "valve_entity_id": "Entity id del primo valvola numero", "valve_entity2_id": "Entity id del secondo valvola numero", "valve_entity3_id": "Entity id del terzo valvola numero", - "valve_entity4_id": "Entity id del quarto valvola numero" + "valve_entity4_id": "Entity id del quarto valvola numero", + "auto_regulation_mode": "Regolazione automatica della temperatura target" } }, "tpi": { @@ -192,7 +194,8 @@ "valve_entity_id": "Primo valvola numero", "valve_entity2_id": "Secondo valvola numero", "valve_entity3_id": "Terzo valvola numero", - "valve_entity4_id": "Quarto valvola numero" + "valve_entity4_id": "Quarto valvola numero", + "auto_regulation_mode": "Autoregolamentazione" }, "data_description": { "heater_entity_id": "Entity id obbligatoria del primo riscaldatore", @@ -208,7 +211,8 @@ "valve_entity_id": "Entity id del primo valvola numero", "valve_entity2_id": "Entity id del secondo valvola numero", "valve_entity3_id": "Entity id del terzo valvola numero", - "valve_entity4_id": "Entity id del quarto valvola numero" + "valve_entity4_id": "Entity id del quarto valvola numero", + "auto_regulation_mode": "Autoregolamentazione" } }, "tpi": { @@ -315,6 +319,12 @@ "thermostat_over_climate": "Termostato sopra un altro termostato", "thermostat_over_valve": "Thermostato su una valvola" } + }, + "auto_regulation_mode": { + "auto_regulation_strong": "Forte", + "auto_regulation_medium": "Media", + "auto_regulation_light": "Leggera", + "auto_regulation_none": "Nessuna autoregolamentazione" } }, "entity": { diff --git a/tests/test_pi.py b/tests/test_pi.py index 6423381..a3d1e61 100644 --- a/tests/test_pi.py +++ b/tests/test_pi.py @@ -168,4 +168,4 @@ def test_pi_algorithm_strong(): assert the_algo.calculate_regulated_temperature(19, 10) == 24 assert the_algo.calculate_regulated_temperature(19, 10) == 24 assert the_algo.calculate_regulated_temperature(19, 10) == 24 - assert the_algo.calculate_regulated_temperature(19, 10) == 24 \ No newline at end of file + assert the_algo.calculate_regulated_temperature(19, 10) == 24