Skip to content

Commit

Permalink
Merge pull request #1083 from pkuehnel/fix/useRequestedCurrentWhenPos…
Browse files Browse the repository at this point in the history
…sible

fix/useRequestedCurrentWhenPossible
  • Loading branch information
pkuehnel authored Jan 20, 2024
2 parents 8bbe05e + fd40090 commit f103f09
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 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;
_logger.LogTrace("Actual current {actualCurrent} higher than last set amp {lastSetAmp}. Setting actual current as last set amp.", actualCurrent, lastSetAmp);
actualCurrent = lastSetAmp;
}
ampToSet += actualCurrent;
}
Expand Down

0 comments on commit f103f09

Please sign in to comment.