Skip to content

Commit

Permalink
Fix Glow/Onyx
Browse files Browse the repository at this point in the history
  • Loading branch information
cyr-ius committed Jun 8, 2024
1 parent 2b2c488 commit b5cd079
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions custom_components/heatzy/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,11 @@ class HeatzyPiloteV2Thermostat(HeatzyThermostat):
@property
def preset_mode(self) -> str | None:
"""Return the current preset mode, e.g., home, away, temp."""
if self._attr.get(CONF_DEROG_MODE) == 2:
return PRESET_BOOST
return self.HEATZY_TO_HA_STATE.get(self._attr.get(CONF_MODE))
return (
PRESET_BOOST
if self._attr.get(CONF_DEROG_MODE) == 2
else self.HEATZY_TO_HA_STATE.get(self._attr.get(CONF_MODE))
)

async def async_turn_on(self) -> None:
"""Turn device on."""
Expand Down Expand Up @@ -444,9 +446,8 @@ def hvac_action(self) -> HVACAction:
if self.hvac_mode == HVACMode.OFF:
return HVACAction.OFF
# If Target temp is higher than current temp then set HVAC Action to HEATING
if (
self.target_temperature
and self.target_temperature > self.current_temperature
if self.target_temperature and (
self.target_temperature > self.current_temperature
):
return HVACAction.HEATING
# Otherwise set to IDLE
Expand All @@ -455,14 +456,11 @@ def hvac_action(self) -> HVACAction:
@property
def preset_mode(self) -> str | None:
"""Return the current preset mode, e.g., home, away, temp."""
if self._attr.get(CONF_ON_OFF) == 0 and self._attr.get(CONF_DEROG_MODE) == 2:
return PRESET_AWAY

if cur_mode := self._attr.get(CONF_CUR_MODE):
# Use CUR_MODE for mapping to preset mode as this works in PROGRAM mode as well manual mode
return self.HEATZY_TO_HA_STATE.get(cur_mode)

return self.HEATZY_TO_HA_STATE.get(self._attr.get(CONF_MODE))
return (
PRESET_AWAY
if self._attr.get(CONF_ON_OFF) == 0 and self._attr.get(CONF_DEROG_MODE) == 2
else self.HEATZY_TO_HA_STATE.get(self._attr.get(CONF_CUR_MODE))
)

async def async_turn_on(self) -> None:
"""Turn device on."""
Expand Down Expand Up @@ -581,9 +579,8 @@ def hvac_action(self) -> HVACAction:
if self.hvac_mode == HVACMode.OFF:
return HVACAction.OFF
# If Target temp is higher than current temp then set HVAC Action to HEATING
if (
self.target_temperature
and self.target_temperature > self.current_temperature
if self.target_temperature and (
self.target_temperature > self.current_temperature
):
return HVACAction.HEATING
# Otherwise set to IDLE
Expand Down

0 comments on commit b5cd079

Please sign in to comment.