Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mercedes: Add preconditioning information #18091

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading