Skip to content

Commit

Permalink
Allow overriding minCurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Dec 30, 2023
1 parent 071f270 commit 69c6cda
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions core/loadpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ func NewLoadpointFromConfig(log *util.Logger, settings *Settings, other map[stri
lp.Soc.Poll.Mode = pollCharging
}

if lp.MinCurrent == 0 {
lp.log.WARN.Println("minCurrent must not be zero")
}

if lp.MaxCurrent < lp.MinCurrent {
lp.log.WARN.Println("maxCurrent must be larger than minCurrent")
}
Expand Down Expand Up @@ -274,6 +278,7 @@ func NewLoadpoint(log *util.Logger, settings *Settings) *Loadpoint {
bus: bus, // event bus
mode: api.ModeOff,
status: api.StatusNone,
MinCurrent: 6, // A
MaxCurrent: 16, // A
Soc: SocConfig{
Poll: PollConfig{
Expand Down
16 changes: 8 additions & 8 deletions core/loadpoint_effective.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ func (lp *Loadpoint) effectiveMinCurrent() float64 {

if c, ok := lp.charger.(api.CurrentLimiter); ok {
if res, _, err := c.GetMinMaxCurrent(); err == nil {
lp.publish(keys.EffectiveMinCurrent, res)
minCurrent = max(minCurrent, res)
if res > 0 && res < minCurrent {
minCurrent = res
} else {
minCurrent = max(minCurrent, res)
}
lp.publish(keys.EffectiveMinCurrent, minCurrent)
}
}

if minCurrent > 0 {
return minCurrent
}

return 6
return minCurrent
}

// effectiveMaxCurrent returns the effective max current
Expand All @@ -94,8 +94,8 @@ func (lp *Loadpoint) effectiveMaxCurrent() float64 {

if c, ok := lp.charger.(api.CurrentLimiter); ok {
if _, res, err := c.GetMinMaxCurrent(); err == nil {
lp.publish(keys.EffectiveMaxCurrent, res)
maxCurrent = min(maxCurrent, res)
lp.publish(keys.EffectiveMaxCurrent, maxCurrent)
}
}

Expand Down

0 comments on commit 69c6cda

Please sign in to comment.