chore: simplify curtailment/dimming (#31954)
This commit is contained in:
parent
101839377a
commit
0224f8395d
4 changed files with 16 additions and 26 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue