psa

package
v0.0.0-...-e6e1b3f Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 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, brand, realm, id, secret string) *API

NewAPI creates a new vehicle

func (*API) Login

func (v *API) Login(user, password string) error

Login performs the login

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 // 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 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 new vehicle

func (*Provider) Climater

func (v *Provider) Climater() (active bool, outsideTemp float64, targetTemp float64, err 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) 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
}

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