[remote_base] Keep constant abbwelcome payloads in shared flash tables (#20311)

This commit is contained in:
J. Nick Koston
2026-10-11 14:55:22 -10:00
committed by GitHub
parent 643f29fae6
commit 40425610d5
4 changed files with 74 additions and 39 deletions
@@ -0,0 +1,36 @@
---
esphome:
name: test
on_boot:
then:
- remote_transmitter.transmit_abbwelcome:
source_address: 0x1234
destination_address: 0x5678
message_type: 0x01
data: [0x10, 0x20, 0x30]
- remote_transmitter.transmit_abbwelcome:
source_address: 0x1234
destination_address: 0x5678
message_type: 0x02
data: [0x10, 0x20, 0x30]
- remote_transmitter.transmit_abbwelcome:
source_address: 0x1234
destination_address: 0x5678
message_type: 0x03
data: []
- remote_transmitter.transmit_abbwelcome:
source_address: 0x1234
destination_address: 0x5678
message_type: 0x04
- remote_transmitter.transmit_abbwelcome:
source_address: 0x1234
destination_address: 0x5678
message_type: 0x05
data: !lambda return {0x09};
esp32:
board: esp32dev
remote_transmitter:
pin: 4
carrier_duty_percent: 100%
@@ -0,0 +1,21 @@
"""Tests for abbwelcome constant data in shared PROGMEM tables."""
from collections.abc import Callable
from pathlib import Path
import re
def test_constant_data_shares_progmem_tables(
generate_main: Callable[[str | Path], str],
component_config_path: Callable[[str], Path],
) -> None:
"""Equal data shares one table, empty or missing data is an empty table, lambdas stay templates."""
main_cpp = generate_main(component_config_path("abbwelcome_payload_tables.yaml"))
tables = re.findall(
r"static constexpr uint8_t (\w+)\[\] PROGMEM = (\{[^}]*\});", main_cpp
)
assert [v for _, v in tables] == ["{0x10, 0x20, 0x30}"]
assert main_cpp.count(f"set_data_static({tables[0][0]}, 3);") == 2
assert main_cpp.count("set_data_static(nullptr, 0);") == 2
assert main_cpp.count("set_data_template(") == 1