Skip to content

Commit

Permalink
Bluelink: add climater (#18370)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Jan 23, 2025
1 parent 3bccab4 commit c3e7f59
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
11 changes: 11 additions & 0 deletions vehicle/bluelink/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ func (v *Provider) Odometer() (float64, error) {
return res.Odometer()
}

var _ api.VehicleClimater = (*Provider)(nil)

// Climater implements the api.VehicleClimater interface
func (v *Provider) Climater() (bool, error) {
res, err := v.statusG()
if err != nil {
return false, err
}
return res.Climater()
}

var _ api.SocLimiter = (*Provider)(nil)

// GetLimitSoc implements the api.SocLimiter interface
Expand Down
15 changes: 13 additions & 2 deletions vehicle/bluelink/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type BluelinkVehicleStatus interface {
Status() (api.ChargeStatus, error)
FinishTime() (time.Time, error)
Range() (int64, error)
Climater() (bool, error)
GetLimitSoc() (int64, error)
}

Expand Down Expand Up @@ -48,8 +49,10 @@ type StatusLatestResponse struct {
}

type VehicleStatus struct {
Time string
EvStatus *struct {
Time string
AirCtrlOn bool
Defrost bool
EvStatus *struct {
BatteryCharge bool
BatteryStatus float64
BatteryPlugin int
Expand Down Expand Up @@ -150,6 +153,10 @@ func (d VehicleStatus) Range() (int64, error) {
return 0, api.ErrNotAvailable
}

func (d VehicleStatus) Climater() (bool, error) {
return d.AirCtrlOn || d.Defrost, nil
}

func (d VehicleStatus) GetLimitSoc() (int64, error) {
if d.EvStatus != nil {
for _, targetSOC := range d.EvStatus.ReservChargeInfos.TargetSocList {
Expand Down Expand Up @@ -323,6 +330,10 @@ func (d StatusLatestResponseCCS) Range() (int64, error) {
return d.ResMsg.State.Vehicle.Drivetrain.FuelSystem.DTE.Total, nil
}

func (d StatusLatestResponseCCS) Climater() (bool, error) {
return false, api.ErrNotAvailable
}

func (d StatusLatestResponseCCS) GetLimitSoc() (int64, error) {
if d.ResMsg.State.Vehicle.Green != nil {
return d.ResMsg.State.Vehicle.Green.ChargingInformation.TargetSoC.Standard, nil
Expand Down

0 comments on commit c3e7f59

Please sign in to comment.