psa

package
v0.0.0-...-e05b1bb Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: MIT Imports: 14 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

This section is empty.

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     int
	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 {
	*request.Helper

	oauth2.TokenSource
	// contains filtered or unexported fields
}

func NewIdentity

func NewIdentity(log *util.Logger, brand, id, secret string) *Identity

NewIdentity creates PSA identity

func (*Identity) Login

func (v *Identity) Login(user, password string) 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