Fix preset modes in Honeywell (#86293)

* Fix for issue #83841

* in instead of =

* Address None for entity maps

* Rework retry logic

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

* Remove none, change log wording
This commit is contained in:
mkmer 2023-01-21 14:21:03 -05:00 committed by GitHub
parent f608e150fd
commit 402be4ebde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,6 +40,9 @@ ATTR_PERMANENT_HOLD = "permanent_hold"
PRESET_HOLD = "Hold" PRESET_HOLD = "Hold"
HEATING_MODES = {"heat", "emheat", "auto"}
COOLING_MODES = {"cool", "auto"}
HVAC_MODE_TO_HW_MODE = { HVAC_MODE_TO_HW_MODE = {
"SwitchOffAllowed": {HVACMode.OFF: "off"}, "SwitchOffAllowed": {HVACMode.OFF: "off"},
"SwitchAutoAllowed": {HVACMode.HEAT_COOL: "auto"}, "SwitchAutoAllowed": {HVACMode.HEAT_COOL: "auto"},
@ -196,7 +199,7 @@ class HoneywellUSThermostat(ClimateEntity):
"""Return the current running hvac operation if supported.""" """Return the current running hvac operation if supported."""
if self.hvac_mode == HVACMode.OFF: if self.hvac_mode == HVACMode.OFF:
return None 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 @property
def current_temperature(self) -> float | None: def current_temperature(self) -> float | None:
@ -239,7 +242,7 @@ class HoneywellUSThermostat(ClimateEntity):
@property @property
def fan_mode(self) -> str | None: def fan_mode(self) -> str | None:
"""Return the fan setting.""" """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: def _is_permanent_hold(self) -> bool:
heat_status = self._device.raw_ui_data.get("StatusHeat", 0) heat_status = self._device.raw_ui_data.get("StatusHeat", 0)
@ -262,15 +265,15 @@ class HoneywellUSThermostat(ClimateEntity):
# Get next period time # Get next period time
hour, minute = divmod(next_period * 15, 60) hour, minute = divmod(next_period * 15, 60)
# Set hold time # Set hold time
if mode == "cool": if mode in COOLING_MODES:
await self._device.set_hold_cool(datetime.time(hour, minute)) 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)) await self._device.set_hold_heat(datetime.time(hour, minute))
# Set temperature # Set temperature
if mode == "cool": if mode in COOLING_MODES:
await self._device.set_setpoint_cool(temperature) await self._device.set_setpoint_cool(temperature)
elif mode == "heat": elif mode in HEATING_MODES:
await self._device.set_setpoint_heat(temperature) await self._device.set_setpoint_heat(temperature)
except AIOSomecomfort.SomeComfortError: except AIOSomecomfort.SomeComfortError:
@ -316,17 +319,20 @@ class HoneywellUSThermostat(ClimateEntity):
# Set permanent hold # Set permanent hold
# and Set temperature # and Set temperature
away_temp = getattr(self, f"_{mode}_away_temp") if mode in COOLING_MODES:
if mode == "cool":
self._device.set_hold_cool(True) self._device.set_hold_cool(True)
self._device.set_setpoint_cool(away_temp) self._device.set_setpoint_cool(self._cool_away_temp)
elif mode == "heat": elif mode in HEATING_MODES:
self._device.set_hold_heat(True) 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: except AIOSomecomfort.SomeComfortError:
_LOGGER.error( _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: async def _turn_hold_mode_on(self) -> None:
@ -341,9 +347,9 @@ class HoneywellUSThermostat(ClimateEntity):
if mode in HW_MODE_TO_HVAC_MODE: if mode in HW_MODE_TO_HVAC_MODE:
try: try:
# Set permanent hold # Set permanent hold
if mode == "cool": if mode in COOLING_MODES:
await self._device.set_hold_cool(True) await self._device.set_hold_cool(True)
elif mode == "heat": elif mode in HEATING_MODES:
await self._device.set_hold_heat(True) await self._device.set_hold_heat(True)
except AIOSomecomfort.SomeComfortError: except AIOSomecomfort.SomeComfortError:
@ -373,7 +379,7 @@ class HoneywellUSThermostat(ClimateEntity):
async def async_turn_aux_heat_on(self) -> None: async def async_turn_aux_heat_on(self) -> None:
"""Turn auxiliary heater on.""" """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: async def async_turn_aux_heat_off(self) -> None:
"""Turn auxiliary heater off.""" """Turn auxiliary heater off."""