From 7dba9d3e0e5510d9c92044d7a5bc7abb0e673d68 Mon Sep 17 00:00:00 2001 From: = <=> Date: Sat, 14 May 2022 22:44:19 +0000 Subject: [PATCH] fix: sets temperatures properly --- .../dual_smart_thermostat/climate.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/custom_components/dual_smart_thermostat/climate.py b/custom_components/dual_smart_thermostat/climate.py index 33fb75a..0b90ade 100644 --- a/custom_components/dual_smart_thermostat/climate.py +++ b/custom_components/dual_smart_thermostat/climate.py @@ -2,6 +2,7 @@ import asyncio import logging +from tkinter import OFF from typing import List import voluptuous as vol @@ -14,6 +15,7 @@ PRESET_AWAY, PRESET_NONE, SUPPORT_PRESET_MODE, + SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE_RANGE, ) from homeassistant.const import ( @@ -242,11 +244,15 @@ def __init__( self._unit = unit self._unique_id = unique_id self._support_flags = ( - SUPPORT_TARGET_TEMPERATURE_RANGE if cooler_entity_id else SUPPORT_FLAGS + SUPPORT_TARGET_TEMPERATURE_RANGE + if cooler_entity_id + else SUPPORT_TARGET_TEMPERATURE ) if away_temp: self._support_flags = ( - SUPPORT_TARGET_TEMPERATURE_RANGE if cooler_entity_id else SUPPORT_FLAGS + SUPPORT_TARGET_TEMPERATURE_RANGE + if cooler_entity_id + else SUPPORT_TARGET_TEMPERATURE ) | SUPPORT_PRESET_MODE self._away_temp = away_temp self._is_away = False @@ -484,12 +490,15 @@ async def async_set_hvac_mode(self, hvac_mode): _LOGGER.info("Setting hvac mode: %s", hvac_mode) if hvac_mode == HVACMode.HEAT: self._hvac_mode = HVACMode.HEAT + self._support_flags = SUPPORT_TARGET_TEMPERATURE await self._async_control_heating(force=True) elif hvac_mode == HVACMode.COOL: self._hvac_mode = HVACMode.COOL + self._support_flags = SUPPORT_TARGET_TEMPERATURE await self._async_control_heating(force=True) elif hvac_mode == HVACMode.HEAT_COOL: self._hvac_mode = HVACMode.HEAT_COOL + self._support_flags = SUPPORT_TARGET_TEMPERATURE_RANGE await self._async_control_heat_cool(force=True) elif hvac_mode == HVACMode.OFF: self._hvac_mode = HVACMode.OFF @@ -504,7 +513,11 @@ async def async_set_hvac_mode(self, hvac_mode): async def async_set_temperature(self, **kwargs): """Set new target temperature.""" - if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None: + temperature = kwargs.get(ATTR_TEMPERATURE) + if ( + self._hvac_mode not in (HVACMode.HEAT_COOL, HVACMode.OFF) + and temperature is None + ): return temp_low = kwargs.get(ATTR_TARGET_TEMP_LOW) temp_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)