AIComfort isn't a distinct thermodynamic operation like Cool/Dry/Heat -- it's an AI-driven overlay on top of the device's own 'Auto' behavior, confirmed by A-CAWW-TP2-20-COMMON reporting both 'Auto' and 'AIComfort' as separate, mutually-exclusive entries in /mode/vs/0's supportedModes. Modeled the idiomatic HA way instead of a flat _DEVICE_TO_HVAC entry: hvac_mode reports AUTO and a new 'ai_comfort' preset carries the distinction. Entered/left only via the preset (writes the primary mode resource, not the convenient one) -- there's no dedicated HVACMode value for it, so it's not offered in the hvac_mode dropdown directly. Also adds a once-per-(href, code) warning log when a device-reported mode has no entry in the relevant map, so a future gap like this one surfaces in the log instead of silently vanishing -- the exact failure mode issue #93 called out ("this class of gap is invisible without diffing against supportedModes").
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
"""Tests for the AC HVAC-mode/preset device<->HA maps in climate.py (issue #93).
|
|
|
|
Module-level dicts/constants 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 (
|
|
_AI_COMFORT_MODE, _DEVICE_TO_HVAC, _HVAC_TO_DEVICE, PRESET_AI_COMFORT,
|
|
)
|
|
|
|
|
|
def test_auto_still_maps_to_heat_cool():
|
|
"""'Auto' is unchanged -- AIComfort is handled separately, not folded
|
|
into this map."""
|
|
assert _DEVICE_TO_HVAC['Auto'] == HVACMode.HEAT_COOL
|
|
|
|
|
|
def test_aicomfort_not_in_flat_hvac_map():
|
|
"""AIComfort isn't a flat _DEVICE_TO_HVAC entry -- it's an AI overlay on
|
|
top of 'Auto', modeled as hvac_mode=AUTO + a dedicated preset instead of
|
|
a distinct HVACMode value (see the climate.py module comment)."""
|
|
assert _AI_COMFORT_MODE not in _DEVICE_TO_HVAC
|
|
|
|
|
|
def test_hvac_auto_not_writable_via_hvac_mode():
|
|
"""HVACMode.AUTO has no _DEVICE_TO_HVAC entry, so it's unreachable via
|
|
async_set_hvac_mode -- entered/left only through the ai_comfort preset."""
|
|
assert HVACMode.AUTO not in _HVAC_TO_DEVICE
|
|
|
|
|
|
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
|
|
|
|
|
|
def test_preset_ai_comfort_constant():
|
|
assert PRESET_AI_COMFORT == 'ai_comfort'
|