diff --git a/esphome/components/remote_base/__init__.py b/esphome/components/remote_base/__init__.py index dc0fd74a3c..754b8a4317 100644 --- a/esphome/components/remote_base/__init__.py +++ b/esphome/components/remote_base/__init__.py @@ -281,22 +281,16 @@ TRIGGER_REGISTRY = SimpleRegistry() DUMPER_REGISTRY = Registry() -def _dumper_key(item: Any) -> Any: - """Registry key of a dump entry in either its string or its mapping form.""" - if isinstance(item, dict) and len(item) == 1: - return next(iter(item)) - return item - - def validate_dumpers(value): if isinstance(value, str) and value.lower() == "all": return validate_dumpers(list(DUMPER_REGISTRY.keys())) - if isinstance(value, list): - # a dumper listed twice would register twice; the receiver holds one secondary dumper - keys = [_dumper_key(item) for item in value] - if all(isinstance(key, str) for key in keys): - value = list(dict(zip(keys, value, strict=True)).values()) - return cv.validate_registry("dumper", DUMPER_REGISTRY)(value) + entries = cv.validate_registry("dumper", DUMPER_REGISTRY)(value) + # a dumper listed twice would register twice; the receiver holds one secondary dumper + return list( + { + next(k for k in entry if k in DUMPER_REGISTRY): entry for entry in entries + }.values() + ) def validate_triggers(base_schema): diff --git a/esphome/components/remote_base/rc_switch_protocol.h b/esphome/components/remote_base/rc_switch_protocol.h index cf39f0eae7..151294c6a2 100644 --- a/esphome/components/remote_base/rc_switch_protocol.h +++ b/esphome/components/remote_base/rc_switch_protocol.h @@ -68,7 +68,7 @@ class RCSwitchBase { uint32_t inverted_{}; // bool widened so every field is a word: the table is read from flash }; -// Constant-initialized and kept in flash on every platform; all fields are 32-bit so ESP8266 can read it in place +// Constant-initialized and kept in flash on every platform inline constexpr RCSwitchBase RC_SWITCH_PROTOCOLS[] PROGMEM = { {0, 0, 0, 0, 0, 0, false}, {350, 10850, 350, 1050, 1050, 350, false}, diff --git a/tests/component_tests/remote_receiver/test_slot_counts.py b/tests/component_tests/remote_receiver/test_slot_counts.py index 9c80c3674f..e9bce83f03 100644 --- a/tests/component_tests/remote_receiver/test_slot_counts.py +++ b/tests/component_tests/remote_receiver/test_slot_counts.py @@ -54,21 +54,14 @@ def test_only_used_protocol_sources_are_compiled( def test_every_registry_name_maps_to_a_protocol_source() -> None: - sources = { - path.name for path in Path(remote_base.__file__).parent.glob("*_protocol.cpp") - } + """A registry name must resolve to a source file or request_protocol rejects it.""" names = ( set(remote_base.BINARY_SENSOR_REGISTRY) | set(remote_base.DUMPER_REGISTRY) | {key.removeprefix("on_") for key in remote_base.TRIGGER_REGISTRY} ) for name in names: - stem = ( - remote_base.protocol_define(name) - .removeprefix("USE_REMOTE_PROTOCOL_") - .lower() - ) - assert f"{stem}_protocol.cpp" in sources, name + assert remote_base._protocol_stem(name) in remote_base._PROTOCOL_STEMS, name def test_request_protocol_rejects_unknown_names() -> None: