Skip to content

Commit

Permalink
missing_key handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bassmaster187 committed Jan 19, 2025
1 parent 0b2716e commit e775345
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions TeslaLogger/TelemetryParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -906,27 +906,48 @@ private void handleLoginResponse(dynamic j)
{
dynamic response = j["Response"];
dynamic updated_vehicles = response["updated_vehicles"];

if (updated_vehicles == "1")
{
string cfg = j["Config"];
Log("LoginRespone: OK / Config: " + cfg);
return;
}
else

dynamic skipped_vehicles = response["skipped_vehicles"];

if (skipped_vehicles != null)
{
Log("LoginRespone ERROR: " + response);
car.CurrentJSON.FatalError = "Telemetry Login Error!!! Check Logfile!";
car.CurrentJSON.CreateCurrentJSON();
dynamic missing_key = skipped_vehicles["missing_key"];

if (response.ToString().Contains("not_found"))
if (missing_key is JArray arrayMissing_key)
{
Thread.Sleep(10 * 60 * 1000);
}
else if (response.ToString().Contains("token expired"))
{
Log("Login Error: token expired!");
car.webhelper.GetToken();
if (arrayMissing_key?.Count == 1)
{
dynamic mkvin = arrayMissing_key[0];
if (mkvin?.ToString() == car.Vin)
{
Log("LoginRespone: missing_key");
car.CurrentJSON.FatalError = "missing_key";
car.CurrentJSON.CreateCurrentJSON();
}
}
}
}

Log("LoginRespone ERROR: " + response);
car.CurrentJSON.FatalError = "Telemetry Login Error!!! Check Logfile!";
car.CurrentJSON.CreateCurrentJSON();

if (response.ToString().Contains("not_found"))
{
Thread.Sleep(10 * 60 * 1000);
}
else if (response.ToString().Contains("token expired"))
{
Log("Login Error: token expired!");
car.webhelper.GetToken();
}
}
catch (Exception ex)
{
Expand Down

0 comments on commit e775345

Please sign in to comment.