From 70d9ab25f3e20f8301ab353ce45dd543e61087db Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 5 Jun 2026 17:57:42 -0500 Subject: [PATCH] [tests] Fail component test merge on conflicting duplicate IDs (#16795) --- .github/workflows/ci.yml | 1 + script/ci_check_duplicate_test_ids.py | 122 ++++++++++++++++++ script/merge_component_configs.py | 48 ++++++- tests/components/adc/test.bk72xx-ard.yaml | 2 +- tests/components/adc/test.esp32-c2-idf.yaml | 2 +- tests/components/adc/test.esp32-c3-idf.yaml | 2 +- tests/components/adc/test.esp32-idf.yaml | 2 +- tests/components/adc/test.esp32-p4-idf.yaml | 2 +- tests/components/adc/test.esp32-s2-idf.yaml | 2 +- tests/components/adc/test.esp32-s3-idf.yaml | 2 +- tests/components/adc/test.esp8266-ard.yaml | 2 +- tests/components/adc/test.ln882x-ard.yaml | 2 +- tests/components/adc/test.rp2040-ard.yaml | 2 +- .../components/adc/test.rp2040-pico2-ard.yaml | 2 +- .../alarm_control_panel/common.yaml | 6 +- .../components/animation/test.esp32-idf.yaml | 2 +- .../animation/test.esp8266-ard.yaml | 2 +- .../components/animation/test.rp2040-ard.yaml | 2 +- tests/components/axs15231/common.yaml | 4 +- .../components/axs15231/test.esp8266-ard.yaml | 4 +- tests/components/bang_bang/common.yaml | 12 +- tests/components/binary_sensor/common.yaml | 6 +- .../components/binary_sensor_map/common.yaml | 24 ++-- tests/components/ble_client/common.yaml | 4 +- tests/components/canbus/common.yaml | 6 +- tests/components/climate_ir_lg/common.yaml | 4 +- .../components/color_temperature/common.yaml | 8 +- tests/components/copy/common.yaml | 8 +- tests/components/current_based/common.yaml | 6 +- tests/components/cwww/common.yaml | 4 +- tests/components/cwww/test.esp32-idf.yaml | 4 +- tests/components/cwww/test.esp8266-ard.yaml | 4 +- tests/components/cwww/test.rp2040-ard.yaml | 4 +- tests/components/display/common.yaml | 2 +- tests/components/duty_time/common.yaml | 4 +- tests/components/e131/test.rp2040-ard.yaml | 2 +- tests/components/ektf2232/common.yaml | 4 +- tests/components/endstop/common.yaml | 12 +- tests/components/esp32_can/common.yaml | 2 +- .../esp32_can/test.esp32-c6-idf.yaml | 6 +- tests/components/espnow/common.yaml | 6 +- .../components/fastled_clockless/common.yaml | 6 +- tests/components/fastled_spi/common.yaml | 6 +- tests/components/font/common.yaml | 6 +- tests/components/font/test.host.yaml | 6 +- tests/components/graph/common.yaml | 2 +- .../graphical_display_menu/common.yaml | 17 +-- tests/components/gt911/common.yaml | 4 +- tests/components/image/test.esp32-idf.yaml | 2 +- tests/components/image/test.esp8266-ard.yaml | 2 +- tests/components/image/test.rp2040-ard.yaml | 2 +- .../components/integration/common-esp32.yaml | 4 +- .../integration/test.esp8266-ard.yaml | 4 +- .../integration/test.rp2040-ard.yaml | 4 +- tests/components/lcd_menu/common.yaml | 4 +- tests/components/light/common.yaml | 2 +- tests/components/light/test.esp32-idf.yaml | 2 +- tests/components/light/test.esp8266-ard.yaml | 2 +- .../components/light/test.nrf52-adafruit.yaml | 4 +- tests/components/light/test.nrf52-mcumgr.yaml | 4 +- tests/components/light/test.rp2040-ard.yaml | 2 +- tests/components/lilygo_t5_47/common.yaml | 4 +- tests/components/lock/common.yaml | 4 +- tests/components/mapping/test.esp32-idf.yaml | 2 +- .../components/mapping/test.esp8266-ard.yaml | 2 +- tests/components/mapping/test.rp2040-ard.yaml | 2 +- tests/components/monochromatic/common.yaml | 4 +- tests/components/mpr121/common.yaml | 6 +- tests/components/nextion/common.yaml | 4 +- .../components/nextion/common_tft_upload.yaml | 2 +- .../nextion/common_tft_upload_watchdog.yaml | 2 +- tests/components/ntc/common.yaml | 10 +- tests/components/number/common.yaml | 4 +- .../components/online_image/common-esp32.yaml | 2 +- .../online_image/common-esp8266.yaml | 2 +- .../online_image/common-rp2040.yaml | 2 +- .../online_image/test.esp32-s3-ard.yaml | 2 +- .../online_image/test.esp32-s3-idf.yaml | 2 +- tests/components/output/common.yaml | 12 +- tests/components/pi4ioe5v6408/common.yaml | 2 +- tests/components/pid/common.yaml | 6 +- tests/components/prometheus/common.yaml | 6 +- tests/components/qspi_dbi/common.yaml | 2 +- .../remote_transmitter/common-buttons.yaml | 6 +- tests/components/resistance/common.yaml | 6 +- tests/components/rgb/common.yaml | 8 +- tests/components/rgbct/common.yaml | 8 +- tests/components/rgbw/common.yaml | 8 +- tests/components/rgbww/common.yaml | 8 +- .../rp2040_pio_led_strip/common.yaml | 2 +- tests/components/rp2040_pwm/common.yaml | 4 +- tests/components/sdl/common.yaml | 8 +- tests/components/speaker/common.yaml | 4 +- tests/components/speed/common.yaml | 6 +- tests/components/sprinkler/common.yaml | 12 +- tests/components/ssd1306_i2c/common.yaml | 2 +- tests/components/switch/common.yaml | 2 +- tests/components/sx126x/common.yaml | 4 +- tests/components/sx127x/common.yaml | 4 +- tests/components/template/common-base.yaml | 14 +- tests/components/tt21100/common.yaml | 4 +- tests/components/uart/test.esp32-idf.yaml | 4 +- tests/components/udp/common.yaml | 4 +- tests/components/ufire_ec/common.yaml | 6 +- tests/components/ufire_ise/common.yaml | 4 +- tests/components/web_server_idf/common.yaml | 4 +- tests/components/wk2132_i2c/common.yaml | 2 +- tests/components/wk2132_spi/common.yaml | 2 +- tests/components/wk2168_i2c/common.yaml | 2 +- tests/components/wk2168_spi/common.yaml | 2 +- tests/components/wk2204_i2c/common.yaml | 2 +- tests/components/wk2204_spi/common.yaml | 2 +- tests/components/wk2212_i2c/common.yaml | 2 +- tests/components/wk2212_spi/common.yaml | 2 +- tests/script/test_merge_component_configs.py | 72 +++++++++++ 115 files changed, 482 insertions(+), 252 deletions(-) create mode 100755 script/ci_check_duplicate_test_ids.py create mode 100644 tests/script/test_merge_component_configs.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40267240d8..96c205fb70 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -113,6 +113,7 @@ jobs: script/build_language_schema.py --check script/generate-esp32-boards.py --check script/generate-rp2040-boards.py --check + script/ci_check_duplicate_test_ids.py import-time: name: Check import esphome.__main__ time diff --git a/script/ci_check_duplicate_test_ids.py b/script/ci_check_duplicate_test_ids.py new file mode 100755 index 0000000000..9d498dd64f --- /dev/null +++ b/script/ci_check_duplicate_test_ids.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +"""Fail when two component test fixtures define the same id with different content. + +Component tests are merged and built in groups in CI (see +``script/merge_component_configs.py``). When two components declare the same id +under the same section but with different content, the merge silently keeps the +first and drops the rest, which can make a cross-reference resolve to an +incompatible entity (this is what broke the i2s_audio speaker tests). The merge +now raises on such a collision, but only when the two components land in the same +group. This script is the complete, batch-independent guard: it scans every +component's ``test..yaml`` per platform and reports any id that is +defined by more than one component with differing content. + +Ids that are intentionally shared across components (e.g. a singleton +``sntp_time`` clock) are listed in ``INTENTIONALLY_SHARED_IDS`` and skipped. +""" + +from __future__ import annotations + +from collections import defaultdict +from pathlib import Path +import sys + +sys.path.insert(0, str(Path(__file__).parent.parent)) + +from script.merge_component_configs import ( # noqa: E402 + INTENTIONALLY_SHARED_IDS, + load_yaml_file, +) + +TESTS_DIR = Path("tests/components") + + +def _normalize(value: object) -> object: + """Return a hashable, order-independent representation for comparison.""" + if isinstance(value, dict): + return tuple(sorted((str(k), _normalize(v)) for k, v in value.items())) + if isinstance(value, (list, tuple)): + return tuple(_normalize(v) for v in value) + # Scalars (and ESPHome tag objects like !lambda) compare by their text form + return str(value) + + +def _collect_ids( + data: object, section: str, out: dict[tuple[str, str], object] +) -> None: + """Walk a parsed config and record (section, id) -> normalized content.""" + if isinstance(data, dict): + for key, value in data.items(): + if isinstance(value, list): + for item in value: + if isinstance(item, dict) and "id" in item: + out[(key, str(item["id"]))] = _normalize(item) + _collect_ids(item, key, out) + else: + _collect_ids(value, key, out) + elif isinstance(data, list): + for item in data: + _collect_ids(item, section, out) + + +def _discover_platforms() -> set[str]: + platforms: set[str] = set() + for test_file in TESTS_DIR.glob("*/test.*.yaml"): + # test..yaml -> platform is the middle dotted part + parts = test_file.name.split(".") + if len(parts) == 3: + platforms.add(parts[1]) + return platforms + + +def main() -> int: + conflicts: list[str] = [] + for platform in sorted(_discover_platforms()): + # (section, id) -> {normalized_content: [components]} + by_id: dict[tuple[str, str], dict[object, list[str]]] = defaultdict( + lambda: defaultdict(list) + ) + for comp_dir in sorted(TESTS_DIR.iterdir()): + if not comp_dir.is_dir(): + continue + test_file = comp_dir / f"test.{platform}.yaml" + if not test_file.exists(): + continue + try: + data = load_yaml_file(test_file) + except Exception as err: # noqa: BLE001 + print(f"WARNING: could not parse {test_file}: {err}", file=sys.stderr) + continue + ids: dict[tuple[str, str], object] = {} + _collect_ids(data, "", ids) + for (section, id_), content in ids.items(): + if id_ in INTENTIONALLY_SHARED_IDS: + continue + by_id[(section, id_)][content].append(comp_dir.name) + + for (section, id_), variants in sorted(by_id.items()): + if len(variants) < 2: + continue + components = sorted({c for comps in variants.values() for c in comps}) + conflicts.append( + f"[{platform}] id '{id_}' under '{section}' is defined " + f"differently by: {', '.join(components)}" + ) + + if conflicts: + print("Conflicting test component ids found:\n") + for line in conflicts: + print(f" - {line}") + print( + "\nGive each component a unique id (e.g. '_'), or add the " + "id to INTENTIONALLY_SHARED_IDS in script/merge_component_configs.py if " + "it is a deliberately shared singleton." + ) + return 1 + + print("No conflicting test component ids found.") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/script/merge_component_configs.py b/script/merge_component_configs.py index a952ecff16..20457e906a 100755 --- a/script/merge_component_configs.py +++ b/script/merge_component_configs.py @@ -161,18 +161,42 @@ def prefix_substitutions_in_dict( return data +# Ids that several components intentionally share. ESPHome treats these as a +# single instance when merged (e.g. multiple components each declaring the same +# `sntp_time` clock collapse into one), so duplicates with differing content are +# expected and must not be flagged as accidental collisions. +INTENTIONALLY_SHARED_IDS = frozenset( + { + # Several components each declare an `sntp_time` clock; ESPHome merges + # them into one time source. + "sntp_time", + # esp_ldo and mipi_dsi both configure the channel-3 internal LDO on the + # ESP32-P4; only one LDO per channel may exist, so the shared id lets the + # merge collapse them into a single LDO. + "ldo_id", + } +) + + def deduplicate_by_id(data: dict) -> dict: """Deduplicate list items with the same ID. - Keeps only the first occurrence of each ID. If items with the same ID - are identical, this silently deduplicates. If they differ, the first - one is kept (ESPHome's validation will catch if this causes issues). + Identical items sharing an ID (e.g. a shared bus from a common package pulled + in by several components) are collapsed to the first occurrence. Two items that + share an ID but differ in content are a real conflict: when merged, the first + one silently wins and the others are dropped, which can make cross-references + resolve to an incompatible entity. Rather than defer that to downstream + validation (where it surfaces as a confusing, order-dependent failure), raise + immediately so the offending ID is named. Args: data: Parsed config dictionary Returns: Config with deduplicated lists + + Raises: + ValueError: If two items share an ID but have different content. """ if not isinstance(data, dict): return data @@ -181,16 +205,26 @@ def deduplicate_by_id(data: dict) -> dict: for key, value in data.items(): if isinstance(value, list): # Check for items with 'id' field - seen_ids = set() + seen_items = {} deduped_list = [] for item in value: if isinstance(item, dict) and "id" in item: item_id = item["id"] - if item_id not in seen_ids: - seen_ids.add(item_id) + if item_id not in seen_items: + seen_items[item_id] = item deduped_list.append(item) - # else: skip duplicate ID (keep first occurrence) + elif item_id in INTENTIONALLY_SHARED_IDS: + # Designed singleton shared by several components (e.g. an + # `sntp_time` clock); ESPHome collapses these, so keep first. + pass + elif item != seen_items[item_id]: + raise ValueError( + f"Conflicting definitions for id '{item_id}' under " + f"'{key}' when merging test configs; give each " + f"component a unique id" + ) + # else: identical duplicate (e.g. shared bus package) -> skip else: # No ID, just add it deduped_list.append(item) diff --git a/tests/components/adc/test.bk72xx-ard.yaml b/tests/components/adc/test.bk72xx-ard.yaml index 0645333a81..09ef0e1fad 100644 --- a/tests/components/adc/test.bk72xx-ard.yaml +++ b/tests/components/adc/test.bk72xx-ard.yaml @@ -1,5 +1,5 @@ sensor: - - id: my_sensor + - id: adc_my_sensor platform: adc pin: P23 name: ADC Test sensor diff --git a/tests/components/adc/test.esp32-c2-idf.yaml b/tests/components/adc/test.esp32-c2-idf.yaml index e764f0fe21..a3019466b5 100644 --- a/tests/components/adc/test.esp32-c2-idf.yaml +++ b/tests/components/adc/test.esp32-c2-idf.yaml @@ -1,5 +1,5 @@ sensor: - - id: my_sensor + - id: adc_my_sensor platform: adc pin: GPIO1 name: ADC Test sensor diff --git a/tests/components/adc/test.esp32-c3-idf.yaml b/tests/components/adc/test.esp32-c3-idf.yaml index e764f0fe21..a3019466b5 100644 --- a/tests/components/adc/test.esp32-c3-idf.yaml +++ b/tests/components/adc/test.esp32-c3-idf.yaml @@ -1,5 +1,5 @@ sensor: - - id: my_sensor + - id: adc_my_sensor platform: adc pin: GPIO1 name: ADC Test sensor diff --git a/tests/components/adc/test.esp32-idf.yaml b/tests/components/adc/test.esp32-idf.yaml index ff1e3bb919..f31e0e087d 100644 --- a/tests/components/adc/test.esp32-idf.yaml +++ b/tests/components/adc/test.esp32-idf.yaml @@ -1,5 +1,5 @@ sensor: - - id: my_sensor + - id: adc_my_sensor platform: adc pin: A0 name: ADC Test sensor diff --git a/tests/components/adc/test.esp32-p4-idf.yaml b/tests/components/adc/test.esp32-p4-idf.yaml index b77dc299c2..77cf50d17c 100644 --- a/tests/components/adc/test.esp32-p4-idf.yaml +++ b/tests/components/adc/test.esp32-p4-idf.yaml @@ -1,5 +1,5 @@ sensor: - - id: my_sensor + - id: adc_my_sensor platform: adc pin: GPIO16 name: ADC Test sensor diff --git a/tests/components/adc/test.esp32-s2-idf.yaml b/tests/components/adc/test.esp32-s2-idf.yaml index e764f0fe21..a3019466b5 100644 --- a/tests/components/adc/test.esp32-s2-idf.yaml +++ b/tests/components/adc/test.esp32-s2-idf.yaml @@ -1,5 +1,5 @@ sensor: - - id: my_sensor + - id: adc_my_sensor platform: adc pin: GPIO1 name: ADC Test sensor diff --git a/tests/components/adc/test.esp32-s3-idf.yaml b/tests/components/adc/test.esp32-s3-idf.yaml index e764f0fe21..a3019466b5 100644 --- a/tests/components/adc/test.esp32-s3-idf.yaml +++ b/tests/components/adc/test.esp32-s3-idf.yaml @@ -1,5 +1,5 @@ sensor: - - id: my_sensor + - id: adc_my_sensor platform: adc pin: GPIO1 name: ADC Test sensor diff --git a/tests/components/adc/test.esp8266-ard.yaml b/tests/components/adc/test.esp8266-ard.yaml index 4cc865bb5d..617464818b 100644 --- a/tests/components/adc/test.esp8266-ard.yaml +++ b/tests/components/adc/test.esp8266-ard.yaml @@ -1,5 +1,5 @@ sensor: - - id: my_sensor + - id: adc_my_sensor platform: adc pin: VCC name: ADC Test sensor diff --git a/tests/components/adc/test.ln882x-ard.yaml b/tests/components/adc/test.ln882x-ard.yaml index face38b647..d899259773 100644 --- a/tests/components/adc/test.ln882x-ard.yaml +++ b/tests/components/adc/test.ln882x-ard.yaml @@ -1,5 +1,5 @@ sensor: - - id: my_sensor + - id: adc_my_sensor platform: adc pin: A5 name: ADC Test sensor diff --git a/tests/components/adc/test.rp2040-ard.yaml b/tests/components/adc/test.rp2040-ard.yaml index 4cc865bb5d..617464818b 100644 --- a/tests/components/adc/test.rp2040-ard.yaml +++ b/tests/components/adc/test.rp2040-ard.yaml @@ -1,5 +1,5 @@ sensor: - - id: my_sensor + - id: adc_my_sensor platform: adc pin: VCC name: ADC Test sensor diff --git a/tests/components/adc/test.rp2040-pico2-ard.yaml b/tests/components/adc/test.rp2040-pico2-ard.yaml index 4cc865bb5d..617464818b 100644 --- a/tests/components/adc/test.rp2040-pico2-ard.yaml +++ b/tests/components/adc/test.rp2040-pico2-ard.yaml @@ -1,5 +1,5 @@ sensor: - - id: my_sensor + - id: adc_my_sensor platform: adc pin: VCC name: ADC Test sensor diff --git a/tests/components/alarm_control_panel/common.yaml b/tests/components/alarm_control_panel/common.yaml index 39d5739255..327234d6ca 100644 --- a/tests/components/alarm_control_panel/common.yaml +++ b/tests/components/alarm_control_panel/common.yaml @@ -1,6 +1,6 @@ binary_sensor: - platform: gpio - id: bin1 + id: alarm_control_panel_bin1 pin: 1 alarm_control_panel: @@ -18,7 +18,7 @@ alarm_control_panel: pending_time: 15s trigger_time: 30s binary_sensors: - - input: bin1 + - input: alarm_control_panel_bin1 bypass_armed_home: true bypass_armed_night: true bypass_auto: true @@ -39,7 +39,7 @@ alarm_control_panel: pending_time: 15s trigger_time: 30s binary_sensors: - - input: bin1 + - input: alarm_control_panel_bin1 bypass_armed_home: true bypass_armed_night: true bypass_auto: true diff --git a/tests/components/animation/test.esp32-idf.yaml b/tests/components/animation/test.esp32-idf.yaml index c28e9584dd..b844f5ae92 100644 --- a/tests/components/animation/test.esp32-idf.yaml +++ b/tests/components/animation/test.esp32-idf.yaml @@ -4,7 +4,7 @@ packages: display: - platform: ili9xxx - id: main_lcd + id: animation_main_lcd spi_id: spi_bus model: ili9342 cs_pin: 12 diff --git a/tests/components/animation/test.esp8266-ard.yaml b/tests/components/animation/test.esp8266-ard.yaml index 11a7117d91..a7937ffca2 100644 --- a/tests/components/animation/test.esp8266-ard.yaml +++ b/tests/components/animation/test.esp8266-ard.yaml @@ -4,7 +4,7 @@ packages: display: - platform: ili9xxx - id: main_lcd + id: animation_main_lcd spi_id: spi_bus model: ili9342 cs_pin: 5 diff --git a/tests/components/animation/test.rp2040-ard.yaml b/tests/components/animation/test.rp2040-ard.yaml index 2c99e937f3..2cbb254adf 100644 --- a/tests/components/animation/test.rp2040-ard.yaml +++ b/tests/components/animation/test.rp2040-ard.yaml @@ -4,7 +4,7 @@ packages: display: - platform: ili9xxx - id: main_lcd + id: animation_main_lcd spi_id: spi_bus model: ili9342 cs_pin: 20 diff --git a/tests/components/axs15231/common.yaml b/tests/components/axs15231/common.yaml index d4fd3becbb..03e82ab26e 100644 --- a/tests/components/axs15231/common.yaml +++ b/tests/components/axs15231/common.yaml @@ -1,7 +1,7 @@ display: - platform: ssd1306_i2c i2c_id: i2c_bus - id: ssd1306_i2c_display + id: axs15231_ssd1306_i2c_display model: SSD1306_128X64 reset_pin: 19 pages: @@ -13,6 +13,6 @@ touchscreen: - platform: axs15231 i2c_id: i2c_bus id: axs15231_touchscreen - display: ssd1306_i2c_display + display: axs15231_ssd1306_i2c_display interrupt_pin: 20 reset_pin: 18 diff --git a/tests/components/axs15231/test.esp8266-ard.yaml b/tests/components/axs15231/test.esp8266-ard.yaml index eb599da773..245b87bec9 100644 --- a/tests/components/axs15231/test.esp8266-ard.yaml +++ b/tests/components/axs15231/test.esp8266-ard.yaml @@ -4,7 +4,7 @@ packages: display: - platform: ssd1306_i2c i2c_id: i2c_bus - id: ssd1306_display + id: axs15231_ssd1306_display model: SSD1306_128X64 reset_pin: 13 pages: @@ -15,5 +15,5 @@ display: touchscreen: - platform: axs15231 i2c_id: i2c_bus - display: ssd1306_display + display: axs15231_ssd1306_display interrupt_pin: 12 diff --git a/tests/components/bang_bang/common.yaml b/tests/components/bang_bang/common.yaml index 5882025191..28798f8173 100644 --- a/tests/components/bang_bang/common.yaml +++ b/tests/components/bang_bang/common.yaml @@ -1,6 +1,6 @@ switch: - platform: template - id: template_switch1 + id: bang_bang_template_switch1 optimistic: true - platform: template id: template_switch2 @@ -8,7 +8,7 @@ switch: sensor: - platform: template - id: template_sensor1 + id: bang_bang_template_sensor1 lambda: |- if (millis() > 10000) { return 42.0; @@ -20,16 +20,16 @@ sensor: climate: - platform: bang_bang name: Bang Bang Climate - sensor: template_sensor1 - humidity_sensor: template_sensor1 + sensor: bang_bang_template_sensor1 + humidity_sensor: bang_bang_template_sensor1 default_target_temperature_low: 18°C default_target_temperature_high: 24°C idle_action: - - switch.turn_on: template_switch1 + - switch.turn_on: bang_bang_template_switch1 cool_action: - switch.turn_on: template_switch2 heat_action: - - switch.turn_on: template_switch1 + - switch.turn_on: bang_bang_template_switch1 away_config: default_target_temperature_low: 16°C default_target_temperature_high: 20°C diff --git a/tests/components/binary_sensor/common.yaml b/tests/components/binary_sensor/common.yaml index e3fd159b08..4f4cf6ea59 100644 --- a/tests/components/binary_sensor/common.yaml +++ b/tests/components/binary_sensor/common.yaml @@ -1,7 +1,7 @@ binary_sensor: - platform: template trigger_on_initial_state: true - id: some_binary_sensor + id: binary_sensor_some_binary_sensor name: "Random binary" lambda: return (random_uint32() & 1) == 0; filters: @@ -21,7 +21,7 @@ binary_sensor: time_off: 100ms time_on: 400ms - lambda: |- - if (id(some_binary_sensor).state) { + if (id(binary_sensor_some_binary_sensor).state) { return x; } return {}; @@ -36,7 +36,7 @@ binary_sensor: - logger.log: format: "New state is %s" args: ['x.has_value() ? ONOFF(x) : "Unknown"'] - - binary_sensor.invalidate_state: some_binary_sensor + - binary_sensor.invalidate_state: binary_sensor_some_binary_sensor # Test autorepeat with default configuration (no timings) - platform: template diff --git a/tests/components/binary_sensor_map/common.yaml b/tests/components/binary_sensor_map/common.yaml index c054022583..667d0be9e7 100644 --- a/tests/components/binary_sensor_map/common.yaml +++ b/tests/components/binary_sensor_map/common.yaml @@ -1,20 +1,20 @@ binary_sensor: - platform: template - id: bin1 + id: binary_sensor_map_bin1 lambda: |- if (millis() > 10000) { return true; } return false; - platform: template - id: bin2 + id: binary_sensor_map_bin2 lambda: |- if (millis() > 20000) { return true; } return false; - platform: template - id: bin3 + id: binary_sensor_map_bin3 lambda: |- if (millis() > 30000) { return true; @@ -26,33 +26,33 @@ sensor: name: Binary Sensor Map Group type: group channels: - - binary_sensor: bin1 + - binary_sensor: binary_sensor_map_bin1 value: 10.0 - - binary_sensor: bin2 + - binary_sensor: binary_sensor_map_bin2 value: 15.0 - - binary_sensor: bin3 + - binary_sensor: binary_sensor_map_bin3 value: 100.0 - platform: binary_sensor_map name: Binary Sensor Map Sum type: sum channels: - - binary_sensor: bin1 + - binary_sensor: binary_sensor_map_bin1 value: 10.0 - - binary_sensor: bin2 + - binary_sensor: binary_sensor_map_bin2 value: 15.0 - - binary_sensor: bin3 + - binary_sensor: binary_sensor_map_bin3 value: 100.0 - platform: binary_sensor_map name: Binary Sensor Map Bayesian type: bayesian prior: 0.4 observations: - - binary_sensor: bin1 + - binary_sensor: binary_sensor_map_bin1 prob_given_true: 0.9 prob_given_false: 0.4 - - binary_sensor: bin2 + - binary_sensor: binary_sensor_map_bin2 prob_given_true: 0.7 prob_given_false: 0.05 - - binary_sensor: bin3 + - binary_sensor: binary_sensor_map_bin3 prob_given_true: 0.8 prob_given_false: 0.2 diff --git a/tests/components/ble_client/common.yaml b/tests/components/ble_client/common.yaml index 4ea1dd60f3..4ed6ad7fc9 100644 --- a/tests/components/ble_client/common.yaml +++ b/tests/components/ble_client/common.yaml @@ -56,7 +56,7 @@ sensor: number: - platform: template name: "Test Number" - id: test_number + id: ble_client_test_number optimistic: true min_value: 0 max_value: 255 @@ -72,5 +72,5 @@ button: service_uuid: "abcd1234-abcd-1234-abcd-abcd12345678" characteristic_uuid: "abcd1235-abcd-1234-abcd-abcd12345678" value: !lambda |- - uint8_t val = (uint8_t)id(test_number).state; + uint8_t val = (uint8_t)id(ble_client_test_number).state; return std::vector{0xAA, val, 0xBB}; diff --git a/tests/components/canbus/common.yaml b/tests/components/canbus/common.yaml index e779f7f078..3ba3564608 100644 --- a/tests/components/canbus/common.yaml +++ b/tests/components/canbus/common.yaml @@ -1,6 +1,6 @@ canbus: - platform: esp32_can - id: esp32_internal_can + id: canbus_esp32_internal_can rx_pin: 4 tx_pin: 5 can_id: 4 @@ -40,7 +40,7 @@ canbus: number: - platform: template name: "Test Number" - id: test_number + id: canbus_test_number optimistic: true min_value: 0 max_value: 255 @@ -62,5 +62,5 @@ button: - canbus.send: !lambda return {0, 1, 2}; # Test canbus.send with lambda that references a component (function pointer) - canbus.send: !lambda |- - uint8_t val = (uint8_t)id(test_number).state; + uint8_t val = (uint8_t)id(canbus_test_number).state; return std::vector{0xAA, val, 0xBB}; diff --git a/tests/components/climate_ir_lg/common.yaml b/tests/components/climate_ir_lg/common.yaml index 37011b16ee..e0bc185d2c 100644 --- a/tests/components/climate_ir_lg/common.yaml +++ b/tests/components/climate_ir_lg/common.yaml @@ -1,6 +1,6 @@ sensor: - platform: template - id: temp_sensor + id: climate_ir_lg_temp_sensor lambda: return 22.0; update_interval: 60s - platform: template @@ -12,5 +12,5 @@ climate: - platform: climate_ir_lg name: LG Climate transmitter_id: xmitr - sensor: temp_sensor + sensor: climate_ir_lg_temp_sensor humidity_sensor: humidity_sensor diff --git a/tests/components/color_temperature/common.yaml b/tests/components/color_temperature/common.yaml index fe0c5bf917..0db54d10d0 100644 --- a/tests/components/color_temperature/common.yaml +++ b/tests/components/color_temperature/common.yaml @@ -1,15 +1,15 @@ output: - platform: ${light_platform} - id: light_output_1 + id: color_temperature_light_output_1 pin: ${pin_o1} - platform: ${light_platform} - id: light_output_2 + id: color_temperature_light_output_2 pin: ${pin_o2} light: - platform: color_temperature name: Lights - color_temperature: light_output_1 - brightness: light_output_2 + color_temperature: color_temperature_light_output_1 + brightness: color_temperature_light_output_2 cold_white_color_temperature: 153 mireds warm_white_color_temperature: 500 mireds diff --git a/tests/components/copy/common.yaml b/tests/components/copy/common.yaml index a376004b2f..cbd056f070 100644 --- a/tests/components/copy/common.yaml +++ b/tests/components/copy/common.yaml @@ -1,17 +1,17 @@ output: - platform: ${pwm_platform} - id: fan_output_1 + id: copy_fan_output_1 pin: ${pin} fan: - platform: speed - id: fan_speed - output: fan_output_1 + id: copy_fan_speed + output: copy_fan_output_1 preset_modes: - Eco - Turbo - platform: copy - source_id: fan_speed + source_id: copy_fan_speed name: Fan Speed Copy select: diff --git a/tests/components/current_based/common.yaml b/tests/components/current_based/common.yaml index 503c4596e9..139571ccec 100644 --- a/tests/components/current_based/common.yaml +++ b/tests/components/current_based/common.yaml @@ -31,7 +31,7 @@ sensor: switch: - platform: template - id: template_switch1 + id: current_based_template_switch1 optimistic: true - platform: template id: template_switch2 @@ -46,7 +46,7 @@ cover: open_obstacle_current_threshold: 0.8 open_duration: 12s open_action: - - switch.turn_on: template_switch1 + - switch.turn_on: current_based_template_switch1 close_sensor: ade7953_current_b close_moving_current_threshold: 0.5 close_obstacle_current_threshold: 0.8 @@ -54,7 +54,7 @@ cover: close_action: - switch.turn_on: template_switch2 stop_action: - - switch.turn_off: template_switch1 + - switch.turn_off: current_based_template_switch1 - switch.turn_off: template_switch2 obstacle_rollback: 30% start_sensing_delay: 0.8s diff --git a/tests/components/cwww/common.yaml b/tests/components/cwww/common.yaml index 7fa5ab668c..bbb6c9182b 100644 --- a/tests/components/cwww/common.yaml +++ b/tests/components/cwww/common.yaml @@ -1,8 +1,8 @@ light: - platform: cwww name: CWWW Light - cold_white: light_output_1 - warm_white: light_output_2 + cold_white: cwww_light_output_1 + warm_white: cwww_light_output_2 cold_white_color_temperature: 153 mireds warm_white_color_temperature: 500 mireds constant_brightness: true diff --git a/tests/components/cwww/test.esp32-idf.yaml b/tests/components/cwww/test.esp32-idf.yaml index 01edf0b0b5..0665879b08 100644 --- a/tests/components/cwww/test.esp32-idf.yaml +++ b/tests/components/cwww/test.esp32-idf.yaml @@ -5,11 +5,11 @@ substitutions: output: - platform: ${light_platform} - id: light_output_1 + id: cwww_light_output_1 pin: ${pin_o1} channel: 0 - platform: ${light_platform} - id: light_output_2 + id: cwww_light_output_2 pin: ${pin_o2} channel: 1 phase_angle: 180° diff --git a/tests/components/cwww/test.esp8266-ard.yaml b/tests/components/cwww/test.esp8266-ard.yaml index 49d73b7d3d..bb1868fdef 100644 --- a/tests/components/cwww/test.esp8266-ard.yaml +++ b/tests/components/cwww/test.esp8266-ard.yaml @@ -5,10 +5,10 @@ substitutions: output: - platform: ${light_platform} - id: light_output_1 + id: cwww_light_output_1 pin: ${pin_o1} - platform: ${light_platform} - id: light_output_2 + id: cwww_light_output_2 pin: ${pin_o2} <<: !include common.yaml diff --git a/tests/components/cwww/test.rp2040-ard.yaml b/tests/components/cwww/test.rp2040-ard.yaml index ba8e0ad071..27fc930b68 100644 --- a/tests/components/cwww/test.rp2040-ard.yaml +++ b/tests/components/cwww/test.rp2040-ard.yaml @@ -5,10 +5,10 @@ substitutions: output: - platform: ${light_platform} - id: light_output_1 + id: cwww_light_output_1 pin: ${pin_o1} - platform: ${light_platform} - id: light_output_2 + id: cwww_light_output_2 pin: ${pin_o2} <<: !include common.yaml diff --git a/tests/components/display/common.yaml b/tests/components/display/common.yaml index a722a5f7c2..6617671972 100644 --- a/tests/components/display/common.yaml +++ b/tests/components/display/common.yaml @@ -1,6 +1,6 @@ display: - platform: ili9xxx - id: main_lcd + id: display_main_lcd model: ili9342 cs_pin: 12 dc_pin: 13 diff --git a/tests/components/duty_time/common.yaml b/tests/components/duty_time/common.yaml index 761d10f16a..12e4397c49 100644 --- a/tests/components/duty_time/common.yaml +++ b/tests/components/duty_time/common.yaml @@ -1,6 +1,6 @@ binary_sensor: - platform: template - id: bin1 + id: duty_time_bin1 lambda: |- if (millis() > 10000) { return true; @@ -10,4 +10,4 @@ binary_sensor: sensor: - platform: duty_time name: Duty Time - sensor: bin1 + sensor: duty_time_bin1 diff --git a/tests/components/e131/test.rp2040-ard.yaml b/tests/components/e131/test.rp2040-ard.yaml index 25fe3b6796..4593784ef9 100644 --- a/tests/components/e131/test.rp2040-ard.yaml +++ b/tests/components/e131/test.rp2040-ard.yaml @@ -2,7 +2,7 @@ light: - platform: rp2040_pio_led_strip - id: led_strip + id: e131_led_strip pin: 2 pio: 0 num_leds: 256 diff --git a/tests/components/ektf2232/common.yaml b/tests/components/ektf2232/common.yaml index 1c4d768b08..070b03eeb9 100644 --- a/tests/components/ektf2232/common.yaml +++ b/tests/components/ektf2232/common.yaml @@ -1,7 +1,7 @@ display: - platform: ssd1306_i2c i2c_id: i2c_bus - id: ssd1306_i2c_display + id: ektf2232_ssd1306_i2c_display model: SSD1306_128X64 reset_pin: ${display_reset_pin} pages: @@ -15,7 +15,7 @@ touchscreen: id: ektf2232_touchscreen interrupt_pin: ${interrupt_pin} reset_pin: ${touch_reset_pin} - display: ssd1306_i2c_display + display: ektf2232_ssd1306_i2c_display on_touch: - logger.log: format: Touch at (%d, %d) diff --git a/tests/components/endstop/common.yaml b/tests/components/endstop/common.yaml index b92b1e13b9..6f5cf61268 100644 --- a/tests/components/endstop/common.yaml +++ b/tests/components/endstop/common.yaml @@ -1,6 +1,6 @@ binary_sensor: - platform: template - id: bin1 + id: endstop_bin1 lambda: |- if (millis() > 10000) { return true; @@ -9,7 +9,7 @@ binary_sensor: switch: - platform: template - id: template_switch1 + id: endstop_template_switch1 optimistic: true - platform: template id: template_switch2 @@ -20,12 +20,12 @@ cover: id: endstop_cover name: Endstop Cover stop_action: - - switch.turn_on: template_switch1 - open_endstop: bin1 + - switch.turn_on: endstop_template_switch1 + open_endstop: endstop_bin1 open_action: - - switch.turn_on: template_switch1 + - switch.turn_on: endstop_template_switch1 open_duration: 5min - close_endstop: bin1 + close_endstop: endstop_bin1 close_action: - switch.turn_on: template_switch2 close_duration: 4.5min diff --git a/tests/components/esp32_can/common.yaml b/tests/components/esp32_can/common.yaml index 3b9b33c048..f15b609d84 100644 --- a/tests/components/esp32_can/common.yaml +++ b/tests/components/esp32_can/common.yaml @@ -13,7 +13,7 @@ esphome: canbus: - platform: esp32_can - id: esp32_internal_can + id: esp32_can_esp32_internal_can rx_pin: ${rx_pin} tx_pin: ${tx_pin} can_id: 4 diff --git a/tests/components/esp32_can/test.esp32-c6-idf.yaml b/tests/components/esp32_can/test.esp32-c6-idf.yaml index ac978482fc..c548b4f0f4 100644 --- a/tests/components/esp32_can/test.esp32-c6-idf.yaml +++ b/tests/components/esp32_can/test.esp32-c6-idf.yaml @@ -3,20 +3,20 @@ esphome: then: - canbus.send: # Extended ID explicit - canbus_id: esp32_internal_can + canbus_id: esp32_can_esp32_internal_can use_extended_id: true can_id: 0x100 data: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] - canbus.send: # Standard ID by default - canbus_id: esp32_internal_can + canbus_id: esp32_can_esp32_internal_can can_id: 0x100 data: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] # Note: esp32_internal_can_2 uses LISTENONLY mode, so no send actions canbus: - platform: esp32_can - id: esp32_internal_can + id: esp32_can_esp32_internal_can rx_pin: GPIO8 tx_pin: GPIO7 can_id: 4 diff --git a/tests/components/espnow/common.yaml b/tests/components/espnow/common.yaml index bdc478ea03..f05735e8f4 100644 --- a/tests/components/espnow/common.yaml +++ b/tests/components/espnow/common.yaml @@ -62,7 +62,7 @@ packet_transport: encryption: key: "0123456789abcdef0123456789abcdef" sensors: - - temp_sensor + - espnow_temp_sensor providers: - name: test-provider encryption: @@ -70,9 +70,9 @@ packet_transport: sensor: - platform: internal_temperature - id: temp_sensor + id: espnow_temp_sensor - platform: packet_transport provider: test-provider - remote_id: temp_sensor + remote_id: espnow_temp_sensor id: remote_temp diff --git a/tests/components/fastled_clockless/common.yaml b/tests/components/fastled_clockless/common.yaml index 8b1447a17a..a7ce7ed280 100644 --- a/tests/components/fastled_clockless/common.yaml +++ b/tests/components/fastled_clockless/common.yaml @@ -1,6 +1,6 @@ light: - platform: fastled_clockless - id: addr1 + id: fastled_clockless_addr1 chipset: WS2811 pin: 13 num_leds: 100 @@ -59,13 +59,13 @@ light: name: Custom Effect sequence: - light.addressable_set: - id: addr1 + id: fastled_clockless_addr1 red: 100% green: 100% blue: 0% - delay: 100ms - light.addressable_set: - id: addr1 + id: fastled_clockless_addr1 red: 0% green: 100% blue: 0% diff --git a/tests/components/fastled_spi/common.yaml b/tests/components/fastled_spi/common.yaml index f6f7c5553b..19d00627f8 100644 --- a/tests/components/fastled_spi/common.yaml +++ b/tests/components/fastled_spi/common.yaml @@ -1,6 +1,6 @@ light: - platform: fastled_spi - id: addr1 + id: fastled_spi_addr1 chipset: WS2801 clock_pin: 22 data_pin: 23 @@ -59,13 +59,13 @@ light: name: Custom Effect sequence: - light.addressable_set: - id: addr1 + id: fastled_spi_addr1 red: 100% green: 100% blue: 0% - delay: 100ms - light.addressable_set: - id: addr1 + id: fastled_spi_addr1 red: 0% green: 100% blue: 0% diff --git a/tests/components/font/common.yaml b/tests/components/font/common.yaml index c156b4aea1..59063291e7 100644 --- a/tests/components/font/common.yaml +++ b/tests/components/font/common.yaml @@ -8,7 +8,7 @@ font: id: roboto32 - file: "gfonts://Roboto" - id: roboto + id: font_roboto size: 20 glyphs: "0123456789." extras: @@ -50,11 +50,11 @@ font: display: - platform: ssd1306_i2c i2c_id: i2c_bus - id: ssd1306_display + id: font_ssd1306_display model: SSD1306_128X64 reset_pin: ${display_reset_pin} lambda: |- - it.print(0, 0, id(roboto), "Hello, World!"); + it.print(0, 0, id(font_roboto), "Hello, World!"); it.print(0, 20, id(roboto_web), "Hello, World!"); it.print(0, 40, id(monocraft), "Hello, World!"); it.print(0, 60, id(monocraft2), "Hello, World!"); diff --git a/tests/components/font/test.host.yaml b/tests/components/font/test.host.yaml index 387ea47335..8ada8b7a4e 100644 --- a/tests/components/font/test.host.yaml +++ b/tests/components/font/test.host.yaml @@ -8,7 +8,7 @@ font: id: roboto32 - file: "gfonts://Roboto" - id: roboto + id: font_roboto size: 20 glyphs: "0123456789." extras: @@ -44,12 +44,12 @@ font: display: - platform: sdl - id: sdl_display + id: font_sdl_display dimensions: width: 800 height: 600 lambda: |- - it.print(0, 0, id(roboto), "Hello, World!"); + it.print(0, 0, id(font_roboto), "Hello, World!"); it.print(0, 20, id(roboto_web), "Hello, World!"); it.print(0, 40, id(roboto_greek), "Hello κόσμε!"); it.print(0, 60, id(monocraft), "Hello, World!"); diff --git a/tests/components/graph/common.yaml b/tests/components/graph/common.yaml index 11e2a16ca1..edf4493aa6 100644 --- a/tests/components/graph/common.yaml +++ b/tests/components/graph/common.yaml @@ -12,7 +12,7 @@ graph: display: - platform: ssd1306_i2c i2c_id: i2c_bus - id: ssd1306_display + id: graph_ssd1306_display model: SSD1306_128X64 reset_pin: ${reset_pin} pages: diff --git a/tests/components/graphical_display_menu/common.yaml b/tests/components/graphical_display_menu/common.yaml index 6cee2af232..50f8a5bc85 100644 --- a/tests/components/graphical_display_menu/common.yaml +++ b/tests/components/graphical_display_menu/common.yaml @@ -1,6 +1,7 @@ display: - platform: ssd1306_i2c - id: ssd1306_i2c_display + i2c_id: i2c_bus + id: graphical_display_menu_ssd1306_i2c_display model: SSD1306_128X64 reset_pin: ${reset_pin} pages: @@ -10,12 +11,12 @@ display: font: - file: "gfonts://Roboto" - id: roboto + id: graphical_display_menu_roboto size: 20 number: - platform: template - id: test_number + id: graphical_display_menu_test_number min_value: 0 step: 1 max_value: 10 @@ -31,13 +32,13 @@ select: switch: - platform: template - id: test_switch + id: graphical_display_menu_test_switch optimistic: true graphical_display_menu: id: test_graphical_display_menu - display: ssd1306_i2c_display - font: roboto + display: graphical_display_menu_ssd1306_i2c_display + font: graphical_display_menu_roboto active: false mode: rotary on_enter: @@ -80,7 +81,7 @@ graphical_display_menu: lambda: 'ESP_LOGI("graphical_display_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - type: number text: "Number" - number: test_number + number: graphical_display_menu_test_number on_enter: then: lambda: 'ESP_LOGI("graphical_display_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' @@ -97,7 +98,7 @@ graphical_display_menu: - display_menu.hide: test_graphical_display_menu - type: switch text: "Switch" - switch: test_switch + switch: graphical_display_menu_test_switch on_text: "Bright" off_text: "Dark" immediate_edit: false diff --git a/tests/components/gt911/common.yaml b/tests/components/gt911/common.yaml index ff464cda24..0fc40737f0 100644 --- a/tests/components/gt911/common.yaml +++ b/tests/components/gt911/common.yaml @@ -1,7 +1,7 @@ display: - platform: ssd1306_i2c i2c_id: i2c_bus - id: ssd1306_i2c_display + id: gt911_ssd1306_i2c_display model: SSD1306_128X64 reset_pin: ${display_reset_pin} pages: @@ -13,7 +13,7 @@ touchscreen: - platform: gt911 i2c_id: i2c_bus id: gt911_touchscreen - display: ssd1306_i2c_display + display: gt911_ssd1306_i2c_display interrupt_pin: ${interrupt_pin} reset_pin: ${reset_pin} diff --git a/tests/components/image/test.esp32-idf.yaml b/tests/components/image/test.esp32-idf.yaml index aea2b4bbb0..9e93c4c289 100644 --- a/tests/components/image/test.esp32-idf.yaml +++ b/tests/components/image/test.esp32-idf.yaml @@ -3,7 +3,7 @@ packages: display: - platform: ili9xxx - id: main_lcd + id: image_main_lcd spi_id: spi_bus model: ili9342 cs_pin: 15 diff --git a/tests/components/image/test.esp8266-ard.yaml b/tests/components/image/test.esp8266-ard.yaml index 2e7bfc5ae5..492b57c449 100644 --- a/tests/components/image/test.esp8266-ard.yaml +++ b/tests/components/image/test.esp8266-ard.yaml @@ -3,7 +3,7 @@ packages: display: - platform: ili9xxx - id: main_lcd + id: image_main_lcd spi_id: spi_bus model: ili9342 cs_pin: 5 diff --git a/tests/components/image/test.rp2040-ard.yaml b/tests/components/image/test.rp2040-ard.yaml index 03a9c42a38..ce2a13fca7 100644 --- a/tests/components/image/test.rp2040-ard.yaml +++ b/tests/components/image/test.rp2040-ard.yaml @@ -3,7 +3,7 @@ packages: display: - platform: ili9xxx - id: main_lcd + id: image_main_lcd spi_id: spi_bus model: ili9342 cs_pin: 20 diff --git a/tests/components/integration/common-esp32.yaml b/tests/components/integration/common-esp32.yaml index 26550d3c5c..c912fb9b84 100644 --- a/tests/components/integration/common-esp32.yaml +++ b/tests/components/integration/common-esp32.yaml @@ -9,11 +9,11 @@ esphome: sensor: - platform: adc - id: my_sensor + id: integration_my_sensor pin: ${pin} attenuation: 12db - platform: integration id: integration_sensor - sensor: my_sensor + sensor: integration_my_sensor name: Integration Sensor time_unit: s diff --git a/tests/components/integration/test.esp8266-ard.yaml b/tests/components/integration/test.esp8266-ard.yaml index 51d3e19077..377bad5578 100644 --- a/tests/components/integration/test.esp8266-ard.yaml +++ b/tests/components/integration/test.esp8266-ard.yaml @@ -1,8 +1,8 @@ sensor: - platform: adc - id: my_sensor + id: integration_my_sensor pin: VCC - platform: integration - sensor: my_sensor + sensor: integration_my_sensor name: Integration Sensor time_unit: s diff --git a/tests/components/integration/test.rp2040-ard.yaml b/tests/components/integration/test.rp2040-ard.yaml index 51d3e19077..377bad5578 100644 --- a/tests/components/integration/test.rp2040-ard.yaml +++ b/tests/components/integration/test.rp2040-ard.yaml @@ -1,8 +1,8 @@ sensor: - platform: adc - id: my_sensor + id: integration_my_sensor pin: VCC - platform: integration - sensor: my_sensor + sensor: integration_my_sensor name: Integration Sensor time_unit: s diff --git a/tests/components/lcd_menu/common.yaml b/tests/components/lcd_menu/common.yaml index 970c18e0d2..a7740e771d 100644 --- a/tests/components/lcd_menu/common.yaml +++ b/tests/components/lcd_menu/common.yaml @@ -1,6 +1,6 @@ number: - platform: template - id: test_number + id: lcd_menu_test_number min_value: 0 step: 1 max_value: 10 @@ -83,7 +83,7 @@ lcd_menu: lambda: 'ESP_LOGI("lcd_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - type: number text: Number - number: test_number + number: lcd_menu_test_number on_enter: then: lambda: 'ESP_LOGI("lcd_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' diff --git a/tests/components/light/common.yaml b/tests/components/light/common.yaml index 2acc080c6d..71c00e5f10 100644 --- a/tests/components/light/common.yaml +++ b/tests/components/light/common.yaml @@ -156,7 +156,7 @@ light: - platform: binary id: test_binary_light name: Binary Light - output: test_binary + output: light_test_binary effects: - strobe: on_state: diff --git a/tests/components/light/test.esp32-idf.yaml b/tests/components/light/test.esp32-idf.yaml index 925197182c..49e49b4318 100644 --- a/tests/components/light/test.esp32-idf.yaml +++ b/tests/components/light/test.esp32-idf.yaml @@ -1,6 +1,6 @@ output: - platform: gpio - id: test_binary + id: light_test_binary pin: 12 - platform: ledc id: test_ledc_1 diff --git a/tests/components/light/test.esp8266-ard.yaml b/tests/components/light/test.esp8266-ard.yaml index 518011e925..1eb58eabc4 100644 --- a/tests/components/light/test.esp8266-ard.yaml +++ b/tests/components/light/test.esp8266-ard.yaml @@ -1,6 +1,6 @@ output: - platform: gpio - id: test_binary + id: light_test_binary pin: 4 - platform: esp8266_pwm id: test_ledc_1 diff --git a/tests/components/light/test.nrf52-adafruit.yaml b/tests/components/light/test.nrf52-adafruit.yaml index cb421ed4bb..60521b8088 100644 --- a/tests/components/light/test.nrf52-adafruit.yaml +++ b/tests/components/light/test.nrf52-adafruit.yaml @@ -5,14 +5,14 @@ esphome: output: - platform: gpio - id: test_binary + id: light_test_binary pin: 0 light: - platform: binary id: test_binary_light name: Binary Light - output: test_binary + output: light_test_binary effects: - strobe: on_state: diff --git a/tests/components/light/test.nrf52-mcumgr.yaml b/tests/components/light/test.nrf52-mcumgr.yaml index cb421ed4bb..60521b8088 100644 --- a/tests/components/light/test.nrf52-mcumgr.yaml +++ b/tests/components/light/test.nrf52-mcumgr.yaml @@ -5,14 +5,14 @@ esphome: output: - platform: gpio - id: test_binary + id: light_test_binary pin: 0 light: - platform: binary id: test_binary_light name: Binary Light - output: test_binary + output: light_test_binary effects: - strobe: on_state: diff --git a/tests/components/light/test.rp2040-ard.yaml b/tests/components/light/test.rp2040-ard.yaml index a5a37fd559..21d5cad774 100644 --- a/tests/components/light/test.rp2040-ard.yaml +++ b/tests/components/light/test.rp2040-ard.yaml @@ -1,6 +1,6 @@ output: - platform: gpio - id: test_binary + id: light_test_binary pin: 0 - platform: rp2040_pwm id: test_ledc_1 diff --git a/tests/components/lilygo_t5_47/common.yaml b/tests/components/lilygo_t5_47/common.yaml index 18f1ba10ae..5e71736eb0 100644 --- a/tests/components/lilygo_t5_47/common.yaml +++ b/tests/components/lilygo_t5_47/common.yaml @@ -1,7 +1,7 @@ display: - platform: ssd1306_i2c i2c_id: i2c_bus - id: ssd1306_i2c_display + id: lilygo_t5_47_ssd1306_i2c_display model: SSD1306_128X64 reset_pin: ${reset_pin} pages: @@ -14,7 +14,7 @@ touchscreen: i2c_id: i2c_bus id: lilygo_touchscreen interrupt_pin: ${interrupt_pin} - display: ssd1306_i2c_display + display: lilygo_t5_47_ssd1306_i2c_display on_touch: - logger.log: format: Touch at (%d, %d) diff --git a/tests/components/lock/common.yaml b/tests/components/lock/common.yaml index 9ba7f34857..08001855cb 100644 --- a/tests/components/lock/common.yaml +++ b/tests/components/lock/common.yaml @@ -7,7 +7,7 @@ esphome: output: - platform: gpio - id: test_binary + id: lock_test_binary pin: 4 lock: @@ -32,4 +32,4 @@ lock: - platform: output name: Generic Output Lock id: test_lock2 - output: test_binary + output: lock_test_binary diff --git a/tests/components/mapping/test.esp32-idf.yaml b/tests/components/mapping/test.esp32-idf.yaml index 93adcf9988..d99f8ddc4e 100644 --- a/tests/components/mapping/test.esp32-idf.yaml +++ b/tests/components/mapping/test.esp32-idf.yaml @@ -5,7 +5,7 @@ packages: display: spi_id: spi_bus platform: mipi_spi - id: main_lcd + id: mapping_main_lcd model: ili9342 cs_pin: 12 dc_pin: 13 diff --git a/tests/components/mapping/test.esp8266-ard.yaml b/tests/components/mapping/test.esp8266-ard.yaml index 6a308b67dd..e51240f20d 100644 --- a/tests/components/mapping/test.esp8266-ard.yaml +++ b/tests/components/mapping/test.esp8266-ard.yaml @@ -5,7 +5,7 @@ packages: display: spi_id: spi_bus platform: mipi_spi - id: main_lcd + id: mapping_main_lcd model: ili9342 cs_pin: 5 dc_pin: 15 diff --git a/tests/components/mapping/test.rp2040-ard.yaml b/tests/components/mapping/test.rp2040-ard.yaml index 01b83c4ab8..0562a4ba51 100644 --- a/tests/components/mapping/test.rp2040-ard.yaml +++ b/tests/components/mapping/test.rp2040-ard.yaml @@ -5,7 +5,7 @@ packages: display: spi_id: spi_bus platform: mipi_spi - id: main_lcd + id: mapping_main_lcd model: ili9342 data_rate: 31.25MHz cs_pin: 20 diff --git a/tests/components/monochromatic/common.yaml b/tests/components/monochromatic/common.yaml index 9915e086eb..e57c7bec29 100644 --- a/tests/components/monochromatic/common.yaml +++ b/tests/components/monochromatic/common.yaml @@ -1,13 +1,13 @@ output: - platform: ${light_platform} - id: light_output_1 + id: monochromatic_light_output_1 pin: ${pin} light: - platform: monochromatic name: Monochromatic Light id: monochromatic_light - output: light_output_1 + output: monochromatic_light_output_1 gamma_correct: 2.8 default_transition_length: 2s effects: diff --git a/tests/components/mpr121/common.yaml b/tests/components/mpr121/common.yaml index 67a06cf9c1..f96651e9bf 100644 --- a/tests/components/mpr121/common.yaml +++ b/tests/components/mpr121/common.yaml @@ -9,15 +9,15 @@ binary_sensor: name: touchkey0 channel: 0 - platform: mpr121 - id: bin1 + id: mpr121_bin1 name: touchkey1 channel: 1 - platform: mpr121 - id: bin2 + id: mpr121_bin2 name: touchkey2 channel: 2 - platform: mpr121 - id: bin3 + id: mpr121_bin3 name: touchkey3 channel: 6 diff --git a/tests/components/nextion/common.yaml b/tests/components/nextion/common.yaml index d79e3ee2ed..9eadd97a6d 100644 --- a/tests/components/nextion/common.yaml +++ b/tests/components/nextion/common.yaml @@ -1,6 +1,6 @@ esphome: on_boot: - - lambda: 'ESP_LOGD("display","is_connected(): %s", YESNO(id(main_lcd).is_connected()));' + - lambda: 'ESP_LOGD("display","is_connected(): %s", YESNO(id(nextion_main_lcd).is_connected()));' - display.nextion.set_brightness: 80% @@ -272,7 +272,7 @@ text_sensor: display: - platform: nextion - id: main_lcd + id: nextion_main_lcd auto_wake_on_touch: true brightness: 80% command_spacing: 5ms diff --git a/tests/components/nextion/common_tft_upload.yaml b/tests/components/nextion/common_tft_upload.yaml index 190abbc7b1..70a0809883 100644 --- a/tests/components/nextion/common_tft_upload.yaml +++ b/tests/components/nextion/common_tft_upload.yaml @@ -1,5 +1,5 @@ display: - - id: !extend main_lcd + - id: !extend nextion_main_lcd tft_url: http://esphome.io/default35.tft tft_upload_http_timeout: 20s tft_upload_http_retries: 10 diff --git a/tests/components/nextion/common_tft_upload_watchdog.yaml b/tests/components/nextion/common_tft_upload_watchdog.yaml index 385fee359e..f0b44ce8c3 100644 --- a/tests/components/nextion/common_tft_upload_watchdog.yaml +++ b/tests/components/nextion/common_tft_upload_watchdog.yaml @@ -1,3 +1,3 @@ display: - - id: !extend main_lcd + - id: !extend nextion_main_lcd tft_upload_watchdog_timeout: 30s diff --git a/tests/components/ntc/common.yaml b/tests/components/ntc/common.yaml index 79ae7f601d..1be2c335bc 100644 --- a/tests/components/ntc/common.yaml +++ b/tests/components/ntc/common.yaml @@ -1,23 +1,23 @@ sensor: - platform: adc - id: my_sensor + id: ntc_my_sensor pin: ${pin} - platform: resistance - sensor: my_sensor + sensor: ntc_my_sensor configuration: DOWNSTREAM resistor: 10kΩ reference_voltage: 3.3V name: Resistance - id: resist + id: ntc_resist - platform: ntc - sensor: resist + sensor: ntc_resist name: NTC Sensor calibration: b_constant: 3950 reference_resistance: 10k reference_temperature: 25°C - platform: ntc - sensor: resist + sensor: ntc_resist name: NTC Sensor2 calibration: - 10.0kOhm -> 25°C diff --git a/tests/components/number/common.yaml b/tests/components/number/common.yaml index c17c2dd5f8..b1a16ebfed 100644 --- a/tests/components/number/common.yaml +++ b/tests/components/number/common.yaml @@ -1,7 +1,7 @@ number: - platform: template name: "Test Number" - id: test_number + id: number_test_number optimistic: true min_value: 0 max_value: 100 @@ -10,4 +10,4 @@ number: sensor: - platform: number name: "Test Number Value" - source_id: test_number + source_id: number_test_number diff --git a/tests/components/online_image/common-esp32.yaml b/tests/components/online_image/common-esp32.yaml index 32c909d351..ee4c1ed0b8 100644 --- a/tests/components/online_image/common-esp32.yaml +++ b/tests/components/online_image/common-esp32.yaml @@ -6,7 +6,7 @@ packages: display: - platform: ili9xxx spi_id: spi_bus - id: main_lcd + id: online_image_main_lcd model: ili9342 cs_pin: 20 dc_pin: 13 diff --git a/tests/components/online_image/common-esp8266.yaml b/tests/components/online_image/common-esp8266.yaml index d7722d171a..fc61aad92e 100644 --- a/tests/components/online_image/common-esp8266.yaml +++ b/tests/components/online_image/common-esp8266.yaml @@ -6,7 +6,7 @@ packages: display: - platform: ili9xxx spi_id: spi_bus - id: main_lcd + id: online_image_main_lcd model: ili9342 cs_pin: 15 dc_pin: 3 diff --git a/tests/components/online_image/common-rp2040.yaml b/tests/components/online_image/common-rp2040.yaml index bbb514bded..4d2785f3e8 100644 --- a/tests/components/online_image/common-rp2040.yaml +++ b/tests/components/online_image/common-rp2040.yaml @@ -6,7 +6,7 @@ packages: display: - platform: ili9xxx spi_id: spi_bus - id: main_lcd + id: online_image_main_lcd model: ili9342 data_rate: 20MHz cs_pin: 20 diff --git a/tests/components/online_image/test.esp32-s3-ard.yaml b/tests/components/online_image/test.esp32-s3-ard.yaml index 9116fd86e0..9972a673c0 100644 --- a/tests/components/online_image/test.esp32-s3-ard.yaml +++ b/tests/components/online_image/test.esp32-s3-ard.yaml @@ -8,7 +8,7 @@ http_request: display: - platform: ili9xxx spi_id: spi_bus - id: main_lcd + id: online_image_main_lcd model: ili9342 cs_pin: 20 dc_pin: 13 diff --git a/tests/components/online_image/test.esp32-s3-idf.yaml b/tests/components/online_image/test.esp32-s3-idf.yaml index f219f71ee2..1f1485fd6c 100644 --- a/tests/components/online_image/test.esp32-s3-idf.yaml +++ b/tests/components/online_image/test.esp32-s3-idf.yaml @@ -8,7 +8,7 @@ http_request: display: - platform: ili9xxx spi_id: spi_bus - id: main_lcd + id: online_image_main_lcd model: ili9342 cs_pin: 20 dc_pin: 13 diff --git a/tests/components/output/common.yaml b/tests/components/output/common.yaml index 81d802e9bf..df20dcde2b 100644 --- a/tests/components/output/common.yaml +++ b/tests/components/output/common.yaml @@ -1,19 +1,19 @@ esphome: on_boot: then: - - output.turn_off: light_output_1 - - output.turn_on: light_output_1 + - output.turn_off: output_light_output_1 + - output.turn_on: output_light_output_1 - output.set_level: - id: light_output_1 + id: output_light_output_1 level: 50% - output.set_min_power: - id: light_output_1 + id: output_light_output_1 min_power: 20% - output.set_max_power: - id: light_output_1 + id: output_light_output_1 max_power: 80% output: - platform: ${output_platform} - id: light_output_1 + id: output_light_output_1 pin: ${pin} diff --git a/tests/components/pi4ioe5v6408/common.yaml b/tests/components/pi4ioe5v6408/common.yaml index 77a77fa3e4..aeda76d35c 100644 --- a/tests/components/pi4ioe5v6408/common.yaml +++ b/tests/components/pi4ioe5v6408/common.yaml @@ -9,7 +9,7 @@ pi4ioe5v6408: switch: - platform: gpio - id: switch1 + id: pi4ioe5v6408_switch1 pin: pi4ioe5v6408: pi4ioe1 number: 0 diff --git a/tests/components/pid/common.yaml b/tests/components/pid/common.yaml index 262e75591e..320e5f775f 100644 --- a/tests/components/pid/common.yaml +++ b/tests/components/pid/common.yaml @@ -23,7 +23,7 @@ output: sensor: - platform: template - id: template_sensor1 + id: pid_template_sensor1 lambda: |- if (millis() > 10000) { return 42.0; @@ -35,8 +35,8 @@ climate: - platform: pid id: pid_climate name: PID Climate Controller - sensor: template_sensor1 - humidity_sensor: template_sensor1 + sensor: pid_template_sensor1 + humidity_sensor: pid_template_sensor1 default_target_temperature: 21°C heat_output: pid_slow_pwm control_parameters: diff --git a/tests/components/prometheus/common.yaml b/tests/components/prometheus/common.yaml index 7ff416dccb..951d8f7fc5 100644 --- a/tests/components/prometheus/common.yaml +++ b/tests/components/prometheus/common.yaml @@ -31,7 +31,7 @@ update: sensor: - platform: template - id: template_sensor1 + id: prometheus_template_sensor1 lambda: |- if (millis() > 10000) { return 42.0; @@ -91,7 +91,7 @@ binary_sensor: switch: - platform: template - id: template_switch1 + id: prometheus_template_switch1 lambda: |- if (millis() > 10000) { return true; @@ -185,7 +185,7 @@ climate: prometheus: include_internal: true relabel: - template_sensor1: + prometheus_template_sensor1: id: hellow_world name: Hello World template_text_sensor1: diff --git a/tests/components/qspi_dbi/common.yaml b/tests/components/qspi_dbi/common.yaml index 109db65b63..0eadfa7392 100644 --- a/tests/components/qspi_dbi/common.yaml +++ b/tests/components/qspi_dbi/common.yaml @@ -16,7 +16,7 @@ display: - platform: qspi_dbi model: CUSTOM - id: main_lcd + id: qspi_dbi_main_lcd draw_from_origin: true dimensions: height: 240 diff --git a/tests/components/remote_transmitter/common-buttons.yaml b/tests/components/remote_transmitter/common-buttons.yaml index c6c7049605..5631c48f95 100644 --- a/tests/components/remote_transmitter/common-buttons.yaml +++ b/tests/components/remote_transmitter/common-buttons.yaml @@ -1,6 +1,6 @@ number: - platform: template - id: test_number + id: remote_transmitter_test_number optimistic: true min_value: 0 max_value: 255 @@ -151,7 +151,7 @@ button: on_press: remote_transmitter.transmit_raw: code: !lambda |- - return {(int32_t)id(test_number).state * 100, -1000}; + return {(int32_t)id(remote_transmitter_test_number).state * 100, -1000}; - platform: template name: AEHA id: eaha_hitachi_climate_power_on @@ -253,7 +253,7 @@ button: destination_address: 0x5678 message_type: 0x01 data: !lambda |- - return {(uint8_t)id(test_number).state, 0x20, 0x30}; + return {(uint8_t)id(remote_transmitter_test_number).state, 0x20, 0x30}; - platform: template name: Digital Write on_press: diff --git a/tests/components/resistance/common.yaml b/tests/components/resistance/common.yaml index b3eec49548..8966b574df 100644 --- a/tests/components/resistance/common.yaml +++ b/tests/components/resistance/common.yaml @@ -1,11 +1,11 @@ sensor: - platform: adc - id: my_sensor + id: resistance_my_sensor pin: ${pin} - platform: resistance - sensor: my_sensor + sensor: resistance_my_sensor configuration: DOWNSTREAM resistor: 10kΩ reference_voltage: 3.3V name: Resistance - id: resist + id: resistance_resist diff --git a/tests/components/rgb/common.yaml b/tests/components/rgb/common.yaml index 9f25efa431..bd72abbd17 100644 --- a/tests/components/rgb/common.yaml +++ b/tests/components/rgb/common.yaml @@ -1,9 +1,9 @@ output: - platform: ${light_platform} - id: light_output_1 + id: rgb_light_output_1 pin: ${pin1} - platform: ${light_platform} - id: light_output_2 + id: rgb_light_output_2 pin: ${pin2} - platform: ${light_platform} id: light_output_3 @@ -13,6 +13,6 @@ light: - platform: rgb name: RGB Light id: rgb_light - red: light_output_1 - green: light_output_2 + red: rgb_light_output_1 + green: rgb_light_output_2 blue: light_output_3 diff --git a/tests/components/rgbct/common.yaml b/tests/components/rgbct/common.yaml index 65bb248e95..46d8082706 100644 --- a/tests/components/rgbct/common.yaml +++ b/tests/components/rgbct/common.yaml @@ -1,9 +1,9 @@ output: - platform: ${light_platform} - id: light_output_1 + id: rgbct_light_output_1 pin: ${pin1} - platform: ${light_platform} - id: light_output_2 + id: rgbct_light_output_2 pin: ${pin2} - platform: ${light_platform} id: light_output_3 @@ -18,8 +18,8 @@ output: light: - platform: rgbct name: RGBCT Light - red: light_output_1 - green: light_output_2 + red: rgbct_light_output_1 + green: rgbct_light_output_2 blue: light_output_3 color_temperature: light_output_4 white_brightness: light_output_5 diff --git a/tests/components/rgbw/common.yaml b/tests/components/rgbw/common.yaml index b0f44869d3..4a8e56a255 100644 --- a/tests/components/rgbw/common.yaml +++ b/tests/components/rgbw/common.yaml @@ -1,9 +1,9 @@ output: - platform: ${light_platform} - id: light_output_1 + id: rgbw_light_output_1 pin: ${pin1} - platform: ${light_platform} - id: light_output_2 + id: rgbw_light_output_2 pin: ${pin2} - platform: ${light_platform} id: light_output_3 @@ -15,8 +15,8 @@ output: light: - platform: rgbw name: RGBW Light - red: light_output_1 - green: light_output_2 + red: rgbw_light_output_1 + green: rgbw_light_output_2 blue: light_output_3 white: light_output_4 color_interlock: true diff --git a/tests/components/rgbww/common.yaml b/tests/components/rgbww/common.yaml index 0013960c10..bb1d73b3bc 100644 --- a/tests/components/rgbww/common.yaml +++ b/tests/components/rgbww/common.yaml @@ -1,9 +1,9 @@ output: - platform: ${light_platform} - id: light_output_1 + id: rgbww_light_output_1 pin: ${pin1} - platform: ${light_platform} - id: light_output_2 + id: rgbww_light_output_2 pin: ${pin2} - platform: ${light_platform} id: light_output_3 @@ -18,8 +18,8 @@ output: light: - platform: rgbww name: RGBWW Light - red: light_output_1 - green: light_output_2 + red: rgbww_light_output_1 + green: rgbww_light_output_2 blue: light_output_3 cold_white: light_output_4 warm_white: light_output_5 diff --git a/tests/components/rp2040_pio_led_strip/common.yaml b/tests/components/rp2040_pio_led_strip/common.yaml index b9b1436cdb..254ac0e13d 100644 --- a/tests/components/rp2040_pio_led_strip/common.yaml +++ b/tests/components/rp2040_pio_led_strip/common.yaml @@ -1,6 +1,6 @@ light: - platform: rp2040_pio_led_strip - id: led_strip + id: rp2040_pio_led_strip_led_strip pin: 4 num_leds: 60 pio: 0 diff --git a/tests/components/rp2040_pwm/common.yaml b/tests/components/rp2040_pwm/common.yaml index 45c039106f..2970a48afb 100644 --- a/tests/components/rp2040_pwm/common.yaml +++ b/tests/components/rp2040_pwm/common.yaml @@ -1,7 +1,7 @@ output: - platform: rp2040_pwm - id: light_output_1 + id: rp2040_pwm_light_output_1 pin: 2 - platform: rp2040_pwm - id: light_output_2 + id: rp2040_pwm_light_output_2 pin: 3 diff --git a/tests/components/sdl/common.yaml b/tests/components/sdl/common.yaml index d3d3c9ee5e..3be86cf8be 100644 --- a/tests/components/sdl/common.yaml +++ b/tests/components/sdl/common.yaml @@ -3,7 +3,7 @@ host: display: - platform: sdl - id: sdl_display + id: sdl_sdl_display update_interval: 1s auto_clear_enabled: false show_test_card: true @@ -35,14 +35,14 @@ display: binary_sensor: - platform: sdl - sdl_id: sdl_display + sdl_id: sdl_sdl_display id: key_up key: SDLK_UP - platform: sdl - sdl_id: sdl_display + sdl_id: sdl_sdl_display id: key_down key: SDLK_DOWN - platform: sdl - sdl_id: sdl_display + sdl_id: sdl_sdl_display id: key_enter key: SDLK_RETURN diff --git a/tests/components/speaker/common.yaml b/tests/components/speaker/common.yaml index 895f4b4b8f..96f459c53f 100644 --- a/tests/components/speaker/common.yaml +++ b/tests/components/speaker/common.yaml @@ -1,7 +1,7 @@ number: - platform: template name: "Speaker Number" - id: my_number + id: speaker_my_number optimistic: true min_value: 0 max_value: 100 @@ -46,7 +46,7 @@ button: - speaker.play: id: speaker_id data: !lambda |- - return {0x01, 0x02, (uint8_t)id(my_number).state}; + return {0x01, 0x02, (uint8_t)id(speaker_my_number).state}; speaker: - platform: i2s_audio diff --git a/tests/components/speed/common.yaml b/tests/components/speed/common.yaml index be8172af7e..70c91259ba 100644 --- a/tests/components/speed/common.yaml +++ b/tests/components/speed/common.yaml @@ -1,9 +1,9 @@ output: - platform: ${output_platform} - id: fan_output_1 + id: speed_fan_output_1 pin: ${pin} fan: - platform: speed - id: fan_speed - output: fan_output_1 + id: speed_fan_speed + output: speed_fan_output_1 diff --git a/tests/components/sprinkler/common.yaml b/tests/components/sprinkler/common.yaml index f099f77729..dbe109f524 100644 --- a/tests/components/sprinkler/common.yaml +++ b/tests/components/sprinkler/common.yaml @@ -34,7 +34,7 @@ esphome: switch: - platform: template - id: switch1 + id: sprinkler_switch1 optimistic: true - platform: template id: switch2 @@ -52,17 +52,17 @@ sprinkler: valves: - valve_switch: Yard Valve 0 enable_switch: Enable Yard Valve 0 - pump_switch_id: switch1 + pump_switch_id: sprinkler_switch1 run_duration: 10s valve_switch_id: switch2 - valve_switch: Yard Valve 1 enable_switch: Enable Yard Valve 1 - pump_switch_id: switch1 + pump_switch_id: sprinkler_switch1 run_duration: 10s valve_switch_id: switch2 - valve_switch: Yard Valve 2 enable_switch: Enable Yard Valve 2 - pump_switch_id: switch1 + pump_switch_id: sprinkler_switch1 run_duration: 10s valve_switch_id: switch2 - id: garden_sprinkler_ctrlr @@ -73,11 +73,11 @@ sprinkler: valves: - valve_switch: Garden Valve 0 enable_switch: Enable Garden Valve 0 - pump_switch_id: switch1 + pump_switch_id: sprinkler_switch1 run_duration: 10s valve_switch_id: switch2 - valve_switch: Garden Valve 1 enable_switch: Enable Garden Valve 1 - pump_switch_id: switch1 + pump_switch_id: sprinkler_switch1 run_duration: 10s valve_switch_id: switch2 diff --git a/tests/components/ssd1306_i2c/common.yaml b/tests/components/ssd1306_i2c/common.yaml index 09eb569a8e..b3b8ad85dc 100644 --- a/tests/components/ssd1306_i2c/common.yaml +++ b/tests/components/ssd1306_i2c/common.yaml @@ -4,7 +4,7 @@ display: model: SSD1306_128X64 reset_pin: ${reset_pin} address: 0x3C - id: ssd1306_i2c_display + id: ssd1306_i2c_ssd1306_i2c_display contrast: 60% pages: - id: ssd1306_i2c_page1 diff --git a/tests/components/switch/common.yaml b/tests/components/switch/common.yaml index afdf26c150..3ea235cfb9 100644 --- a/tests/components/switch/common.yaml +++ b/tests/components/switch/common.yaml @@ -1,6 +1,6 @@ binary_sensor: - platform: switch - id: some_binary_sensor + id: switch_some_binary_sensor name: "Template Switch State" source_id: the_switch diff --git a/tests/components/sx126x/common.yaml b/tests/components/sx126x/common.yaml index 659550cc01..a4a24d8da7 100644 --- a/tests/components/sx126x/common.yaml +++ b/tests/components/sx126x/common.yaml @@ -29,7 +29,7 @@ sx126x: number: - platform: template name: "SX126x Number" - id: my_number + id: sx126x_my_number optimistic: true min_value: 0 max_value: 100 @@ -47,4 +47,4 @@ button: - sx126x.send_packet: data: [0xC5, 0x51, 0x78, 0x82, 0xB7, 0xF9, 0x9C, 0x5C] - sx126x.send_packet: !lambda |- - return {0x01, 0x02, (uint8_t)id(my_number).state}; + return {0x01, 0x02, (uint8_t)id(sx126x_my_number).state}; diff --git a/tests/components/sx127x/common.yaml b/tests/components/sx127x/common.yaml index 6e48952fcc..b7eadc084f 100644 --- a/tests/components/sx127x/common.yaml +++ b/tests/components/sx127x/common.yaml @@ -29,7 +29,7 @@ sx127x: number: - platform: template name: "SX127x Number" - id: my_number + id: sx127x_my_number optimistic: true min_value: 0 max_value: 100 @@ -48,4 +48,4 @@ button: - sx127x.send_packet: data: [0xC5, 0x51, 0x78, 0x82, 0xB7, 0xF9, 0x9C, 0x5C] - sx127x.send_packet: !lambda |- - return {0x01, 0x02, (uint8_t)id(my_number).state}; + return {0x01, 0x02, (uint8_t)id(sx127x_my_number).state}; diff --git a/tests/components/template/common-base.yaml b/tests/components/template/common-base.yaml index d3985a848b..f1387a7afe 100644 --- a/tests/components/template/common-base.yaml +++ b/tests/components/template/common-base.yaml @@ -52,7 +52,7 @@ esphome: binary_sensor: - platform: template - id: some_binary_sensor + id: template_some_binary_sensor name: "Garage Door Open" lambda: |- if (id(template_sens).state > 30) { @@ -108,7 +108,7 @@ sensor: name: "Template Sensor" id: template_sens lambda: |- - if (id(some_binary_sensor).state) { + if (id(template_some_binary_sensor).state) { return 42.0; } return 0.0; @@ -230,7 +230,7 @@ switch: id: test_switch name: "Template Switch" lambda: |- - if (id(some_binary_sensor).state) { + if (id(template_some_binary_sensor).state) { return true; } return false; @@ -249,7 +249,7 @@ cover: - platform: template name: "Template Cover" lambda: |- - if (id(some_binary_sensor).state) { + if (id(template_some_binary_sensor).state) { return COVER_OPEN; } return COVER_CLOSED; @@ -264,7 +264,7 @@ cover: name: "Template Cover with Triggers" id: template_cover_with_triggers lambda: |- - if (id(some_binary_sensor).state) { + if (id(template_some_binary_sensor).state) { return COVER_OPEN; } return COVER_CLOSED; @@ -442,7 +442,7 @@ lock: - platform: template name: "Template Lock" lambda: |- - if (id(some_binary_sensor).state) { + if (id(template_some_binary_sensor).state) { return LOCK_STATE_LOCKED; } return LOCK_STATE_UNLOCKED; @@ -458,7 +458,7 @@ valve: id: template_valve name: "Template Valve" lambda: |- - if (id(some_binary_sensor).state) { + if (id(template_some_binary_sensor).state) { return VALVE_OPEN; } return VALVE_CLOSED; diff --git a/tests/components/tt21100/common.yaml b/tests/components/tt21100/common.yaml index 56089aed1e..1f9249f1ba 100644 --- a/tests/components/tt21100/common.yaml +++ b/tests/components/tt21100/common.yaml @@ -1,7 +1,7 @@ display: - platform: ssd1306_i2c i2c_id: i2c_bus - id: ssd1306_i2c_display + id: tt21100_ssd1306_i2c_display model: SSD1306_128X64 reset_pin: ${disp_reset_pin} pages: @@ -13,7 +13,7 @@ touchscreen: - platform: tt21100 i2c_id: i2c_bus id: tt21100_touchscreen - display: ssd1306_i2c_display + display: tt21100_ssd1306_i2c_display interrupt_pin: ${interrupt_pin} reset_pin: ${reset_pin} diff --git a/tests/components/uart/test.esp32-idf.yaml b/tests/components/uart/test.esp32-idf.yaml index fa76316b9c..c805188005 100644 --- a/tests/components/uart/test.esp32-idf.yaml +++ b/tests/components/uart/test.esp32-idf.yaml @@ -79,7 +79,7 @@ switch: number: - platform: template name: "Test Number" - id: test_number + id: uart_test_number optimistic: true min_value: 0 max_value: 100 @@ -103,7 +103,7 @@ button: - uart.write: id: uart_id data: !lambda |- - std::string cmd = "VALUE=" + str_sprintf("%.0f", id(test_number).state) + "\r\n"; + std::string cmd = "VALUE=" + str_sprintf("%.0f", id(uart_test_number).state) + "\r\n"; return std::vector(cmd.begin(), cmd.end()); event: diff --git a/tests/components/udp/common.yaml b/tests/components/udp/common.yaml index a40ca455cb..6824c5cca8 100644 --- a/tests/components/udp/common.yaml +++ b/tests/components/udp/common.yaml @@ -24,7 +24,7 @@ udp: number: - platform: template name: "UDP Number" - id: my_number + id: udp_my_number optimistic: true min_value: 0 max_value: 100 @@ -38,4 +38,4 @@ button: - udp.write: data: [0x01, 0x02, 0x03] - udp.write: !lambda |- - return {0x10, 0x20, (uint8_t)id(my_number).state}; + return {0x10, 0x20, (uint8_t)id(udp_my_number).state}; diff --git a/tests/components/ufire_ec/common.yaml b/tests/components/ufire_ec/common.yaml index 4260f0ab4c..2365b7a368 100644 --- a/tests/components/ufire_ec/common.yaml +++ b/tests/components/ufire_ec/common.yaml @@ -4,18 +4,18 @@ esphome: - ufire_ec.calibrate_probe: id: ufire_ec_board solution: 0.146 - temperature: !lambda "return id(test_sensor).state;" + temperature: !lambda "return id(ufire_ec_test_sensor).state;" - ufire_ec.reset: sensor: - platform: template - id: test_sensor + id: ufire_ec_test_sensor lambda: "return 21;" - platform: ufire_ec i2c_id: i2c_bus id: ufire_ec_board ec: name: Ufire EC - temperature_sensor: test_sensor + temperature_sensor: ufire_ec_test_sensor temperature_compensation: 20.0 temperature_coefficient: 0.019 diff --git a/tests/components/ufire_ise/common.yaml b/tests/components/ufire_ise/common.yaml index f7865ea87b..478c75ad37 100644 --- a/tests/components/ufire_ise/common.yaml +++ b/tests/components/ufire_ise/common.yaml @@ -11,11 +11,11 @@ esphome: sensor: - platform: template - id: test_sensor + id: ufire_ise_test_sensor lambda: "return 21;" - platform: ufire_ise i2c_id: i2c_bus id: ufire_ise_sensor - temperature_sensor: test_sensor + temperature_sensor: ufire_ise_test_sensor ph: name: Ufire pH diff --git a/tests/components/web_server_idf/common.yaml b/tests/components/web_server_idf/common.yaml index b1885af266..cfba0060d9 100644 --- a/tests/components/web_server_idf/common.yaml +++ b/tests/components/web_server_idf/common.yaml @@ -12,7 +12,7 @@ network: sensor: - platform: template name: "Test Sensor" - id: test_sensor + id: web_server_idf_test_sensor update_interval: 60s lambda: "return 42.5;" @@ -25,5 +25,5 @@ binary_sensor: switch: - platform: template name: "Test Switch" - id: test_switch + id: web_server_idf_test_switch optimistic: true diff --git a/tests/components/wk2132_i2c/common.yaml b/tests/components/wk2132_i2c/common.yaml index 39013baeb2..93bb17b38f 100644 --- a/tests/components/wk2132_i2c/common.yaml +++ b/tests/components/wk2132_i2c/common.yaml @@ -16,4 +16,4 @@ wk2132_i2c: sensor: - platform: a02yyuw uart_id: wk2132_id_1 - id: distance_sensor + id: wk2132_i2c_distance_sensor diff --git a/tests/components/wk2132_spi/common.yaml b/tests/components/wk2132_spi/common.yaml index 18294974b9..5ff48bc64c 100644 --- a/tests/components/wk2132_spi/common.yaml +++ b/tests/components/wk2132_spi/common.yaml @@ -17,4 +17,4 @@ wk2132_spi: sensor: - platform: a02yyuw uart_id: wk2132_spi_uart1 - id: distance_sensor + id: wk2132_spi_distance_sensor diff --git a/tests/components/wk2168_i2c/common.yaml b/tests/components/wk2168_i2c/common.yaml index 49f0d1ec6b..1b2de74c02 100644 --- a/tests/components/wk2168_i2c/common.yaml +++ b/tests/components/wk2168_i2c/common.yaml @@ -23,7 +23,7 @@ wk2168_i2c: sensor: - platform: a02yyuw uart_id: wk2168_i2c_uart3 - id: distance_sensor + id: wk2168_i2c_distance_sensor # individual binary_sensor inputs binary_sensor: diff --git a/tests/components/wk2168_spi/common.yaml b/tests/components/wk2168_spi/common.yaml index b402077aa3..a21a4a34d0 100644 --- a/tests/components/wk2168_spi/common.yaml +++ b/tests/components/wk2168_spi/common.yaml @@ -23,7 +23,7 @@ wk2168_spi: sensor: - platform: a02yyuw uart_id: wk2168_spi_uart3 - id: distance_sensor + id: wk2168_spi_distance_sensor # individual binary_sensor inputs binary_sensor: diff --git a/tests/components/wk2204_i2c/common.yaml b/tests/components/wk2204_i2c/common.yaml index 863633937b..55c67efd88 100644 --- a/tests/components/wk2204_i2c/common.yaml +++ b/tests/components/wk2204_i2c/common.yaml @@ -24,4 +24,4 @@ wk2204_i2c: sensor: - platform: a02yyuw uart_id: wk2204_id_3 - id: distance_sensor + id: wk2204_i2c_distance_sensor diff --git a/tests/components/wk2204_spi/common.yaml b/tests/components/wk2204_spi/common.yaml index 0b62a7a009..ee00da22bb 100644 --- a/tests/components/wk2204_spi/common.yaml +++ b/tests/components/wk2204_spi/common.yaml @@ -25,4 +25,4 @@ wk2204_spi: sensor: - platform: a02yyuw uart_id: wk2204_spi_uart3 - id: distance_sensor + id: wk2204_spi_distance_sensor diff --git a/tests/components/wk2212_i2c/common.yaml b/tests/components/wk2212_i2c/common.yaml index a754bec5c7..d48063bb4d 100644 --- a/tests/components/wk2212_i2c/common.yaml +++ b/tests/components/wk2212_i2c/common.yaml @@ -19,7 +19,7 @@ wk2212_i2c: sensor: - platform: a02yyuw uart_id: uart_i2c_id1 - id: distance_sensor + id: wk2212_i2c_distance_sensor # individual binary_sensor inputs binary_sensor: diff --git a/tests/components/wk2212_spi/common.yaml b/tests/components/wk2212_spi/common.yaml index 969f16bb12..d17db2f676 100644 --- a/tests/components/wk2212_spi/common.yaml +++ b/tests/components/wk2212_spi/common.yaml @@ -17,7 +17,7 @@ wk2212_spi: sensor: - platform: a02yyuw uart_id: wk2212_spi_uart1 - id: distance_sensor + id: wk2212_spi_distance_sensor # individual binary_sensor inputs binary_sensor: diff --git a/tests/script/test_merge_component_configs.py b/tests/script/test_merge_component_configs.py new file mode 100644 index 0000000000..9286380de1 --- /dev/null +++ b/tests/script/test_merge_component_configs.py @@ -0,0 +1,72 @@ +"""Unit tests for script/merge_component_configs.py deduplication.""" + +from pathlib import Path +import sys + +import pytest + +# Add the script directory to Python path so we can import the module +sys.path.insert(0, str((Path(__file__).parent / ".." / ".." / "script").resolve())) + +import merge_component_configs # noqa: E402 + +deduplicate_by_id = merge_component_configs.deduplicate_by_id + + +def test_identical_duplicate_ids_collapse() -> None: + """Two identical items sharing an id collapse to one without error.""" + data = { + "sensor": [ + {"id": "shared", "platform": "template", "name": "A"}, + {"id": "shared", "platform": "template", "name": "A"}, + ] + } + result = deduplicate_by_id(data) + assert result["sensor"] == [{"id": "shared", "platform": "template", "name": "A"}] + + +def test_conflicting_duplicate_ids_raise() -> None: + """Two different items sharing an id is a hard error naming the id.""" + data = { + "sensor": [ + {"id": "dup", "platform": "template", "name": "A"}, + {"id": "dup", "platform": "template", "name": "B"}, + ] + } + with pytest.raises(ValueError, match="dup"): + deduplicate_by_id(data) + + +def test_intentionally_shared_id_does_not_raise() -> None: + """Allowlisted singleton ids may differ across components and collapse.""" + shared = next(iter(merge_component_configs.INTENTIONALLY_SHARED_IDS)) + data = { + "time": [ + {"id": shared, "platform": "sntp"}, + {"id": shared, "platform": "sntp", "servers": ["a"]}, + ] + } + result = deduplicate_by_id(data) + # First occurrence wins, no error raised + assert result["time"] == [{"id": shared, "platform": "sntp"}] + + +def test_items_without_id_are_preserved() -> None: + """Items lacking an id are passed through untouched.""" + data = {"binary_sensor": [{"platform": "gpio"}, {"platform": "gpio"}]} + result = deduplicate_by_id(data) + assert result["binary_sensor"] == [{"platform": "gpio"}, {"platform": "gpio"}] + + +def test_nested_lists_are_checked() -> None: + """Conflicts nested inside dict values are also detected.""" + data = { + "wrapper": { + "sensor": [ + {"id": "dup", "value": 1}, + {"id": "dup", "value": 2}, + ] + } + } + with pytest.raises(ValueError, match="dup"): + deduplicate_by_id(data)