Fix Lyric LCC thermostats auto mode (#104853)

This commit is contained in:
Alex Thompson 2023-12-11 10:27:02 -05:00 committed by GitHub
parent 3963f59121
commit 4c0fda9ca0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import asyncio import asyncio
import enum
import logging import logging
from time import localtime, strftime, time from time import localtime, strftime, time
from typing import Any from typing import Any
@ -151,6 +152,13 @@ async def async_setup_entry(
) )
class LyricThermostatType(enum.Enum):
"""Lyric thermostats are classified as TCC or LCC devices."""
TCC = enum.auto()
LCC = enum.auto()
class LyricClimate(LyricDeviceEntity, ClimateEntity): class LyricClimate(LyricDeviceEntity, ClimateEntity):
"""Defines a Honeywell Lyric climate entity.""" """Defines a Honeywell Lyric climate entity."""
@ -201,8 +209,10 @@ class LyricClimate(LyricDeviceEntity, ClimateEntity):
# Setup supported features # Setup supported features
if device.changeableValues.thermostatSetpointStatus: if device.changeableValues.thermostatSetpointStatus:
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(
@ -365,6 +375,16 @@ class LyricClimate(LyricDeviceEntity, ClimateEntity):
"""Set hvac mode.""" """Set hvac mode."""
_LOGGER.debug("HVAC mode: %s", hvac_mode) _LOGGER.debug("HVAC mode: %s", hvac_mode)
try: try:
match self._attr_thermostat_type:
case LyricThermostatType.TCC:
await self._async_set_hvac_mode_tcc(hvac_mode)
case LyricThermostatType.LCC:
await self._async_set_hvac_mode_lcc(hvac_mode)
except LYRIC_EXCEPTIONS as exception:
_LOGGER.error(exception)
await self.coordinator.async_refresh()
async def _async_set_hvac_mode_tcc(self, hvac_mode: HVACMode) -> None:
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.
@ -403,18 +423,21 @@ class LyricClimate(LyricDeviceEntity, ClimateEntity):
self.location, self.device, autoChangeoverActive=True self.location, self.device, autoChangeoverActive=True
) )
else: else:
_LOGGER.debug( _LOGGER.debug("HVAC mode passed to lyric: %s", LYRIC_HVAC_MODES[hvac_mode])
"HVAC mode passed to lyric: %s", LYRIC_HVAC_MODES[hvac_mode]
)
await self._update_thermostat( await self._update_thermostat(
self.location, self.location,
self.device, self.device,
mode=LYRIC_HVAC_MODES[hvac_mode], mode=LYRIC_HVAC_MODES[hvac_mode],
autoChangeoverActive=False, autoChangeoverActive=False,
) )
except LYRIC_EXCEPTIONS as exception:
_LOGGER.error(exception) async def _async_set_hvac_mode_lcc(self, hvac_mode: HVACMode) -> None:
await self.coordinator.async_refresh() _LOGGER.debug("HVAC mode passed to lyric: %s", LYRIC_HVAC_MODES[hvac_mode])
await self._update_thermostat(
self.location,
self.device,
mode=LYRIC_HVAC_MODES[hvac_mode],
)
async def async_set_preset_mode(self, preset_mode: str) -> None: async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set preset (PermanentHold, HoldUntil, NoHold, VacationHold) mode.""" """Set preset (PermanentHold, HoldUntil, NoHold, VacationHold) mode."""