Add a Preset mode for Honeywell permanent hold (#58060)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
schreyack 2021-10-28 16:59:50 -07:00 committed by GitHub
parent 34a6ce6f2a
commit e10bd39827
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 6 deletions

View file

@ -57,6 +57,8 @@ ATTR_FAN_ACTION = "fan_action"
ATTR_PERMANENT_HOLD = "permanent_hold"
PRESET_HOLD = "Hold"
PLATFORM_SCHEMA = vol.All(
cv.deprecated(CONF_REGION),
PLATFORM_SCHEMA.extend(
@ -161,7 +163,7 @@ class HoneywellUSThermostat(ClimateEntity):
self._attr_temperature_unit = (
TEMP_CELSIUS if device.temperature_unit == "C" else TEMP_FAHRENHEIT
)
self._attr_preset_modes = [PRESET_NONE, PRESET_AWAY]
self._attr_preset_modes = [PRESET_NONE, PRESET_AWAY, PRESET_HOLD]
self._attr_is_aux_heat = device.system_mode == "emheat"
# not all honeywell HVACs support all modes
@ -268,7 +270,12 @@ class HoneywellUSThermostat(ClimateEntity):
@property
def preset_mode(self) -> str | None:
"""Return the current preset mode, e.g., home, away, temp."""
return PRESET_AWAY if self._away else None
if self._away:
return PRESET_AWAY
if self._is_permanent_hold():
return PRESET_HOLD
return None
@property
def fan_mode(self) -> str | None:
@ -353,8 +360,26 @@ class HoneywellUSThermostat(ClimateEntity):
"Temperature %.1f out of range", getattr(self, f"_{mode}_away_temp")
)
def _turn_hold_mode_on(self) -> None:
"""Turn permanent hold on."""
try:
# Get current mode
mode = self._device.system_mode
except somecomfort.SomeComfortError:
_LOGGER.error("Can not get system mode")
return
# Check that we got a valid mode back
if mode in HW_MODE_TO_HVAC_MODE:
try:
# Set permanent hold
setattr(self._device, f"hold_{mode}", True)
except somecomfort.SomeComfortError:
_LOGGER.error("Couldn't set permanent hold")
else:
_LOGGER.error("Invalid system mode returned: %s", mode)
def _turn_away_mode_off(self) -> None:
"""Turn away off."""
"""Turn away/hold off."""
self._away = False
try:
# Disabling all hold modes
@ -367,6 +392,9 @@ class HoneywellUSThermostat(ClimateEntity):
"""Set new preset mode."""
if preset_mode == PRESET_AWAY:
self._turn_away_mode_on()
elif preset_mode == PRESET_HOLD:
self._away = False
self._turn_hold_mode_on()
else:
self._turn_away_mode_off()

View file

@ -3,7 +3,7 @@
"name": "Honeywell Total Connect Comfort (US)",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/honeywell",
"requirements": ["somecomfort==0.7.0"],
"requirements": ["somecomfort==0.8.0"],
"codeowners": ["@rdfurman"],
"iot_class": "cloud_polling"
}

View file

@ -2193,7 +2193,7 @@ solaredge==0.0.2
solax==0.2.8
# homeassistant.components.honeywell
somecomfort==0.7.0
somecomfort==0.8.0
# homeassistant.components.somfy_mylink
somfy-mylink-synergy==1.0.6

View file

@ -1269,7 +1269,7 @@ soco==0.24.0
solaredge==0.0.2
# homeassistant.components.honeywell
somecomfort==0.7.0
somecomfort==0.8.0
# homeassistant.components.somfy_mylink
somfy-mylink-synergy==1.0.6