Fix lyric TCC set temperature when in Auto mode (#106853)

pull/105955/head
Numa Perez 2024-01-14 05:29:03 -05:00 committed by GitHub
parent 75ba879c34
commit 5d8bf86279
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 15 deletions

View File

@ -182,6 +182,12 @@ class LyricClimate(LyricDeviceEntity, ClimateEntity):
device: LyricDevice,
) -> None:
"""Initialize Honeywell Lyric climate entity."""
# Define thermostat type (TCC - e.g., Lyric round; LCC - e.g., T5,6)
if device.changeableValues.thermostatSetpointStatus:
self._attr_thermostat_type = LyricThermostatType.LCC
else:
self._attr_thermostat_type = LyricThermostatType.TCC
# Use the native temperature unit from the device settings
if device.units == "Fahrenheit":
self._attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
@ -207,12 +213,10 @@ class LyricClimate(LyricDeviceEntity, ClimateEntity):
self._attr_hvac_modes.append(HVACMode.HEAT_COOL)
# Setup supported features
if device.changeableValues.thermostatSetpointStatus:
if self._attr_thermostat_type is LyricThermostatType.LCC:
self._attr_supported_features = SUPPORT_FLAGS_LCC
self._attr_thermostat_type = LyricThermostatType.LCC
else:
self._attr_supported_features = SUPPORT_FLAGS_TCC
self._attr_thermostat_type = LyricThermostatType.TCC
# Setup supported fan modes
if device_fan_modes := device.settings.attributes.get("fan", {}).get(
@ -328,20 +332,19 @@ class LyricClimate(LyricDeviceEntity, ClimateEntity):
target_temp_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
target_temp_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
if device.changeableValues.autoChangeoverActive:
if device.changeableValues.mode == LYRIC_HVAC_MODE_HEAT_COOL:
if target_temp_low is None or target_temp_high is None:
raise HomeAssistantError(
"Could not find target_temp_low and/or target_temp_high in"
" arguments"
)
# If the device supports "Auto" mode, don't pass the mode when setting the
# temperature
mode = (
None
if device.changeableValues.mode == LYRIC_HVAC_MODE_HEAT_COOL
else HVAC_MODES[device.changeableValues.heatCoolMode]
)
# If TCC device pass the heatCoolMode value, otherwise
# if LCC device can skip the mode altogether
if self._attr_thermostat_type is LyricThermostatType.TCC:
mode = HVAC_MODES[device.changeableValues.heatCoolMode]
else:
mode = None
_LOGGER.debug("Set temperature: %s - %s", target_temp_low, target_temp_high)
try:
@ -385,12 +388,12 @@ class LyricClimate(LyricDeviceEntity, ClimateEntity):
await self.coordinator.async_refresh()
async def _async_set_hvac_mode_tcc(self, hvac_mode: HVACMode) -> None:
"""Set hvac mode for TCC devices (e.g., Lyric round)."""
if LYRIC_HVAC_MODES[hvac_mode] == LYRIC_HVAC_MODE_HEAT_COOL:
# If the system is off, turn it to Heat first then to Auto,
# otherwise it turns to.
# Auto briefly and then reverts to Off (perhaps related to
# heatCoolMode). This is the behavior that happens with the
# native app as well, so likely a bug in the api itself
# otherwise it turns to Auto briefly and then reverts to Off.
# This is the behavior that happens with the native app as well,
# so likely a bug in the api itself.
if HVAC_MODES[self.device.changeableValues.mode] == HVACMode.OFF:
_LOGGER.debug(
"HVAC mode passed to lyric: %s",