Skip to content

Commit

Permalink
Perform checks and warnings before adjusting target temperature (#117)
Browse files Browse the repository at this point in the history
Co-authored-by: Cody Cooper <[email protected]>
  • Loading branch information
codyc1515 and Cody Cooper authored Jan 10, 2024
1 parent 1e4224a commit 2371ac9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions custom_components/dyson_local/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,16 @@ def max_temp(self):
def set_temperature(self, **kwargs):
"""Set new target temperature."""
target_temp = kwargs.get(ATTR_TEMPERATURE)
# Check if a temperature was sent
if target_temp is None:
_LOGGER.error("Missing target temperature %s", kwargs)
return
# Limit the target temperature into acceptable range
if target_temp < self.min_temp or target_temp > self.max_temp:
_LOGGER.warning('Temperature requested is outside min/max range, adjusting')
target_temp = min(self.max_temp, target_temp)
target_temp = max(self.min_temp, target_temp)
_LOGGER.debug("Set %s temperature %s", self.name, target_temp)
# Limit the target temperature into acceptable range.
target_temp = min(self.max_temp, target_temp)
target_temp = max(self.min_temp, target_temp)
self._device.set_heat_target(target_temp + 273)

def set_hvac_mode(self, hvac_mode: str):
Expand Down

0 comments on commit 2371ac9

Please sign in to comment.