From 9b92f42c22835a9f6e77f48a2b5e9f7c5f910d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Sch=C3=B6fegger?= Date: Sat, 22 Aug 2020 09:22:58 +0200 Subject: [PATCH] evse: use evse alwaysActvie setting for enable method --- charger/evsewifi.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/charger/evsewifi.go b/charger/evsewifi.go index c25f42a124..555dbb8b6a 100644 --- a/charger/evsewifi.go +++ b/charger/evsewifi.go @@ -47,6 +47,7 @@ type EVSEListEntry struct { type EVSEWifi struct { *util.HTTPHelper uri string + alwaysActive bool } // NewEVSEWifiFromConfig creates a EVSEWifi charger from generic config @@ -62,8 +63,9 @@ func NewEVSEWifiFromConfig(other map[string]interface{}) (api.Charger, error) { // NewEVSEWifi creates EVSEWifi charger func NewEVSEWifi(uri string) (api.Charger, error) { evse := &EVSEWifi{ - HTTPHelper: util.NewHTTPHelper(util.NewLogger("wifi")), - uri: strings.TrimRight(uri, "/"), + HTTPHelper: util.NewHTTPHelper(util.NewLogger("wifi")), + uri: strings.TrimRight(uri, "/"), + alwaysActive: true, } return evse, nil @@ -87,10 +89,11 @@ func (evse *EVSEWifi) getParameters() (EVSEListEntry, error) { } params := pr.List[0] - if params.AlwaysActive { - evse.HTTPHelper.Log.WARN.Println("cannot control evse- alwaysactive is on") + if !params.AlwaysActive { + evse.HTTPHelper.Log.WARN.Println("evse should be configured to remote mode") } + evse.alwaysActive = params.AlwaysActive return params, nil } @@ -134,6 +137,14 @@ func (evse *EVSEWifi) checkError(b []byte, err error) error { // Enable implements the Charger.Enable interface func (evse *EVSEWifi) Enable(enable bool) error { url := fmt.Sprintf("%s?active=%v", evse.apiURL(evseSetStatus), enable) + + if evse.alwaysActive { + current := 0 + if enable { + current = 6 + } + url = fmt.Sprintf("%s?current=%d", evse.apiURL(evseSetCurrent), current) + } return evse.checkError(evse.Get(url)) }