From 8c3250b16329f8531b00bd23a76d5e64719ff6f3 Mon Sep 17 00:00:00 2001 From: Marc Billow Date: Mon, 27 Jul 2026 01:43:22 +0000 Subject: [PATCH] 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. --- custom_components/localthings/climate.py | 5 ++++ tests/test_climate_ac_modes.py | 34 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/test_climate_ac_modes.py diff --git a/custom_components/localthings/climate.py b/custom_components/localthings/climate.py index 79d38af..511c712 100644 --- a/custom_components/localthings/climate.py +++ b/custom_components/localthings/climate.py @@ -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()} diff --git a/tests/test_climate_ac_modes.py b/tests/test_climate_ac_modes.py new file mode 100644 index 0000000..62c3489 --- /dev/null +++ b/tests/test_climate_ac_modes.py @@ -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