Add cool-only global RAC support: WindFree, Auto mode, display light
Finishes PR #91's contribution (pedroperosin) with the requested review changes applied, on our own branch: - Preset resolution is now fully dynamic, read from each unit's own /mode/convenient/vs/0 supportedModes instead of a static per-model table -- any board's convenient modes (including WindFree's Nano/ NanoSleep) surface without code changes. Unlabelled codes across existing fixtures (longwind, motionindirect, motiondirect, drycomfort) plus the two new WindFree ones are added to en.json/nl.json. - 'Auto' now maps to HVACMode.AUTO instead of HEAT_COOL: these are single-setpoint "device decides" units, not two-setpoint heat+cool ones. 'Fan' is added alongside 'Wind' as a second FAN_ONLY spelling; a new _device_code_for_hvac() picks the code from the unit's own supportedModes since the flat map can't disambiguate two device codes mapping to one HA value. - Detection gains a hyphenated '-RAC-' modelNum fallback (alongside the existing '_RAC_') for cool-only global RAC variants whose /otninformation/vs/0 ships no swVersionInfo block. - Adds a display_light switch sourced from /mode/vs/0's opaque options blob (inverted Light_On/Light_Off token) for boards with no dedicated /light/vs/0 switch. Write-path behavioural change (touches the path iterated on across #9/#17/#27/#38/#54): power now targets the vendor /power/vs/0 instead of the OCF /power/0, and _is_on() reads vendor-first. /power/0 is absent on several known AC boards, so the previous OCF-first read/write pair could report and act on stale state -- consistent with #53's "can turn on but not off". Target temperature now picks its channel (OCF pair vs. vendor items[]) based on which the unit actually reports, reading and writing the same one. The vendor temperature write and the new display-light write both carry only the changed field(s), not the whole resource -- confirmed sufficient on the wire, the device merges the rest itself. That requires the coordinator's optimistic cache to do the same merge on the read side so a setpoint change doesn't blank out current/min/max/unit for the settle window: common.py gains merge_items_field() next to the existing merge_options_field(), and async_send_command wires it in for any write touching x.com.samsung.da.items. New fixture/golden for the cool-only global RAC variant (TP1X_DA-AC-RAC- 01001, AI_RAC_GLOBAL_COOLONLY_3.0); display_light added to the goldens for boards that gain the new options-based switch. Regenerated against current main rather than copied from the original PR, since those goldens had already shifted (current_temperature_c/humidity from issue #75).
This commit is contained in:
19 files changed
+1002
-71
No files matched your search
@@ -168,4 +168,43 @@ def test_all_entity_state_translation_keys_are_lowercase():
|
||||
for translation in platform.values():
|
||||
for state_key in translation.get("state", {}):
|
||||
assert state_key == state_key.lower()
|
||||
|
||||
|
||||
|
||||
def test_every_ac_convenient_mode_code_has_a_preset_label():
|
||||
"""issue #91 review feedback #3: AC preset resolution is fully dynamic
|
||||
(climate._preset_to_ha), so every fixture's /mode/convenient/vs/0
|
||||
supportedModes code surfaces as a preset -- an unlabelled one falls back
|
||||
to its raw device code in the UI. Cheap guard against repeating that gap:
|
||||
every non-'Off' code across every AC fixture must either resolve to one
|
||||
of HA's own auto-localized standard presets or have an explicit label in
|
||||
en.json.
|
||||
"""
|
||||
from homeassistant.components.climate.const import (
|
||||
PRESET_ACTIVITY, PRESET_AWAY, PRESET_BOOST, PRESET_COMFORT,
|
||||
PRESET_ECO, PRESET_HOME, PRESET_SLEEP,
|
||||
)
|
||||
standard = {PRESET_ACTIVITY, PRESET_AWAY, PRESET_BOOST, PRESET_COMFORT,
|
||||
PRESET_ECO, PRESET_HOME, PRESET_SLEEP}
|
||||
preset_labels = set(
|
||||
_load("en")["entity"]["climate"]["airconditioner"]["state_attributes"]
|
||||
["preset_mode"]["state"]
|
||||
)
|
||||
fixtures_dir = Path(__file__).parent / "fixtures"
|
||||
missing = []
|
||||
for path in sorted(fixtures_dir.glob("airconditioner*_device.json")):
|
||||
dump = json.loads(path.read_text())
|
||||
conv = next(
|
||||
(item for item in dump.get("device0", [])
|
||||
if item.get("href") == "/mode/convenient/vs/0"), None,
|
||||
)
|
||||
if not conv:
|
||||
continue
|
||||
for code in conv["rep"].get("x.com.samsung.da.supportedModes", []):
|
||||
if code == "Off":
|
||||
continue
|
||||
label = code.lower()
|
||||
if label in standard or label in preset_labels:
|
||||
continue
|
||||
missing.append((path.name, code))
|
||||
assert missing == []
|
||||
|
||||
Reference in new issue
Block a user