OpenEVSE: fix null pointer (#4515)

This commit is contained in:
sparkyson 2022-09-19 10:33:29 +03:00 • committed by GitHub
parent 91e1ceac38
commit 912af5f260
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -187,15 +187,17 @@ func (c *OpenEVSE) Enabled() (bool, error) {
}
if overrideResp.JSON200 != nil && overrideResp.JSON200.State != nil {
switch *overrideResp.JSON200.State {
switch state := *overrideResp.JSON200.State; state {
case "disabled":
return false, nil
case "enabled", "active":
return true, nil
default:
return false, fmt.Errorf("unknown EVSE state: %s", state)
}
}
return false, fmt.Errorf("unknown EVSE state: %s", *overrideResp.JSON200.State)
return false, errors.New("invalid EVSE state")
}
// Enable implements the api.Charger interface