Skip to content

Commit

Permalink
Mercedes: add climater (#18091)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReneNulschDE authored Jan 6, 2025
1 parent 9ed40dc commit 711f5e5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions vehicle/mercedes/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 8 additions & 0 deletions vehicle/mercedes/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions vehicle/mercedes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,9 @@ type StatusResponse struct {
Longitude float64
Latitude float64
}
Preconditioning struct {
Active bool
Timestamp time.Time
}
Timestamp time.Time
}

0 comments on commit 711f5e5

Please sign in to comment.