Skip to content

Commit

Permalink
Let vehicle command wait for refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Jun 15, 2021
1 parent 4238c4c commit 2e1fcad
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/dumper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"
"math"
"os"
Expand Down Expand Up @@ -64,7 +65,15 @@ func (d *dumper) Dump(name string, v interface{}) {
}

if v, ok := v.(api.Battery); ok {
if soc, err := v.SoC(); err != nil {
soc, err := v.SoC()

for err != nil && errors.Is(err, api.ErrMustRetry) {
fmt.Fprint(w, ".")
time.Sleep(3 * time.Second)
soc, err = v.SoC()
}

if err != nil {
fmt.Fprintf(w, "SoC:\t%v\n", err)
} else {
fmt.Fprintf(w, "SoC:\t%.0f%%\n", soc)
Expand Down

0 comments on commit 2e1fcad

Please sign in to comment.