Skip to content

Commit

Permalink
fix(ErrorHandlingService): autoresolve errors for not managed cars
Browse files Browse the repository at this point in the history
  • Loading branch information
pkuehnel committed Oct 24, 2024
1 parent f4f6535 commit 0fa80c1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion TeslaSolarCharger/Server/Services/ErrorHandlingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ public async Task DetectErrors()
var activeErrors = await context.LoggedErrors
.Where(e => e.EndTimeStamp == default)
.ToListAsync().ConfigureAwait(false);
foreach (var error in activeErrors)
{
if (error.Vin == null || settings.CarsToManage.Any(c => c.Vin == error.Vin))
{
continue;
}
logger.LogDebug("Remove error with ID {id} as it belongs to a car that should not be managed.", error.Id);
error.EndTimeStamp = dateTimeProvider.UtcNow();
}
await context.SaveChangesAsync().ConfigureAwait(false);

await AddOrRemoveErrors(activeErrors, issueKeys.RestartNeeded, "TSC restart needed",
"Due to configuration changes a restart of TSC is needed.", settings.RestartNeeded).ConfigureAwait(false);

Expand All @@ -128,7 +139,7 @@ await AddOrRemoveErrors(activeErrors, issueKeys.FleetApiTokenNoApiRequestsAllowe
"Make sure your TSC can access the internet and TSC is on its latest version.", !settings.AllowUnlimitedFleetApiRequests).ConfigureAwait(false);

await DetectTokenStateIssues(activeErrors);
foreach (var car in settings.Cars)
foreach (var car in settings.CarsToManage)
{
if ((car.LastNonSuccessBleCall != default)
&& (car.LastNonSuccessBleCall.Value > (dateTimeProvider.UtcNow() - configurationWrapper.BleUsageStopAfterError())))
Expand Down

0 comments on commit 0fa80c1

Please sign in to comment.