Support waking up custom chargers/vehicles (#8005)
This commit is contained in:
parent
13dd7d578e
commit
5adacb06c3
5 changed files with 468 additions and 48 deletions
14
api/api.go
14
api/api.go
|
|
@ -2,8 +2,10 @@ package api
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -40,6 +42,18 @@ const (
|
|||
StatusF ChargeStatus = "F" // Fzg. angeschlossen: ja Laden aktiv: nein - Fehler (Ausfall Wallbox)
|
||||
)
|
||||
|
||||
// ChargeStatusString converts a string to ChargeStatus
|
||||
func ChargeStatusString(s string) (ChargeStatus, error) {
|
||||
switch strings.ToUpper(s) {
|
||||
case "A", "B", "C":
|
||||
return ChargeStatus(s), nil
|
||||
case "D", "E", "F":
|
||||
return ChargeStatus(s), fmt.Errorf("invalid status: %s", s)
|
||||
default:
|
||||
return StatusNone, fmt.Errorf("invalid status: %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
// String implements Stringer
|
||||
func (c ChargeStatus) String() string {
|
||||
return string(c)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue