A quick Google and a download of a Yamaha ebike service manual shows it to be an problem with the battery, but a number of people have fixed battery issues by ensuring the battery terminals and the matching socket on the bike are clean and dry. Others have found that adjusting the battery catch to ensure a tight fit has worked.
At worst it's back to a dealer ☹
The World's largest electric mountain bike community.