Skip to content

Commit d908dee

Browse files
committed
feat: tinkerforge warp: disable phase auto switch on startup
1 parent 92730e4 commit d908dee

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

charger/warp-http.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ func NewWarpHTTPFromConfig(other map[string]any) (api.Charger, error) {
7676
}
7777
}
7878

79+
if err := wb.disablePhaseAutoSwitch(); err != nil {
80+
wb.log.INFO.Printf("disabling phase auto switch skipped: %v", err)
81+
}
82+
7983
return decorateWarpHTTP(wb, currentPower, totalEnergy, currents, voltages, identity, phases, getPhases), nil
8084
}
8185

@@ -248,6 +252,19 @@ func (wb *WarpHTTP) identify() (string, error) {
248252
return res.AuthorizationInfo.TagId, err
249253
}
250254

255+
func (wb *WarpHTTP) disablePhaseAutoSwitch() error {
256+
uri := fmt.Sprintf("%s/evse/phase_auto_switch", wb.uri)
257+
data := map[string]bool{"enabled": false}
258+
259+
req, err := request.New(http.MethodPut, uri, request.MarshalJSON(data), request.JSONEncoding)
260+
if err != nil {
261+
return err
262+
}
263+
264+
var res interface{}
265+
return wb.DoJSON(req, &res)
266+
}
267+
251268
func (wb *WarpHTTP) emState() (warp.EmState, error) {
252269
var res warp.EmState
253270
uri := fmt.Sprintf("%s/power_manager/state", wb.emURI)

0 commit comments

Comments
 (0)