evcc-io/vehicle/subaru/provider.go
2025-12-25 12:01:22 +00:00

30 lines
563 B
Go

package subaru
import (
"time"
"github.com/evcc-io/evcc/util"
)
type Provider struct {
status func() (Status, error)
}
func NewProvider(api *API, vin string, cache time.Duration) *Provider {
impl := &Provider{
status: util.Cached(func() (Status, error) {
return api.Status(vin)
}, cache),
}
return impl
}
func (v *Provider) Soc() (float64, error) {
res, err := v.status()
return float64(res.Payload.BatteryLevel), err
}
func (v *Provider) Range() (int64, error) {
res, err := v.status()
return int64(res.Payload.EvRangeWithAc.Value), err
}