From 91ec0f959ef1176eb8e22d4f31269f1f07ea4945 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 25 Jul 2025 11:27:01 -1000 Subject: [PATCH] review comment --- esphome/components/api/api_connection.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index c226fe8c5e..ed0dba89eb 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -1830,9 +1830,7 @@ void APIConnection::process_state_subscriptions_() { resp.set_entity_id(StringRef(it.entity_id)); // Avoid string copy by directly using the optional's value if it exists - if (it.attribute.has_value()) { - resp.set_attribute(StringRef(it.attribute.value())); - } + resp.set_attribute(it.attribute.has_value() ? StringRef(it.attribute.value()) : StringRef("")); resp.once = it.once; if (this->send_message(resp, SubscribeHomeAssistantStateResponse::MESSAGE_TYPE)) {