Skip to content

Commit

Permalink
Merge pull request bassmaster187#1399 from motzky/fix_grafana_empty_c…
Browse files Browse the repository at this point in the history
…ar_name

Make Grafana dashboards work, when Tesla API did not return a display_name
  • Loading branch information
bassmaster187 authored Dec 8, 2024
2 parents d3b0f3d + be49d74 commit 600c443
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions TeslaLogger/WebHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,13 @@ public string GetVehicles()
System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString() + " : " + OnlineState);

string display_name = r2["display_name"].ToString();
if(string.IsNullOrEmpty(display_name) && string.IsNullOrEmpty(car.DisplayName))
{
// Grafana dashboards break, if Car's display_name is null or empty, so
// if display_name is null from API and car.DisplayName is also null already
// we just write "Car $id" to database because that is how the fallback in admin panel works
display_name = $"Car {car.CarInDB}";
}
if (!string.IsNullOrEmpty(display_name) && car.DisplayName != display_name)
{
car.DisplayName = display_name;
Expand Down

0 comments on commit 600c443

Please sign in to comment.