Skip to content

Commit

Permalink
Add PhaseGetter support for circuit controlled chargers
Browse files Browse the repository at this point in the history
  • Loading branch information
GrimmiMeloni committed Nov 18, 2024
1 parent c4d237d commit c4abc48
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions charger/easee.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type Easee struct {
lastEnergyPollMux sync.Mutex
maxChargerCurrent float64
dynamicChargerCurrent float64
dynamicCircuitCurrent [3]float64
current float64
chargerEnabled bool
smartCharging bool
Expand Down Expand Up @@ -315,6 +316,12 @@ 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.DYNAMIC_CIRCUIT_CURRENT_P1:
c.dynamicCircuitCurrent[0] = value.(float64)
case easee.DYNAMIC_CIRCUIT_CURRENT_P2:
c.dynamicCircuitCurrent[1] = value.(float64)
case easee.DYNAMIC_CIRCUIT_CURRENT_P3:
c.dynamicCircuitCurrent[2] = value.(float64)
case easee.MAX_CHARGER_CURRENT:
c.maxChargerCurrent = value.(float64)
case easee.DYNAMIC_CHARGER_CURRENT:
Expand Down Expand Up @@ -814,11 +821,22 @@ var _ api.PhaseGetter = (*Easee)(nil)
func (c *Easee) GetPhases() (int, error) {
c.mux.RLock()
defer c.mux.RUnlock()
phaseMode := c.phaseMode
if phaseMode == 2 { // map automatic to 3p
phaseMode = 3
var phases = 0
if c.circuit != 0 {
// circuit level controlled charger
for dcc := range c.dynamicCircuitCurrent {
if dcc > 0 {
phases++
}
}
} else {
// charger level
phases := c.phaseMode
if phases == 2 { // map automatic to 3p
phases = 3
}
}
return phaseMode, nil
return phases, nil
}

var _ api.Identifier = (*Easee)(nil)
Expand Down

0 comments on commit c4abc48

Please sign in to comment.