Skip to content

Commit

Permalink
Fix preset modes in Honeywell (home-assistant#86293)
Browse files Browse the repository at this point in the history
* Fix for issue home-assistant#83841

* in instead of =

* Address None for entity maps

* Rework retry logic

* Committed to the wrong branch....
This reverts commit 40e1940 (Rework retry logic, 2023-01-21).

* Remove none, change log wording
  • Loading branch information
mkmer authored Jan 21, 2023
1 parent f608e15 commit 402be4e
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions homeassistant/components/honeywell/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@

PRESET_HOLD = "Hold"

HEATING_MODES = {"heat", "emheat", "auto"}
COOLING_MODES = {"cool", "auto"}

HVAC_MODE_TO_HW_MODE = {
"SwitchOffAllowed": {HVACMode.OFF: "off"},
"SwitchAutoAllowed": {HVACMode.HEAT_COOL: "auto"},
Expand Down Expand Up @@ -196,7 +199,7 @@ def hvac_action(self) -> HVACAction | None:
"""Return the current running hvac operation if supported."""
if self.hvac_mode == HVACMode.OFF:
return None
return HW_MODE_TO_HA_HVAC_ACTION[self._device.equipment_output_status]
return HW_MODE_TO_HA_HVAC_ACTION.get(self._device.equipment_output_status)

@property
def current_temperature(self) -> float | None:
Expand Down Expand Up @@ -239,7 +242,7 @@ def preset_mode(self) -> str | None:
@property
def fan_mode(self) -> str | None:
"""Return the fan setting."""
return HW_FAN_MODE_TO_HA[self._device.fan_mode]
return HW_FAN_MODE_TO_HA.get(self._device.fan_mode)

def _is_permanent_hold(self) -> bool:
heat_status = self._device.raw_ui_data.get("StatusHeat", 0)
Expand All @@ -262,15 +265,15 @@ async def _set_temperature(self, **kwargs) -> None:
# Get next period time
hour, minute = divmod(next_period * 15, 60)
# Set hold time
if mode == "cool":
if mode in COOLING_MODES:
await self._device.set_hold_cool(datetime.time(hour, minute))
elif mode == "heat":
elif mode in HEATING_MODES:
await self._device.set_hold_heat(datetime.time(hour, minute))

# Set temperature
if mode == "cool":
if mode in COOLING_MODES:
await self._device.set_setpoint_cool(temperature)
elif mode == "heat":
elif mode in HEATING_MODES:
await self._device.set_setpoint_heat(temperature)

except AIOSomecomfort.SomeComfortError:
Expand Down Expand Up @@ -316,17 +319,20 @@ async def _turn_away_mode_on(self) -> None:

# Set permanent hold
# and Set temperature
away_temp = getattr(self, f"_{mode}_away_temp")
if mode == "cool":
if mode in COOLING_MODES:
self._device.set_hold_cool(True)
self._device.set_setpoint_cool(away_temp)
elif mode == "heat":
self._device.set_setpoint_cool(self._cool_away_temp)
elif mode in HEATING_MODES:
self._device.set_hold_heat(True)
self._device.set_setpoint_heat(away_temp)
self._device.set_setpoint_heat(self._heat_away_temp)

except AIOSomecomfort.SomeComfortError:

_LOGGER.error(
"Temperature %.1f out of range", getattr(self, f"_{mode}_away_temp")
"Temperature out of range. Mode: %s, Heat Temperature: %.1f, Cool Temperature: %.1f",
mode,
self._heat_away_temp,
self._cool_away_temp,
)

async def _turn_hold_mode_on(self) -> None:
Expand All @@ -341,9 +347,9 @@ async def _turn_hold_mode_on(self) -> None:
if mode in HW_MODE_TO_HVAC_MODE:
try:
# Set permanent hold
if mode == "cool":
if mode in COOLING_MODES:
await self._device.set_hold_cool(True)
elif mode == "heat":
elif mode in HEATING_MODES:
await self._device.set_hold_heat(True)

except AIOSomecomfort.SomeComfortError:
Expand Down Expand Up @@ -373,7 +379,7 @@ async def async_set_preset_mode(self, preset_mode: str) -> None:

async def async_turn_aux_heat_on(self) -> None:
"""Turn auxiliary heater on."""
await self._device.system_mode("emheat")
await self._device.set_system_mode("emheat")

async def async_turn_aux_heat_off(self) -> None:
"""Turn auxiliary heater off."""
Expand Down

0 comments on commit 402be4e

Please sign in to comment.