1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-05 21:02:20 +01:00

Merge branch 'api_cleanups_5' into integration

This commit is contained in:
J. Nick Koston
2025-07-22 09:16:10 -10:00
2 changed files with 18 additions and 31 deletions

View File

@@ -2427,19 +2427,16 @@ static const char *const TAG = "api.service";
else:
check_func = "this->check_connection_setup_()"
body = f"if ({check_func}) {{\n"
# Add the actual handler code, indented
handler_body = ""
if is_void:
handler_body = f"this->{func}(msg);\n"
# For void methods, just wrap with auth check
body = f"if ({check_func}) {{\n"
body += f" this->{func}(msg);\n"
body += "}\n"
else:
handler_body = f"if (!this->send_{func}_response(msg)) {{\n"
handler_body += " this->on_fatal_error();\n"
handler_body += "}\n"
body += indent(handler_body) + "\n"
body += "}\n"
# For non-void methods, combine auth check and send response check
body = f"if ({check_func} && !this->send_{func}_response(msg)) {{\n"
body += " this->on_fatal_error();\n"
body += "}\n"
else:
# No auth check needed, just call the handler
body = ""