Fix HKC showing hvac_action as idle when fan is active and heat cool target is off (#142443)

* Fix HKC showing hvac_action as idle when fan is active and heat cool target is off

fixes #142442

* comment relocation
This commit is contained in:
J. Nick Koston 2025-04-06 22:11:15 -10:00 committed by GitHub
parent 43f93c74da
commit 8d82ef8e36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6921 additions and 8 deletions

View File

@ -659,13 +659,7 @@ class HomeKitClimateEntity(HomeKitBaseClimateEntity):
# e.g. a thermostat is "heating" a room to 75 degrees Fahrenheit.
# Can be 0 - 2 (Off, Heat, Cool)
# If the HVAC is switched off, it must be idle
# This works around a bug in some devices (like Eve radiator valves) that
# return they are heating when they are not.
target = self.service.value(CharacteristicsTypes.HEATING_COOLING_TARGET)
if target == HeatingCoolingTargetValues.OFF:
return HVACAction.IDLE
value = self.service.value(CharacteristicsTypes.HEATING_COOLING_CURRENT)
current_hass_value = CURRENT_MODE_HOMEKIT_TO_HASS.get(value)
@ -679,6 +673,12 @@ class HomeKitClimateEntity(HomeKitBaseClimateEntity):
):
return HVACAction.FAN
# If the HVAC is switched off, it must be idle
# This works around a bug in some devices (like Eve radiator valves) that
# return they are heating when they are not.
if target == HeatingCoolingTargetValues.OFF:
return HVACAction.IDLE
return current_hass_value
@property

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,8 @@ from aiohomekit.model.characteristics import (
CharacteristicsTypes,
CurrentFanStateValues,
CurrentHeaterCoolerStateValues,
HeatingCoolingCurrentValues,
HeatingCoolingTargetValues,
SwingModeValues,
TargetHeaterCoolerStateValues,
)
@ -20,6 +22,7 @@ from homeassistant.components.climate import (
SERVICE_SET_HVAC_MODE,
SERVICE_SET_SWING_MODE,
SERVICE_SET_TEMPERATURE,
HVACAction,
HVACMode,
)
from homeassistant.core import HomeAssistant
@ -662,7 +665,7 @@ async def test_hvac_mode_vs_hvac_action(
state = await helper.poll_and_get_state()
assert state.state == "heat"
assert state.attributes["hvac_action"] == "fan"
assert state.attributes["hvac_action"] == HVACAction.FAN
# Simulate that current temperature is below target temp
# Heating might be on and hvac_action currently 'heat'
@ -676,7 +679,23 @@ async def test_hvac_mode_vs_hvac_action(
state = await helper.poll_and_get_state()
assert state.state == "heat"
assert state.attributes["hvac_action"] == "heating"
assert state.attributes["hvac_action"] == HVACAction.HEATING
# If the fan is active, and the heating is off, the hvac_action should be 'fan'
# and not 'idle' or 'heating'
await helper.async_update(
ServicesTypes.THERMOSTAT,
{
CharacteristicsTypes.FAN_STATE_CURRENT: CurrentFanStateValues.ACTIVE,
CharacteristicsTypes.HEATING_COOLING_CURRENT: HeatingCoolingCurrentValues.IDLE,
CharacteristicsTypes.HEATING_COOLING_TARGET: HeatingCoolingTargetValues.OFF,
CharacteristicsTypes.FAN_STATE_CURRENT: CurrentFanStateValues.ACTIVE,
},
)
state = await helper.poll_and_get_state()
assert state.state == HVACMode.OFF
assert state.attributes["hvac_action"] == HVACAction.FAN
async def test_hvac_mode_vs_hvac_action_current_mode_wrong(