Easee: obey current limits based on charger configuration (#16116)

This commit is contained in:
Michael Heß 2024-09-16 20:41:51 +02:00 • committed by GitHub
parent f20855fc9d
commit 42fa9d263e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -50,6 +50,7 @@ type Easee struct {
log *util.Logger
mux sync.RWMutex
lastEnergyPollMux sync.Mutex
maxChargerCurrent float64
dynamicChargerCurrent float64
current float64
chargerEnabled bool
@ -314,6 +315,8 @@ func (c *Easee) ProductUpdate(i json.RawMessage) {
c.phaseMode = value.(int)
case easee.OUTPUT_PHASE:
c.outputPhase = value.(int) / 10 // API gives 0,10,30 for 0,1,3p
case easee.MAX_CHARGER_CURRENT:
c.maxChargerCurrent = value.(float64)
case easee.DYNAMIC_CHARGER_CURRENT:
c.dynamicChargerCurrent = value.(float64)
@ -649,6 +652,9 @@ func (c *Easee) waitForDynamicChargerCurrent(targetCurrent float64) error {
// MaxCurrent implements the api.Charger interface
func (c *Easee) MaxCurrent(current int64) error {
cur := float64(current)
if c.maxChargerCurrent != 0 {
cur = min(cur, c.maxChargerCurrent)
}
data := easee.ChargerSettings{
DynamicChargerCurrent: &cur,
}