Map AC's AIComfort mode to HVACMode.AUTO (issue #93)

A-CAWW-TP2-20-COMMON (and likely other CAWW/TP2X-class boards) reports
'AIComfort' as a distinct entry in /mode/vs/0's supportedModes,
alongside 'Auto' (already mapped to HEAT_COOL). _read_modes() silently
drops any code missing from _DEVICE_TO_HVAC, so AIComfort was
unreachable -- one of HA's five other AC hvac_modes, unused by this
device family until now.

The other two gaps in issue #93 are already addressed elsewhere and
not duplicated here:
- Fan-only via the 'Fan' device code, and the WindFree/LongWind/
  NanoSleep preset codes, are covered by the still-open PR #91, which
  replaces the static preset table with a fully dynamic resolver over
  the device's own supportedModes.
- The 'Left_And_Right' -> horizontal swing mapping is already on the
  still-open claude/device-support-issue-75-windfree-ac branch.
This commit is contained in:
Marc Billow committed 2026-07-27 01:43:22 +00:00
1 parent aff7647460
commit 8c3250b163
2 files changed
+39

No files matched your search

+5
View File
@@ -65,6 +65,11 @@ _DEVICE_TO_HVAC: dict[str, HVACMode] = {
'Wind': HVACMode.FAN_ONLY,
'Auto': HVACMode.HEAT_COOL,
'Heat': HVACMode.HEAT,
# AI-driven auto-comfort mode (issue #93, A-CAWW-TP2-20-COMMON) -- a
# separate device code from 'Auto' above (both can appear in the same
# unit's supportedModes), so it needs its own entry rather than reusing
# 'Auto'. HVACMode.AUTO is otherwise unused by this map.
'AIComfort': HVACMode.AUTO,
}
_HVAC_TO_DEVICE = {v: k for k, v in _DEVICE_TO_HVAC.items()}
+34
View File
@@ -0,0 +1,34 @@
"""Tests for the AC HVAC-mode device<->HA map in climate.py (issue #93).
`_DEVICE_TO_HVAC`/`_HVAC_TO_DEVICE` are plain module-level dicts with no
coordinator/entity dependency, so -- like `_temps_vs_item` in
test_climate_temperature_fallback.py -- they're testable directly.
"""
from homeassistant.components.climate import HVACMode
from custom_components.localthings.climate import _DEVICE_TO_HVAC, _HVAC_TO_DEVICE
def test_aicomfort_maps_to_auto():
"""A-CAWW-TP2-20-COMMON (issue #93) reports 'AIComfort' in its
supportedModes alongside 'Auto' -- a separate AI-driven auto-comfort
mode, distinct from the existing 'Auto' -> HEAT_COOL entry."""
assert _DEVICE_TO_HVAC['AIComfort'] == HVACMode.AUTO
def test_auto_still_maps_to_heat_cool():
"""'AIComfort' is additive -- the existing 'Auto' -> HEAT_COOL mapping
(a different device code) is unchanged."""
assert _DEVICE_TO_HVAC['Auto'] == HVACMode.HEAT_COOL
def test_hvac_auto_writes_back_aicomfort():
"""Reverse map: selecting HA's Auto hvac_mode writes the 'AIComfort'
device code, not 'Auto' (which is reserved for HEAT_COOL)."""
assert _HVAC_TO_DEVICE[HVACMode.AUTO] == 'AIComfort'
def test_fan_only_still_reachable_via_wind():
"""Guard against regressing the existing 'Wind' -> FAN_ONLY entry while
editing this map."""
assert _DEVICE_TO_HVAC['Wind'] == HVACMode.FAN_ONLY