diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index a54e51e6dd..4bcb83ccb6 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -1722,7 +1722,7 @@ void APIConnection::on_home_assistant_state_response(const HomeAssistantStateRes memcpy(state_buf, msg.state, msg.state_len); } state_buf[msg.state_len] = '\0'; - it.callback(StringRef(state_buf)); + it.callback(StringRef(state_buf, msg.state_len)); } } #endif