psa

package
v0.0.0-...-610f8f3 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURL = "https://api.groupe-psa.com/connectedcar/v4"

BaseURL is the API base url

Variables

This section is empty.

Functions

func NewIdentity

func NewIdentity(log *util.Logger, brand, user string, oc *oauth2.Config, token *oauth2.Token) (oauth2.TokenSource, error)

NewIdentity creates PSA identity

func Oauth2Config

func Oauth2Config(brand, country string) *oauth2.Config

Types

type API

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

API is an api.Vehicle implementation for PSA cars

func NewAPI

func NewAPI(log *util.Logger, identity oauth2.TokenSource, realm, id string) *API

NewAPI creates a new vehicle

func (*API) Status

func (v *API) Status(vid string) (Status, error)

Status implements the /vehicles/<vid>/status response

func (*API) Vehicles

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

Vehicles implements the /vehicles response

type Duration

type Duration struct {
	time.Duration
}

Duration is a time.Duration that can be unmarshalled from JSON

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler

type Energy

type Energy struct {
	UpdatedAt time.Time
	Type      string // Fuel/Electric
	Level     float64
	Autonomy  int
	Charging  struct {
		Plugged         bool
		Status          string // InProgress
		RemainingTime   Duration
		ChargingRate    int
		ChargingMode    string // "Slow"
		NextDelayedTime Duration
	}
}

Energy is the /status partial energy response

type Identity

type Identity struct {
	oauth2.TokenSource
	// contains filtered or unexported fields
}

func (*Identity) RefreshToken

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

type Provider

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

Provider is an api.Vehicle implementation for PSA cars

func NewProvider

func NewProvider(api *API, vid string, cache time.Duration) *Provider

NewProvider creates a vehicle api provider

func (*Provider) Climater

func (v *Provider) Climater() (bool, error)

Climater implements the api.VehicleClimater interface

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)

Odometer implements the api.VehicleOdometer 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.Vehicle interface

func (*Provider) Status

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

Status implements the api.ChargeState interface

type Status

type Status struct {
	Battery struct {
		Capacity int64
		Health   struct {
			Capacity   int64
			Resistance int64
		}
	}
	Charging struct {
		ChargingMode    string
		ChargingRate    int64
		NextDelayedTime string
		Plugged         bool
		RemainingTime   string
		Status          string
	}
	Preconditionning struct {
		AirConditioning struct {
			UpdatedAt time.Time
			Status    string // Disabled
		}
	}
	Energy   []Energy
	Odometer struct {
		Mileage float64
	}
	LastPosition struct {
		Type     string
		Geometry struct {
			Type        string
			Coordinates []float64
		}
		Properties struct {
			UpdatedAt time.Time
			Type      string
			Heading   int
		}
	}
}

Status is the /status response

type Vehicle

type Vehicle struct {
	ID       string   `json:"id"`
	Label    string   `json:"label"`
	Pictures []string `json:"pictures"`
	VIN      string   `json:"vin"`
}

Vehicle is a single vehicle

Jump to

Keyboard shortcuts

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