Skip to content

Commit

Permalink
Fix evse resetting current when enabling (evcc-io#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Dec 1, 2020
1 parent 4fdb744 commit 839f6ac
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions charger/evsewifi.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type EVSEWifi struct {
log *util.Logger
uri string
alwaysActive bool
current int64
}

func init() {
Expand Down Expand Up @@ -109,9 +110,10 @@ func NewEVSEWifi(uri string) (*EVSEWifi, error) {
log := util.NewLogger("evse")

evse := &EVSEWifi{
log: log,
Helper: request.NewHelper(log),
uri: strings.TrimRight(uri, "/"),
log: log,
Helper: request.NewHelper(log),
uri: strings.TrimRight(uri, "/"),
current: 6, // 6A defined value
}

return evse, nil
Expand Down Expand Up @@ -195,9 +197,9 @@ func (evse *EVSEWifi) Enable(enable bool) error {
url := fmt.Sprintf("%s?active=%v", evse.apiURL(evseSetStatus), enable)

if evse.alwaysActive {
current := 0
var current int64
if enable {
current = 6
current = evse.current
}
url = fmt.Sprintf("%s?current=%d", evse.apiURL(evseSetCurrent), current)
}
Expand All @@ -206,6 +208,7 @@ func (evse *EVSEWifi) Enable(enable bool) error {

// MaxCurrent implements the Charger.MaxCurrent interface
func (evse *EVSEWifi) MaxCurrent(current int64) error {
evse.current = current
url := fmt.Sprintf("%s?current=%d", evse.apiURL(evseSetCurrent), current)
return evse.checkError(evse.GetBody(url))
}
Expand Down

0 comments on commit 839f6ac

Please sign in to comment.