Smart grid charging per loadpoint (BC) (#12135)

This commit is contained in:
Michael Geers 2024-02-24 17:52:15 +01:00 • committed by GitHub
parent 974cc85b6c
commit 93a1faf755
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 615 additions and 598 deletions

View file

@ -13,52 +13,6 @@ import (
"github.com/gorilla/mux"
)
type moder interface {
GetMode() api.ChargeMode
SetMode(api.ChargeMode)
}
// chargeModeHandler updates charge mode
func chargeModeHandler(lp moder) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
mode, err := api.ChargeModeString(vars["value"])
if err != nil {
jsonError(w, http.StatusBadRequest, err)
return
}
lp.SetMode(mode)
jsonResult(w, lp.GetMode())
}
}
type phaser interface {
GetPhases() int
SetPhases(int) error
}
// phasesHandler updates minimum soc
func phasesHandler(lp phaser) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
phases, err := strconv.Atoi(vars["value"])
if err == nil {
err = lp.SetPhases(phases)
}
if err != nil {
jsonError(w, http.StatusBadRequest, err)
return
}
jsonResult(w, lp.GetPhases())
}
}
// remoteDemandHandler updates minimum soc
func remoteDemandHandler(lp loadpoint.API) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {