Improves parking state logic
All checks were successful
Build, Push and Run Container / build (push) Successful in 25s

Ensures the parking state is correctly managed by setting the parking started state before any parking zone checks.
Also, updates the logging message to more accurately reflect the car's state.
This commit is contained in:
2025-08-22 08:53:42 +02:00
parent 1272ecab46
commit c44f0d327d

View File

@@ -74,7 +74,7 @@ public class MessageProcessor
else else
{ {
this.parkingState.SetCarMoved(); this.parkingState.SetCarMoved();
this.logger.LogInformation("{vin} moved (not parking anymore)", vin); this.logger.LogInformation("{vin} is NOT in a parked state", vin);
} }
if (this.parkingState is { ParkingInProgress: false, CarParked: true }) if (this.parkingState is { ParkingInProgress: false, CarParked: true })
@@ -94,6 +94,9 @@ public class MessageProcessor
if (zoneLookupResult.IsSuccessful) if (zoneLookupResult.IsSuccessful)
{ {
//Set parking started
this.parkingState.SetParkingStarted();
if (String.IsNullOrWhiteSpace(zoneLookupResult.Value)) if (String.IsNullOrWhiteSpace(zoneLookupResult.Value))
{ {
// Push not a parking zone // Push not a parking zone
@@ -111,7 +114,6 @@ public class MessageProcessor
else else
{ {
// Push parking started in zone // Push parking started in zone
this.parkingState.SetParkingStarted();
if (sendNotification) if (sendNotification)
this.pushApi.Send(pushoverToken, new PushoverMessage this.pushApi.Send(pushoverToken, new PushoverMessage
{ {