bluelink

package
v0.0.0-...-3371691 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VehiclesURL     = "vehicles"
	StatusURL       = "vehicles/%s/status"
	StatusLatestURL = "vehicles/%s/status/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

View Source
var (
	Stamps = map[string]*stampCollection{
		KiaAppID:     {AppID: KiaAppID, Brand: "kia", /* contains filtered or unexported fields */},
		HyundaiAppID: {AppID: HyundaiAppID, Brand: "hyundai", /* contains filtered or unexported fields */},
	}
)

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(vid string) (StatusLatestResponse, error)

StatusLatest retrieves the latest server-side status

func (*API) StatusPartial

func (v *API) StatusPartial(vid string) (StatusResponse, error)

StatusPartial refreshes the status

func (*API) Vehicles

func (v *API) Vehicles() ([]Vehicle, 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, vid string, 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) 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) TargetSoc

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

TargetSoc implements the api.SocLimiter 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
		}
	}
}

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
}

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) Updated

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

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