From 0fa80c18aaadb6919b201956df33ee214c5deaf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Thu, 24 Oct 2024 21:38:25 +0200 Subject: [PATCH] fix(ErrorHandlingService): autoresolve errors for not managed cars --- .../Server/Services/ErrorHandlingService.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/TeslaSolarCharger/Server/Services/ErrorHandlingService.cs b/TeslaSolarCharger/Server/Services/ErrorHandlingService.cs index f8c887293..18002f0a6 100644 --- a/TeslaSolarCharger/Server/Services/ErrorHandlingService.cs +++ b/TeslaSolarCharger/Server/Services/ErrorHandlingService.cs @@ -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); @@ -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())))