bluelink

package
v0.0.0-...-f411113 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VehiclesURL         = "vehicles"
	StatusURL           = "vehicles/%s/status"
	StatusLatestURL     = "vehicles/%s/status/latest"
	StatusURLCCS2       = "vehicles/%s/ccs2/carstatus"
	StatusLatestURLCCS2 = "vehicles/%s/ccs2/carstatus/latest"
)
View Source
const (
	DeviceIdURL        = "/api/v1/spa/notifications/register"
	IntegrationInfoURL = "/api/v1/user/integrationinfo"
	SilentSigninURL    = "/api/v1/user/silentsignin"
	LanguageURL        = "/api/v1/user/language"
	LoginURL           = "/api/v1/user/signin"
	TokenURL           = "/api/v1/user/oauth2/token"
)
View Source
const (
	KiaAppID     = "a2b8469b-30a3-4361-8e13-6fceea8fbe74"
	HyundaiAppID = "014d2225-8495-4735-812d-2616334fd15d"
)

Variables

View Source
var ErrAuthFail = errors.New("authorization failed")

ErrAuthFail indicates authorization failure

Functions

This section is empty.

Types

type API

type API struct {
	*request.Helper
	// contains filtered or unexported fields
}

API implements the Kia/Hyundai bluelink api.

func NewAPI

func NewAPI(log *util.Logger, baseURI string, decorator func(*http.Request) error) *API

New creates a new BlueLink API

func (*API) StatusLatest

func (v *API) StatusLatest(vehicle Vehicle) (BluelinkVehicleStatusLatest, error)

StatusLatest retrieves the latest server-side status

func (*API) StatusPartial

func (v *API) StatusPartial(vehicle Vehicle) (BluelinkVehicleStatus, error)

StatusPartial refreshes the status

func (*API) Vehicles

func (v *API) Vehicles() ([]Vehicle, error)

type BluelinkVehicleStatus

type BluelinkVehicleStatus interface {
	Updated() (time.Time, error)
	SoC() (float64, error)
	Status() (api.ChargeStatus, error)
	FinishTime() (time.Time, error)
	Range() (int64, error)
	GetLimitSoc() (int64, error)
}

type BluelinkVehicleStatusLatest

type BluelinkVehicleStatusLatest interface {
	BluelinkVehicleStatus() BluelinkVehicleStatus
	Odometer() (float64, error)
	Position() (float64, float64, error)
}

type Config

type Config struct {
	URI               string
	AuthClientID      string // v2
	BrandAuthUrl      string // v2
	BasicToken        string
	CCSPServiceID     string
	CCSPApplicationID string
	PushType          string
	Cfb               string
}

Config is the bluelink API configuration

type DrivingDistance

type DrivingDistance struct {
	RangeByFuel struct {
		EvModeRange struct {
			Value int
		}
	}
}

type Identity

type Identity struct {
	*request.Helper

	oauth2.TokenSource
	// contains filtered or unexported fields
}

Identity implements the Kia/Hyundai bluelink identity. Based on https://github.com/Hacksore/bluelinky.

func NewIdentity

func NewIdentity(log *util.Logger, config Config) *Identity

NewIdentity creates BlueLink Identity

func (*Identity) Login

func (v *Identity) Login(user, password, language string) (err error)

func (*Identity) RefreshToken

func (v *Identity) RefreshToken(token *oauth2.Token) (*oauth2.Token, error)

RefreshToken implements oauth.TokenRefresher

func (*Identity) Request

func (v *Identity) Request(req *http.Request) error

Request decorates requests with authorization headers

type Odometer

type Odometer struct {
	Value float64
	Unit  int
}

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements the vehicle api. Based on https://github.com/Hacksore/bluelinky.

func NewProvider

func NewProvider(api *API, vehicle Vehicle, expiry, cache time.Duration) *Provider

New creates a new BlueLink API

func (*Provider) FinishTime

func (v *Provider) FinishTime() (time.Time, error)

FinishTime implements the api.VehicleFinishTimer interface

func (*Provider) GetLimitSoc

func (v *Provider) GetLimitSoc() (int64, error)

GetLimitSoc implements the api.SocLimiter interface

func (*Provider) Odometer

func (v *Provider) Odometer() (float64, error)

Range implements the api.VehicleRange interface

func (*Provider) Position

func (v *Provider) Position() (float64, float64, error)

Position implements the api.VehiclePosition interface

func (*Provider) Range

func (v *Provider) Range() (int64, error)

Range implements the api.VehicleRange interface

func (*Provider) Soc

func (v *Provider) Soc() (float64, error)

Soc implements the api.Battery interface

func (*Provider) Status

func (v *Provider) Status() (api.ChargeStatus, error)

Status implements the api.Battery interface

func (*Provider) WakeUp

func (v *Provider) WakeUp() error

WakeUp implements the api.Resurrector interface

type ReservChargeInfo

type ReservChargeInfo struct {
	TargetSocList []TargetSoc
}

type StatusLatestResponse

type StatusLatestResponse struct {
	RetCode string
	ResCode string
	ResMsg  struct {
		VehicleStatusInfo struct {
			VehicleStatus   VehicleStatus
			VehicleLocation *VehicleLocation
			Odometer        *Odometer
		}
	}
}

func (StatusLatestResponse) BluelinkVehicleStatus

func (d StatusLatestResponse) BluelinkVehicleStatus() BluelinkVehicleStatus

func (StatusLatestResponse) Odometer

func (d StatusLatestResponse) Odometer() (float64, error)

func (StatusLatestResponse) Position

func (d StatusLatestResponse) Position() (float64, float64, error)

type StatusLatestResponseCCS

type StatusLatestResponseCCS struct {
	RetCode string
	ResCode string
	ResMsg  struct {
		State struct {
			Vehicle VehicleStatusCCS
		}
		LastUpdateTime string
	}
}

func (StatusLatestResponseCCS) BluelinkVehicleStatus

func (d StatusLatestResponseCCS) BluelinkVehicleStatus() BluelinkVehicleStatus

func (StatusLatestResponseCCS) FinishTime

func (d StatusLatestResponseCCS) FinishTime() (time.Time, error)

func (StatusLatestResponseCCS) GetLimitSoc

func (d StatusLatestResponseCCS) GetLimitSoc() (int64, error)

func (StatusLatestResponseCCS) Odometer

func (d StatusLatestResponseCCS) Odometer() (float64, error)

func (StatusLatestResponseCCS) Position

func (d StatusLatestResponseCCS) Position() (float64, float64, error)

func (StatusLatestResponseCCS) Range

func (d StatusLatestResponseCCS) Range() (int64, error)

func (StatusLatestResponseCCS) SoC

func (StatusLatestResponseCCS) Status

func (StatusLatestResponseCCS) Updated

func (d StatusLatestResponseCCS) Updated() (time.Time, error)

type StatusResponse

type StatusResponse struct {
	RetCode string
	ResCode string
	ResMsg  VehicleStatus
}

type TargetSoc

type TargetSoc struct {
	TargetSocLevel int
	PlugType       int
}

type Vehicle

type Vehicle struct {
	VIN, VehicleName, VehicleID string
	CcuCCS2ProtocolSupport      int
}

type VehicleLocation

type VehicleLocation struct {
	Coord struct {
		Lat, Lon, Alt float64
	}
	Time string // TODO convert to timestamp
}

type VehicleStatus

type VehicleStatus struct {
	Time     string
	EvStatus *struct {
		BatteryCharge bool
		BatteryStatus float64
		BatteryPlugin int
		RemainTime2   struct {
			Atc struct {
				Value, Unit int
			}
		}
		ChargePortDoorOpenStatus int
		DrvDistance              []DrivingDistance
		ReservChargeInfos        ReservChargeInfo
	}
	Vehicles []Vehicle
}

func (VehicleStatus) FinishTime

func (d VehicleStatus) FinishTime() (time.Time, error)

func (VehicleStatus) GetLimitSoc

func (d VehicleStatus) GetLimitSoc() (int64, error)

func (VehicleStatus) Range

func (d VehicleStatus) Range() (int64, error)

func (VehicleStatus) SoC

func (d VehicleStatus) SoC() (float64, error)

func (VehicleStatus) Status

func (d VehicleStatus) Status() (api.ChargeStatus, error)

func (VehicleStatus) Updated

func (d VehicleStatus) Updated() (time.Time, error)

type VehicleStatusCCS

type VehicleStatusCCS struct {
	Location *struct {
		GeoCoord struct {
			Latitude, Longitude, Altitude float64
			Type                          int
			Date                          string
		}
	}
	Green *struct {
		BatteryManagement struct {
			BatteryRemain struct {
				Ratio float64
				Value float64
			}
			BatteryCapacity struct {
				Value float64
			}
			SoH struct {
				Ratio float64
			}
		}
		ChargingInformation struct {
			ConnectorFastening struct {
				// 1 connected
				State int
			}
			Charging struct {
				RemainTime     float64
				RemainTimeUnit int
			}
			EstimatedTime struct {
				Standard float64
				ICCB     float64
				Quick    float64
				Unit     int
			}
			ExpectedTime struct {
				StartDay  int
				StartHour int
				StartMin  int
				EndDay    int
				EndHour   int
				EndMin    int
			}
			TargetSoC struct {
				Standard int64
				Quick    int64
			}
			DTE struct {
				TargetSoC struct {
					// in Drivetrain.FuelSystem.DTE.Unit
					Standard float64
					Quick    float64
				}
			}
		}
		ChargingDoor struct {
			// 0, 2 closed, 1 open
			State int
		}
		Electric struct {
			SmartGrid struct {
				VehicleToLoad struct {
					DischargeLimitation struct {
						SoC        float64
						RemainTime float64
					}
				}
			}
		}
	}
	Drivetrain struct {
		Odometer   float64
		FuelSystem struct {
			DTE struct {
				Total int64
			}
		}
	}
}

type VehiclesResponse

type VehiclesResponse struct {
	RetCode string
	ResMsg  struct {
		Vehicles []Vehicle
	}
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL