Skip to content

Commit

Permalink
Evse: require remote mode
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Dec 1, 2021
1 parent 8632ca2 commit 23bf8b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions charger/evsewifi.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ type EVSEListEntry struct {
// EVSEWifi charger implementation
type EVSEWifi struct {
*request.Helper
log *util.Logger
uri string
alwaysActive bool
current int64 // current will always be the physical value sent to the API
Expand Down Expand Up @@ -87,6 +86,10 @@ func NewEVSEWifiFromConfig(other map[string]interface{}) (api.Charger, error) {
return evse, err
}

if !params.AlwaysActive {
return nil, errors.New("evse must be configured to remote mode")
}

if params.UseMeter {
cc.Meter.Energy = true
cc.Meter.Energy = true
Expand Down Expand Up @@ -136,7 +139,6 @@ func NewEVSEWifi(uri string) (*EVSEWifi, error) {
log := util.NewLogger("evse")

evse := &EVSEWifi{
log: log,
Helper: request.NewHelper(log),
uri: strings.TrimRight(uri, "/"),
current: 6, // 6A defined value
Expand All @@ -163,11 +165,8 @@ func (evse *EVSEWifi) getParameters() (EVSEListEntry, error) {
}

params := res.List[0]
if !params.AlwaysActive {
evse.log.WARN.Println("evse should be configured to remote mode")
}

evse.alwaysActive = params.AlwaysActive

return params, nil
}

Expand Down
2 changes: 1 addition & 1 deletion charger/evsewifi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func TestEvseWifi(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = fmt.Fprintln(w, `{"list":[{"useMeter":true}]}`)
_, _ = fmt.Fprintln(w, `{"list":[{"useMeter":true, "alwaysActive":true}]}`)
}))
defer ts.Close()

Expand Down

0 comments on commit 23bf8b5

Please sign in to comment.