mirror of
https://github.com/esphome/esphome.git
synced 2026-02-13 13:07:41 -07:00
Replace std::string with StringRef (non-owning string view) for user service string arguments in YAML-generated services. This avoids unnecessary heap allocation when the protobuf decode buffer already contains the string data. Key changes: - Frame helpers reserve +1 byte in rx_buf_ so string fields can be safely null-terminated in-place after decode - Add (null_terminate) protobuf field option to target only fields that need it (ExecuteServiceArgument.string_ and HomeAssistantStateResponse.state) - Add StringRef template specializations for get_execute_arg_value and to_service_arg_type - Python codegen uses StringRef for string service args, with automatic std::string fallback when deferred actions (delay, wait_until, script.wait) are present in the action chain - Add deferred flag to action registry for detecting actions that store trigger args for later execution - Simplify HomeAssistantStateResponse handler by removing SmallBufferWithHeapFallback copy (state is null-terminated in-place) - Add compare() method to StringRef for external component compatibility Saves ~240 bytes of flash on ESP8266 by eliminating std::string template instantiations for user service string arguments.