Avoid treating empty charge mode as off (#333)

This commit is contained in:
andig 2020-09-10 15:25:40 +02:00 • committed by GitHub
parent 5882644fff
commit f98fc8148d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -11,7 +11,9 @@ func ChargeModeString(mode string) ChargeMode {
return ModeMinPV
case string(ModePV):
return ModePV
default:
case string(ModeOff):
return ModeOff
default:
return ""
}
}

View file

@ -177,7 +177,7 @@ func ChargeModeHandler(loadpoint loadpoint) http.HandlerFunc {
modeS, ok := vars["mode"]
mode := api.ChargeModeString(modeS)
if string(mode) != modeS || !ok {
if mode == "" || string(mode) != modeS || !ok {
w.WriteHeader(http.StatusBadRequest)
return
}