diff --git a/vehicle/mercedes/api.go b/vehicle/mercedes/api.go index 47acfb0209..4a87d655b8 100644 --- a/vehicle/mercedes/api.go +++ b/vehicle/mercedes/api.go @@ -114,5 +114,15 @@ func (v *API) Status(vin string) (StatusResponse, error) { } } + // There are two attributes for the proconditioning status, precondNow and precondActive + if val, ok := message.Attributes["precondNow"]; ok { + res.Preconditioning.Active = val.GetBoolValue() + } + if !res.Preconditioning.Active { + if val, ok := message.Attributes["precondActive"]; ok { + res.Preconditioning.Active = val.GetBoolValue() + } + } + return res, err } diff --git a/vehicle/mercedes/provider.go b/vehicle/mercedes/provider.go index babbb57da2..2898d2a068 100644 --- a/vehicle/mercedes/provider.go +++ b/vehicle/mercedes/provider.go @@ -64,6 +64,14 @@ func (v *Provider) Status() (api.ChargeStatus, error) { return status, err } +var _ api.VehicleClimater = (*Provider)(nil) + +// Climater implements the api.VehicleClimater interface +func (v *Provider) Climater() (bool, error) { + res, err := v.dataG() + return res.Preconditioning.Active, err +} + var _ api.VehiclePosition = (*Provider)(nil) // Position implements the api.VehiclePosition interface diff --git a/vehicle/mercedes/types.go b/vehicle/mercedes/types.go index 98278087ca..1875d88e3f 100644 --- a/vehicle/mercedes/types.go +++ b/vehicle/mercedes/types.go @@ -73,5 +73,9 @@ type StatusResponse struct { Longitude float64 Latitude float64 } + Preconditioning struct { + Active bool + Timestamp time.Time + } Timestamp time.Time }