Compute sunrise and sunset only if necessary.

Sunrise and -set must recomputed if one of the following conditions is met:
* The date changed (based on the selected timezone)
* Location (Lat/Lon) changed
* Sunset type changed

So instead of calculating that every minute just do it on update via web interface or date change.

If a new config is uploaded, the DTU gets restarted. There is no need to initiate a recalculation in this case.
This commit is contained in:
Stefan Oberhumer
2023-10-06 10:20:36 +02:00
parent d419fd4794
commit 943dfc2dbf
3 changed files with 58 additions and 11 deletions

View File

@@ -190,6 +190,8 @@ void WebApiNtpClass::onNtpAdminPost(AsyncWebServerRequest* request)
NtpSettings.setServer();
NtpSettings.setTimezone();
SunPosition.setDoRecalc(true);
}
void WebApiNtpClass::onNtpTimeGet(AsyncWebServerRequest* request)
@@ -350,4 +352,4 @@ void WebApiNtpClass::onNtpTimePost(AsyncWebServerRequest* request)
response->setLength();
request->send(response);
}
}