From be49d74db016f92b213961ee9c07f2fd19c3d3d2 Mon Sep 17 00:00:00 2001 From: Christian Moyzyczyk Date: Sun, 8 Dec 2024 19:06:50 +0100 Subject: [PATCH] Write fallback to database, if car's display_name is null and API returns NULL --- TeslaLogger/WebHelper.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/TeslaLogger/WebHelper.cs b/TeslaLogger/WebHelper.cs index 729d55024..22abe15f0 100644 --- a/TeslaLogger/WebHelper.cs +++ b/TeslaLogger/WebHelper.cs @@ -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;