diff --git a/api/error.go b/api/error.go new file mode 100644 index 000000000..17180a634 --- /dev/null +++ b/api/error.go @@ -0,0 +1,6 @@ +package api + +import "errors" + +// ErrNotAvailable indicates that a feature is not available +var ErrNotAvailable = errors.New("not available") diff --git a/core/wrapper/socestimator.go b/core/wrapper/socestimator.go index d06d82d80..64caf1774 100644 --- a/core/wrapper/socestimator.go +++ b/core/wrapper/socestimator.go @@ -1,6 +1,7 @@ package wrapper import ( + "errors" "math" "time" @@ -63,7 +64,9 @@ func (s *SocEstimator) RemainingChargeDuration(chargePower float64, targetSoC in return time.Duration(float64(timeRemaining) * percentRemaining / (100 - s.socCharge)) } - s.log.WARN.Printf("updating remaining time failed: %v", err) + if !errors.Is(err, api.ErrNotAvailable) { + s.log.WARN.Printf("updating remaining time failed: %v", err) + } } // estimate remaining time diff --git a/vehicle/renault.go b/vehicle/renault.go index 7a9381e4a..0e956df61 100644 --- a/vehicle/renault.go +++ b/vehicle/renault.go @@ -333,7 +333,7 @@ func (v *Renault) finishTime() (time.Time, error) { } if kr.Data.Attributes.RemainingTime == nil { - return time.Time{}, errors.New("estimate not available") + return time.Time{}, api.ErrNotAvailable } return timestamp.Add(time.Duration(*kr.Data.Attributes.RemainingTime) * time.Minute), err