From b3afa14095d7a32d12e21560f43c200c3b0cfc7e Mon Sep 17 00:00:00 2001 From: nu <2722344+ncd7@users.noreply.github.com> Date: Thu, 17 Aug 2023 23:59:53 -0400 Subject: [PATCH] fix bug when climate entity is using default min/max temp and temp unit is F The default min/max temps are in C but when the climate entity is set up with F this will cause incorrect boundary check and an inability to change the temperature from the home assistant entity UI widget. --- custom_components/localtuya/climate.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/custom_components/localtuya/climate.py b/custom_components/localtuya/climate.py index d8585ddaf..99bbf29ae 100644 --- a/custom_components/localtuya/climate.py +++ b/custom_components/localtuya/climate.py @@ -343,14 +343,22 @@ def min_temp(self): """Return the minimum temperature.""" if self.has_config(CONF_MIN_TEMP_DP): return self.dps_conf(CONF_MIN_TEMP_DP) - return DEFAULT_MIN_TEMP + # DEFAULT_MIN_TEMP is in C + if self.temperature_unit == TEMP_FAHRENHEIT: + return DEFAULT_MIN_TEMP * 1.8 + 32 + else: + return DEFAULT_MIN_TEMP @property def max_temp(self): """Return the maximum temperature.""" if self.has_config(CONF_MAX_TEMP_DP): return self.dps_conf(CONF_MAX_TEMP_DP) - return DEFAULT_MAX_TEMP + # DEFAULT_MAX_TEMP is in C + if self.temperature_unit == TEMP_FAHRENHEIT: + return DEFAULT_MAX_TEMP * 1.8 + 32 + else: + return DEFAULT_MAX_TEMP def status_updated(self): """Device status was updated."""