diff --git a/cmd/soc/main.go b/cmd/soc/main.go index b3debfec1..8c24b88c2 100644 --- a/cmd/soc/main.go +++ b/cmd/soc/main.go @@ -80,7 +80,7 @@ func main() { soc, err := v.SoC() if err != nil { - if errors.As(err, &api.ErrMustRetry) { + if errors.Is(err, api.ErrMustRetry) { time.Sleep(5 * time.Second) continue } diff --git a/cmd/vehicle.go b/cmd/vehicle.go index 917e85a59..179c2caaf 100644 --- a/cmd/vehicle.go +++ b/cmd/vehicle.go @@ -1,6 +1,10 @@ package cmd import ( + "errors" + "fmt" + "time" + "github.com/andig/evcc/api" "github.com/andig/evcc/server" "github.com/andig/evcc/util" @@ -45,7 +49,32 @@ func runVehicle(cmd *cobra.Command, args []string) { } d := dumper{len: len(vehicles)} +NEXT: for name, v := range vehicles { + start := time.Now() + + WAIT: + // wait up to 1m for the vehicle to wakeup + for { + if time.Since(start) > time.Minute { + log.ERROR.Println(api.ErrTimeout) + continue NEXT + } + + if _, err := v.SoC(); err != nil { + if errors.Is(err, api.ErrMustRetry) { + time.Sleep(5 * time.Second) + fmt.Print(".") + continue WAIT + } + + log.ERROR.Println(err) + continue NEXT + } + + break + } + d.DumpWithHeader(name, v) } }