Skip to content

Commit

Permalink
fix: wrong usage of 'isSunsetAvailable'
Browse files Browse the repository at this point in the history
I assumed that 'isSunsetAvailable' tells us if NTP is working and we got the correct time and timezone but actually it tells us if sunrise/sunset exists for the current timeperiod in the current timezone.
  • Loading branch information
AndreasBoehm committed Dec 7, 2024
1 parent 6aaa2de commit 7f62362
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PowerLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void PowerLimiterClass::loop()
auto getBatteryPower = [this,&config]() -> bool {
if (!usesBatteryPoweredInverter()) { return false; }

auto isDayPeriod = SunPosition.isSunsetAvailable() ? SunPosition.isDayPeriod() : true;
auto isDayPeriod = SunPosition.isDayPeriod();

if (_nighttimeDischarging && isDayPeriod) {
_nighttimeDischarging = false;
Expand Down
1 change: 1 addition & 0 deletions src/SunPosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ bool SunPositionClass::isDayPeriod() const
return (minutesPastMidnight >= _sunriseMinutes) && (minutesPastMidnight < _sunsetMinutes);
}

// Returns if sunset/sunrise exists (e.g. in norway sunset/sunrise don't happen in summer months)
bool SunPositionClass::isSunsetAvailable() const
{
return _isSunsetAvailable;
Expand Down

0 comments on commit 7f62362

Please sign in to comment.