From c3e7f59f18e47126edc767421d040635fa92dfa7 Mon Sep 17 00:00:00 2001 From: andig Date: Thu, 23 Jan 2025 12:03:53 +0100 Subject: [PATCH] Bluelink: add climater (#18370) --- vehicle/bluelink/provider.go | 11 +++++++++++ vehicle/bluelink/types.go | 15 +++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/vehicle/bluelink/provider.go b/vehicle/bluelink/provider.go index bf9344ac02..689f0d96af 100644 --- a/vehicle/bluelink/provider.go +++ b/vehicle/bluelink/provider.go @@ -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 diff --git a/vehicle/bluelink/types.go b/vehicle/bluelink/types.go index 06ee85d9a9..ada9edb573 100644 --- a/vehicle/bluelink/types.go +++ b/vehicle/bluelink/types.go @@ -13,6 +13,7 @@ type BluelinkVehicleStatus interface { Status() (api.ChargeStatus, error) FinishTime() (time.Time, error) Range() (int64, error) + Climater() (bool, error) GetLimitSoc() (int64, error) } @@ -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 @@ -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 { @@ -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