Skip to content

Commit

Permalink
fix: sets temperatures properly
Browse files Browse the repository at this point in the history
  • Loading branch information
= authored and swingerman committed May 14, 2022
1 parent ca1d2a1 commit 7dba9d3
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions custom_components/dual_smart_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import asyncio
import logging
from tkinter import OFF
from typing import List

import voluptuous as vol
Expand All @@ -14,6 +15,7 @@
PRESET_AWAY,
PRESET_NONE,
SUPPORT_PRESET_MODE,
SUPPORT_TARGET_TEMPERATURE,
SUPPORT_TARGET_TEMPERATURE_RANGE,
)
from homeassistant.const import (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 7dba9d3

Please sign in to comment.