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

This commit is contained in:
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

View File

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