Skip to content

Commit 705d79a

Browse files
authored
Merge pull request #305 from schenlap/features/evse-improve
Support alwaysactive mode
2 parents 81b72e2 + 9b92f42 commit 705d79a

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

charger/evsewifi.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type EVSEListEntry struct {
4747
type EVSEWifi struct {
4848
*util.HTTPHelper
4949
uri string
50+
alwaysActive bool
5051
}
5152

5253
func init() {
@@ -66,8 +67,9 @@ func NewEVSEWifiFromConfig(other map[string]interface{}) (api.Charger, error) {
6667
// NewEVSEWifi creates EVSEWifi charger
6768
func NewEVSEWifi(uri string) (api.Charger, error) {
6869
evse := &EVSEWifi{
69-
HTTPHelper: util.NewHTTPHelper(util.NewLogger("wifi")),
70-
uri: strings.TrimRight(uri, "/"),
70+
HTTPHelper: util.NewHTTPHelper(util.NewLogger("wifi")),
71+
uri: strings.TrimRight(uri, "/"),
72+
alwaysActive: true,
7173
}
7274

7375
return evse, nil
@@ -91,10 +93,11 @@ func (evse *EVSEWifi) getParameters() (EVSEListEntry, error) {
9193
}
9294

9395
params := pr.List[0]
94-
if params.AlwaysActive {
95-
evse.HTTPHelper.Log.WARN.Println("cannot control evse- alwaysactive is on")
96+
if !params.AlwaysActive {
97+
evse.HTTPHelper.Log.WARN.Println("evse should be configured to remote mode")
9698
}
9799

100+
evse.alwaysActive = params.AlwaysActive
98101
return params, nil
99102
}
100103

@@ -138,6 +141,14 @@ func (evse *EVSEWifi) checkError(b []byte, err error) error {
138141
// Enable implements the Charger.Enable interface
139142
func (evse *EVSEWifi) Enable(enable bool) error {
140143
url := fmt.Sprintf("%s?active=%v", evse.apiURL(evseSetStatus), enable)
144+
145+
if evse.alwaysActive {
146+
current := 0
147+
if enable {
148+
current = 6
149+
}
150+
url = fmt.Sprintf("%s?current=%d", evse.apiURL(evseSetCurrent), current)
151+
}
141152
return evse.checkError(evse.Get(url))
142153
}
143154

0 commit comments

Comments
 (0)