Easee: use start_charge when authentication required (#9271)
This commit is contained in:
parent
5ef8825582
commit
68ec274c00
3 changed files with 39 additions and 16 deletions
|
|
@ -53,6 +53,7 @@ type Easee struct {
|
|||
current float64
|
||||
chargerEnabled bool
|
||||
smartCharging bool
|
||||
authorize bool
|
||||
opMode int
|
||||
reasonForNoCurrent int
|
||||
phaseMode int
|
||||
|
|
@ -72,10 +73,11 @@ func init() {
|
|||
// NewEaseeFromConfig creates a go-e charger from generic config
|
||||
func NewEaseeFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
cc := struct {
|
||||
User string
|
||||
Password string
|
||||
Charger string
|
||||
Timeout time.Duration
|
||||
User string
|
||||
Password string
|
||||
Charger string
|
||||
Timeout time.Duration
|
||||
Authorize bool
|
||||
}{
|
||||
Timeout: request.Timeout,
|
||||
}
|
||||
|
|
@ -88,11 +90,11 @@ func NewEaseeFromConfig(other map[string]interface{}) (api.Charger, error) {
|
|||
return nil, api.ErrMissingCredentials
|
||||
}
|
||||
|
||||
return NewEasee(cc.User, cc.Password, cc.Charger, cc.Timeout)
|
||||
return NewEasee(cc.User, cc.Password, cc.Charger, cc.Timeout, cc.Authorize)
|
||||
}
|
||||
|
||||
// NewEasee creates Easee charger
|
||||
func NewEasee(user, password, charger string, timeout time.Duration) (*Easee, error) {
|
||||
func NewEasee(user, password, charger string, timeout time.Duration, authorize bool) (*Easee, error) {
|
||||
log := util.NewLogger("easee").Redact(user, password)
|
||||
|
||||
if !sponsor.IsAuthorized() {
|
||||
|
|
@ -100,14 +102,15 @@ func NewEasee(user, password, charger string, timeout time.Duration) (*Easee, er
|
|||
}
|
||||
|
||||
c := &Easee{
|
||||
Helper: request.NewHelper(log),
|
||||
charger: charger,
|
||||
log: log,
|
||||
current: 6, // default current
|
||||
done: make(chan struct{}),
|
||||
cmdC: make(chan easee.SignalRCommandResponse),
|
||||
obsC: make(chan easee.Observation),
|
||||
obsTime: make(map[easee.ObservationID]time.Time),
|
||||
Helper: request.NewHelper(log),
|
||||
charger: charger,
|
||||
authorize: authorize,
|
||||
log: log,
|
||||
current: 6, // default current
|
||||
done: make(chan struct{}),
|
||||
cmdC: make(chan easee.SignalRCommandResponse),
|
||||
obsC: make(chan easee.Observation),
|
||||
obsTime: make(map[easee.ObservationID]time.Time),
|
||||
}
|
||||
|
||||
c.Client.Timeout = timeout
|
||||
|
|
@ -372,6 +375,7 @@ func (c *Easee) Enabled() (bool, error) {
|
|||
|
||||
disabled := c.opMode == easee.ModeDisconnected ||
|
||||
c.opMode == easee.ModeCompleted ||
|
||||
c.opMode == easee.ModeAwaitingAuthentication ||
|
||||
(c.opMode == easee.ModeAwaitingStart && c.reasonForNoCurrent == 52)
|
||||
return !disabled && c.dynamicChargerCurrent > 0, nil
|
||||
}
|
||||
|
|
@ -380,6 +384,7 @@ func (c *Easee) Enabled() (bool, error) {
|
|||
func (c *Easee) Enable(enable bool) error {
|
||||
c.mux.Lock()
|
||||
enablingRequired := enable && !c.chargerEnabled
|
||||
opMode := c.opMode
|
||||
c.mux.Unlock()
|
||||
|
||||
// enable charger once if it's switched off
|
||||
|
|
@ -394,17 +399,23 @@ func (c *Easee) Enable(enable bool) error {
|
|||
}
|
||||
}
|
||||
|
||||
// do not send pause/resume if disconnected or unauthenticated
|
||||
if c.opMode == easee.ModeDisconnected || c.opMode == easee.ModeAwaitingAuthentication {
|
||||
// do not send pause/resume if disconnected or unauthenticated without automatic authorization
|
||||
if opMode == easee.ModeDisconnected || (opMode == easee.ModeAwaitingAuthentication && !(enable && c.authorize)) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// resume/stop charger
|
||||
action := easee.ChargePause
|
||||
if c.authorize {
|
||||
action = easee.ChargeStop
|
||||
}
|
||||
var expectedEnabledState bool
|
||||
var targetCurrent float64
|
||||
if enable {
|
||||
action = easee.ChargeResume
|
||||
if opMode == easee.ModeAwaitingAuthentication && c.authorize {
|
||||
action = easee.ChargeStart
|
||||
}
|
||||
expectedEnabledState = true
|
||||
targetCurrent = 32
|
||||
}
|
||||
|
|
@ -418,6 +429,11 @@ func (c *Easee) Enable(enable bool) error {
|
|||
if err := c.waitForChargerEnabledState(expectedEnabledState); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if c.authorize { // authenticating charger does not mingle with DCC, no need for below operations
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := c.waitForDynamicChargerCurrent(targetCurrent); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ package easee
|
|||
const API = "https://api.easee.com/api"
|
||||
|
||||
const (
|
||||
ChargeStart = "start_charging"
|
||||
ChargeStop = "stop_charging"
|
||||
ChargePause = "pause_charging"
|
||||
ChargeResume = "resume_charging"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -23,9 +23,14 @@ params:
|
|||
example: EH______
|
||||
- name: timeout
|
||||
default: 10s
|
||||
- name: authorize
|
||||
help:
|
||||
de: Steuert ob evcc die Authentifizierung am Charger vornimmt. Vorteil ist ein kontrollierter Ladestart. Nicht kompatibel mit RFID Identifikation von Fahrzeugen.
|
||||
en: Controls wether evcc shall perform authentication against charger. Benefit is a contolled start of charging. Not compatible with RFID identification of vehicles.
|
||||
render: |
|
||||
type: easee
|
||||
user: {{ .user }}
|
||||
password: {{ .password }}
|
||||
charger: {{ .charger }}
|
||||
timeout: {{ .timeout }}
|
||||
authorize: {{ .authorize }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue