Trim duplicated comments from /simplify review

Consolidate the AC/power-exclusion rationale (previously spelled out nearly
verbatim in three places) down to one canonical explanation next to
common.POWER, with one-line pointers elsewhere. Dedupe the switch/select
test classes' identical _desc() lookup into one shared helper.
This commit is contained in:
Marc Billow committed 2026-07-23 00:44:58 +00:00
1 parent 3d5263d792
commit 61ee2972dc
3 files changed
+20 -21

No files matched your search

@@ -4,10 +4,8 @@ The first device whose core controls surface as a single composite HA `climate`
entity (see capabilities/airconditioner.py and climate.py). Power/mode/temp/wind entity (see capabilities/airconditioner.py and climate.py). Power/mode/temp/wind
are consumed by that entity rather than exposed as separate switches/selects, so are consumed by that entity rather than exposed as separate switches/selects, so
this registry includes *common.UNIVERSAL but deliberately NOT common.POWER -- this registry includes *common.UNIVERSAL but deliberately NOT common.POWER --
on/off is the climate entity's HVACMode.OFF / TURN_ON/OFF, and /power/0 + on/off is the climate entity's HVACMode.OFF / TURN_ON/OFF. See common.POWER's
/power/vs/0 are already pre-claimed (no-entity) by airconditioner.COVERAGE via own comment in capabilities/common.py for why it's excluded.
CLIMATE_CONSUMED_HREFS. A real POWER_GENERIC/POWER_VS_FALLBACK cap on either
href alongside that bare claim would make _build() raise (see its docstring).
Reuses dishwasher.DIAGNOSIS for /diagnosis/vs/0. Reuses dishwasher.DIAGNOSIS for /diagnosis/vs/0.
""" """
@@ -348,15 +348,16 @@ SELF_CHECK = Capability(
# these to a new family is a safe, harmless guess (issue #40's AI energy # these to a new family is a safe, harmless guess (issue #40's AI energy
# level: 2 of 6 families confirmed, blanket-added everywhere else). # level: 2 of 6 families confirmed, blanket-added everywhere else).
# #
# POWER is kept separate: airconditioner deliberately does NOT include it. # POWER is kept separate -- airconditioner is the one family that opts out
# AC's climate entity (registry/capabilities/airconditioner.py) already # of it. Canonical reason (see by_type/airconditioner.py and its test for
# owns /power/0 and /power/vs/0 -- they're pre-claimed there via bare, # pointers back here, not restatements): AC's climate entity already owns
# no-entity Capability objects (COVERAGE) so a second, real POWER_GENERIC/ # /power/0 and /power/vs/0 via bare, no-entity Capability objects
# POWER_VS_FALLBACK cap on the same href would make _build() raise # (airconditioner.COVERAGE), and a second, real POWER_GENERIC/
# (a href with >1 cap must have every cap discriminated by rt_filter/ # POWER_VS_FALLBACK cap on the same href would make _build() raise (a href
# match_fn, and the bare COVERAGE cap has neither). Kids-lock and remote- # with >1 cap must have every cap discriminated by rt_filter/match_fn, and
# control don't have this conflict -- no AC dump has ever reported those # the bare COVERAGE cap has neither). Kids-lock/remote-control don't have
# hrefs -- so they stay in UNIVERSAL. # this conflict -- no AC dump has ever reported those hrefs -- so they stay
# in UNIVERSAL.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
UNIVERSAL = ( UNIVERSAL = (
+8 -8
View File
@@ -142,10 +142,14 @@ class TestEnergyMeter:
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
def _ai_energy_level_desc(cls_name):
return next(e for e in common.AI_ENERGY_LEVEL.entities
if e.__class__.__name__ == cls_name)
class TestAiEnergyLevelSwitch: class TestAiEnergyLevelSwitch:
def _desc(self): def _desc(self):
return next(e for e in common.AI_ENERGY_LEVEL.entities return _ai_energy_level_desc('SwitchDesc')
if e.__class__.__name__ == 'SwitchDesc')
def test_href(self): def test_href(self):
assert common.AI_ENERGY_LEVEL.href == '/energy/ailevel/vs/0' assert common.AI_ENERGY_LEVEL.href == '/energy/ailevel/vs/0'
@@ -190,8 +194,7 @@ class TestAiEnergyLevelSwitch:
class TestAiEnergyLevelSelect: class TestAiEnergyLevelSelect:
def _desc(self): def _desc(self):
return next(e for e in common.AI_ENERGY_LEVEL.entities return _ai_energy_level_desc('SelectDesc')
if e.__class__.__name__ == 'SelectDesc')
def test_shown_only_with_multiple_supported_levels(self): def test_shown_only_with_multiple_supported_levels(self):
desc = self._desc() desc = self._desc()
@@ -282,10 +285,7 @@ class TestUniversalAndPowerBundles:
} }
def test_power_kept_separate_for_airconditioners_sake(self): def test_power_kept_separate_for_airconditioners_sake(self):
"""airconditioner.py deliberately doesn't unpack this bundle -- its """See common.POWER's own comment for why airconditioner opts out."""
climate entity already owns /power/0 and /power/vs/0 via a bare,
no-entity claim (airconditioner.COVERAGE); a real POWER_GENERIC/
POWER_VS_FALLBACK cap on the same href would make _build() raise."""
assert set(common.POWER) == {common.POWER_GENERIC, common.POWER_VS_FALLBACK} assert set(common.POWER) == {common.POWER_GENERIC, common.POWER_VS_FALLBACK}
def test_no_overlap_between_the_two_bundles(self): def test_no_overlap_between_the_two_bundles(self):