Skip to content

Commit

Permalink
fix(ChargingService): use requested current when possible instead of …
Browse files Browse the repository at this point in the history
…last set amp
  • Loading branch information
pkuehnel committed Jan 20, 2024
1 parent 8bbe05e commit e80efb9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions TeslaSolarCharger/Server/Services/ChargingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,11 @@ private void UpdateShouldStartStopChargingSince(Car car)
var actualCurrent = car.CarState.ChargerActualCurrent ?? 0;
_logger.LogTrace("Actual current: {actualCurrent}", actualCurrent);
//This is needed because sometimes actual current is higher than last set amp, leading to higher calculated amp to set, than actually needed
if (actualCurrent > car.CarState.LastSetAmp)
var lastSetAmp = car.CarState.ChargerRequestedCurrent ?? car.CarState.LastSetAmp;
if (actualCurrent > lastSetAmp)
{
_logger.LogTrace("Actual current {actualCurrent} higher than last set amp {lastSetAmp}. Setting actual current as last set amp.", actualCurrent, car.CarState.LastSetAmp);
actualCurrent = car.CarState.LastSetAmp;
actualCurrent = lastSetAmp;
}
ampToSet += actualCurrent;
}
Expand Down

0 comments on commit e80efb9

Please sign in to comment.