Optimizer: publish result before status check (#32055)

This commit is contained in:
andig 2026-07-22 17:13:43 +02:00 • committed by GitHub
parent 1db0d5015c
commit 19c4e06391
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -551,10 +551,8 @@ func (site *Site) optimizerUpdate(battery []types.Measurement) error {
return apiError(resp)
}
if resp.JSON200.Status != optimizer.Optimal {
return errors.New(string(resp.JSON200.Status))
}
// publish before the status check so the optimizer page stays available
// for diagnosing non-optimal results
site.publish("evopt", optimizerResult{
Updated: time.Now(),
Req: req,
@ -562,6 +560,10 @@ func (site *Site) optimizerUpdate(battery []types.Measurement) error {
Details: details,
})
if resp.JSON200.Status != optimizer.Optimal {
return errors.New(string(resp.JSON200.Status))
}
slotHours := firstSlotDuration.Hours()
gridImporting := len(resp.JSON200.GridImport) > 0 && resp.JSON200.GridImport[0] > 0
gridExporting := len(resp.JSON200.GridExport) > 0 && resp.JSON200.GridExport[0] > 0