Wakeup: wake via charger and vehicle api in parallel, add for Porsche (#8204)

This commit is contained in:
MarkusGH 2023-06-01 18:09:11 +02:00 • committed by GitHub
parent cedd4f5568
commit ee16e3bb67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -179,7 +179,6 @@ func (lp *Loadpoint) wakeUpVehicle() {
if err := c.WakeUp(); err != nil {
lp.log.ERROR.Printf("wake-up charger: %v", err)
}
return
}
// vehicle

View file

@ -14,6 +14,7 @@ type Provider struct {
statusG func() (StatusResponse, error)
emobilityG func() (EmobilityResponse, error)
mobileG func() (StatusResponseMobile, error)
wakeup func() error
}
// NewProvider creates a vehicle api provider
@ -33,6 +34,15 @@ func NewProvider(log *util.Logger, api *API, emobility *EmobilityAPI, mobile *Mo
mobileG: provider.Cached(func() (StatusResponseMobile, error) {
return mobile.Status(vin, []string{BATTERY_LEVEL, BATTERY_CHARGING_STATE, CLIMATIZER_STATE, E_RANGE, HEATING_STATE, MILEAGE})
}, cache),
wakeup: func() error {
_, _ = api.Status(vin)
if carModel != "" {
_, _ = emobility.Status(vin, carModel)
}
_, _ = mobile.Status(vin, []string{BATTERY_LEVEL})
return nil
},
}
return impl
@ -242,3 +252,10 @@ func (v *Provider) Odometer() (float64, error) {
return 0, err
}
var _ api.Resurrector = (*Provider)(nil)
// WakeUp implements the api.Resurrector interface
func (v *Provider) WakeUp() error {
return v.wakeup()
}