From 34ab80ad93d9f5689f9da9b6c56d4087002e7d3f Mon Sep 17 00:00:00 2001 From: William P Date: Wed, 29 May 2024 13:10:00 -0400 Subject: [PATCH] support boolean for HVAC Eco preset --- custom_components/localtuya/climate.py | 8 +++++++- custom_components/localtuya/const.py | 1 + custom_components/localtuya/strings.json | 1 + custom_components/localtuya/translations/en.json | 1 + custom_components/localtuya/translations/it.json | 1 + custom_components/localtuya/translations/pt-BR.json | 1 + 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/custom_components/localtuya/climate.py b/custom_components/localtuya/climate.py index da23cfa..0730eaf 100644 --- a/custom_components/localtuya/climate.py +++ b/custom_components/localtuya/climate.py @@ -42,6 +42,7 @@ from .const import ( CONF_TEMP_MIN, CONF_ECO_DP, CONF_ECO_VALUE, + CONF_ECO_VALUE_BOOL, CONF_HEURISTIC_ACTION, CONF_HVAC_ACTION_DP, CONF_HVAC_ACTION_SET, @@ -168,6 +169,7 @@ def flow_schema(dps): vol.Optional(CONF_HVAC_ACTION_SET): vol.In(list(HVAC_ACTION_SETS.keys())), vol.Optional(CONF_ECO_DP): vol.In(dps), vol.Optional(CONF_ECO_VALUE): str, + vol.Optional(CONF_ECO_VALUE_BOOL): bool, vol.Optional(CONF_PRESET_DP): vol.In(dps), vol.Optional(CONF_PRESET_SET): vol.In(list(PRESET_SETS.keys())), vol.Optional(CONF_TEMPERATURE_UNIT): vol.In( @@ -224,6 +226,7 @@ class LocaltuyaClimate(LocalTuyaEntity, ClimateEntity): ) self._conf_eco_dp = self._config.get(CONF_ECO_DP) self._conf_eco_value = self._config.get(CONF_ECO_VALUE, "ECO") + self._conf_eco_value_bool = self._config.get(CONF_ECO_VALUE_BOOL) self._has_presets = self.has_config(CONF_ECO_DP) or self.has_config( CONF_PRESET_DP ) @@ -413,7 +416,10 @@ class LocaltuyaClimate(LocalTuyaEntity, ClimateEntity): async def async_set_preset_mode(self, preset_mode): """Set new target preset mode.""" if preset_mode == PRESET_ECO: - await self._device.set_dp(self._conf_eco_value, self._conf_eco_dp) + if self._conf_eco_value_bool: + await self._device.set_dp(True, self._conf_eco_dp) + else: + await self._device.set_dp(self._conf_eco_value, self._conf_eco_dp) return await self._device.set_dp( self._conf_preset_set[preset_mode], self._conf_preset_dp diff --git a/custom_components/localtuya/const.py b/custom_components/localtuya/const.py index 75f7bbd..5bce692 100644 --- a/custom_components/localtuya/const.py +++ b/custom_components/localtuya/const.py @@ -108,6 +108,7 @@ CONF_HVAC_ACTION_DP = "hvac_action_dp" CONF_HVAC_ACTION_SET = "hvac_action_set" CONF_ECO_DP = "eco_dp" CONF_ECO_VALUE = "eco_value" +CONF_ECO_VALUE_BOOL = "eco_value_bool" # vacuum CONF_POWERGO_DP = "powergo_dp" diff --git a/custom_components/localtuya/strings.json b/custom_components/localtuya/strings.json index 32f6040..3dc60ec 100644 --- a/custom_components/localtuya/strings.json +++ b/custom_components/localtuya/strings.json @@ -121,6 +121,7 @@ "preset_set": "Presets Set (optional)", "eco_dp": "Eco DP (optional)", "eco_value": "Eco value (optional)", + "eco_value_bool":"Eco value is a boolean type (true/false)", "heuristic_action": "Enable heuristic action (optional)", "dps_default_value": "Default value when un-initialised (optional)", "restore_on_reconnect": "Restore the last set value in HomeAssistant after a lost connection", diff --git a/custom_components/localtuya/translations/en.json b/custom_components/localtuya/translations/en.json index 8fdbb60..641860a 100644 --- a/custom_components/localtuya/translations/en.json +++ b/custom_components/localtuya/translations/en.json @@ -199,6 +199,7 @@ "preset_set": "Presets Set (optional)", "eco_dp": "Eco DP (optional)", "eco_value": "Eco value (optional)", + "eco_value_bool":"Eco value is a boolean type (true/false)", "heuristic_action": "Enable heuristic action (optional)", "dps_default_value": "Default value when un-initialised (optional)", "restore_on_reconnect": "Restore the last set value in HomeAssistant after a lost connection", diff --git a/custom_components/localtuya/translations/it.json b/custom_components/localtuya/translations/it.json index 264bb97..56821fc 100644 --- a/custom_components/localtuya/translations/it.json +++ b/custom_components/localtuya/translations/it.json @@ -183,6 +183,7 @@ "preset_set": "Set di preset (opzionale)", "eco_dp": "DP per Eco (opzionale)", "eco_value": "Valore Eco (opzionale)", + "eco_value_bool":"Il valore ecologico è di tipo booleano (vero/falso)", "heuristic_action": "Abilita azione euristica (opzionale)" } } diff --git a/custom_components/localtuya/translations/pt-BR.json b/custom_components/localtuya/translations/pt-BR.json index 74884ee..6b3a345 100644 --- a/custom_components/localtuya/translations/pt-BR.json +++ b/custom_components/localtuya/translations/pt-BR.json @@ -183,6 +183,7 @@ "preset_set": "Conjunto de predefinições (opcional)", "eco_dp": "Eco DP (opcional)", "eco_value": "Valor eco (opcional)", + "eco_value_bool":"O valor ecológico é do tipo booleano (verdadeiro/falso)", "heuristic_action": "Ativar ação heurística (opcional)" } }