Wait for vehicle wakeup (#1262)
This commit is contained in:
parent
2b430ae9b0
commit
e8e5584003
2 changed files with 30 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue