Skip to content

Move wipe_devices lambda string dispatch to C++ to save ESP8266 RAM#554

Merged
bdraco merged 1 commit intomainfrom
lambda_flash
Feb 22, 2026
Merged

Move wipe_devices lambda string dispatch to C++ to save ESP8266 RAM#554
bdraco merged 1 commit intomainfrom
lambda_flash

Conversation

@bdraco
Copy link
Member

@bdraco bdraco commented Feb 22, 2026

Summary

  • Moves the string-to-PairedDevice mapping from the YAML lambda into a C++ template method on RATGDOComponent
  • The YAML lambda had 5 string literals that ended up in RODATA (RAM on ESP8266)
  • The new implementation uses length + first character checks, avoiding any string data in RAM
  • Template works with both std::string and StringRef (or any type with length() and operator[])
  • Functionally the same — all valid inputs (all, remote, keypad, wall, accessory) map to the same enum values, just slightly more permissive since it checks length and first character rather than exact equality

Move the string-to-PairedDevice mapping out of the YAML lambda and into
a C++ overload of clear_paired_devices(const std::string&). The lambda
had 5 string literals that ended up in RODATA (RAM on ESP8266). The new
implementation uses length + first character checks which avoids any
string data in RAM.

The behavior is functionally the same — all valid inputs ("all",
"remote", "keypad", "wall", "accessory") map to the same enum values.
The matching is slightly more permissive since it checks length and
first character rather than exact equality, but invalid values are
never sent through the HA service in practice.
@bdraco bdraco merged commit 30faad3 into main Feb 22, 2026
23 checks passed
@bdraco bdraco deleted the lambda_flash branch February 22, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant