Optimizer: re-run on vehicle changes and include unmodeled loads (#32681)

This commit is contained in:
andig 2026-08-10 11:03:57 +02:00 • committed by GitHub
parent cc9bfc2556
commit a237f698d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 124 additions and 13 deletions

View file

@ -197,7 +197,7 @@ func (s *HTTPd) RegisterSiteHandlers(site site.API) {
"deletesession": {"DELETE", "/session/{id:[0-9]+}", deleteSessionHandler},
"gridsessions": {"GET", "/gridsessions", gridSessionsHandler},
"energyhistory": {"GET", "/history/energy", energyHistoryHandler},
"optimize": {"POST", "/optimize", getHandler(site.Optimize)},
"optimize": {"POST", "/optimize", callHandler(site.Optimize)},
"telemetry2": {"POST", "/settings/telemetry/{value:[01truefalse]+}", boolHandler(telemetry.Enable, telemetry.Enabled)},
"devicecolors": {"PUT", "/devicecolors", updateDeviceColor(site)},

View file

@ -191,6 +191,14 @@ func getHandler[T any](get func() T) http.HandlerFunc {
}
}
// callHandler invokes an api function without result
func callHandler(fun func()) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
fun()
jsonWrite(w, nil)
}
}
// updateSmartCostLimit sets the smart cost limit globally
func updateSmartCostLimit(site site.API, setLimit func(loadpoint.API, *float64)) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {