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