chore: simplify curtailment/dimming (#31954)

This commit is contained in:
andig 2026-07-19 18:53:19 +02:00 • committed by GitHub
parent 101839377a
commit 0224f8395d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 26 deletions

View file

@ -4,6 +4,10 @@ import "github.com/evcc-io/evcc/api"
// Dimmed reports nil until MaxConsumptionPower is known (see api.HEMS).
func Dimmed(hems api.HEMS) *bool {
if hems == nil {
return nil
}
dimmed := hems.MaxConsumptionPower()
if dimmed == nil {
return nil
@ -13,10 +17,13 @@ func Dimmed(hems api.HEMS) *bool {
}
func Curtailed(hems api.HEMS) *bool {
percent := hems.CurtailedPercent()
if percent == nil {
if hems == nil {
return nil
}
return new(*percent < 100)
if percent := hems.CurtailedPercent(); percent != nil {
return new(*percent < 100)
}
return nil
}