mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 03:03:17 +01:00
Fix Control4 HVAC action mapping for multi-stage and idle states (#163222)
This commit is contained in:
@@ -75,11 +75,12 @@ C4_TO_HA_HVAC_MODE = {
|
||||
|
||||
HA_TO_C4_HVAC_MODE = {v: k for k, v in C4_TO_HA_HVAC_MODE.items()}
|
||||
|
||||
# Map the five known Control4 HVAC states to Home Assistant HVAC actions
|
||||
# Map Control4 HVAC states to Home Assistant HVAC actions
|
||||
C4_TO_HA_HVAC_ACTION = {
|
||||
"off": HVACAction.OFF,
|
||||
"heat": HVACAction.HEATING,
|
||||
"cool": HVACAction.COOLING,
|
||||
"idle": HVACAction.IDLE,
|
||||
"dry": HVACAction.DRYING,
|
||||
"fan": HVACAction.FAN,
|
||||
}
|
||||
@@ -292,8 +293,14 @@ class Control4Climate(Control4Entity, ClimateEntity):
|
||||
c4_state = data.get(CONTROL4_HVAC_STATE)
|
||||
if c4_state is None:
|
||||
return None
|
||||
# Convert state to lowercase for mapping
|
||||
action = C4_TO_HA_HVAC_ACTION.get(str(c4_state).lower())
|
||||
# Substring match for multi-stage systems that report
|
||||
# e.g. "Stage 1 Heat", "Stage 2 Cool"
|
||||
if action is None:
|
||||
if "heat" in str(c4_state).lower():
|
||||
action = HVACAction.HEATING
|
||||
elif "cool" in str(c4_state).lower():
|
||||
action = HVACAction.COOLING
|
||||
if action is None:
|
||||
_LOGGER.debug("Unknown HVAC state received from Control4: %s", c4_state)
|
||||
return action
|
||||
|
||||
@@ -115,6 +115,21 @@ async def test_climate_entities(
|
||||
HVACAction.FAN,
|
||||
id="fan",
|
||||
),
|
||||
pytest.param(
|
||||
_make_climate_data(hvac_state="Idle"),
|
||||
HVACAction.IDLE,
|
||||
id="idle",
|
||||
),
|
||||
pytest.param(
|
||||
_make_climate_data(hvac_state="Stage 1 Heat"),
|
||||
HVACAction.HEATING,
|
||||
id="stage_1_heat",
|
||||
),
|
||||
pytest.param(
|
||||
_make_climate_data(hvac_state="Stage 2 Cool", hvac_mode="Cool"),
|
||||
HVACAction.COOLING,
|
||||
id="stage_2_cool",
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures(
|
||||
|
||||
Reference in New Issue
Block a user