Documentation ¶
Index ¶
- Constants
- Variables
- func MetersToMiles(meters int) int
- type BatteryStatus
- type ChargingStatus
- type ClimateStatus
- type DailyStatistics
- type DateDetail
- type MonthlyStatistics
- type MonthlyTotals
- type PluginState
- type Session
- func (s *Session) BatteryStatus() (BatteryStatus, error)
- func (s *Session) CabinTempRequest() (string, error)
- func (s *Session) ChargingRequest() error
- func (s *Session) CheckCabinTempRequest(resultKey string) (bool, error)
- func (s *Session) CheckClimateOffRequest(resultKey string) (bool, error)
- func (s *Session) CheckClimateOnRequest(resultKey string) (bool, error)
- func (s *Session) CheckUpdate(resultKey string) (bool, error)
- func (s *Session) ClimateControlStatus() (ClimateStatus, error)
- func (s *Session) ClimateOffRequest() (string, error)
- func (s *Session) ClimateOnRequest() (string, error)
- func (s *Session) Connect(username, password string) error
- func (s *Session) GetCabinTemp() int
- func (s *Session) GetDailyStatistics(day time.Time) (DailyStatistics, error)
- func (s *Session) GetMonthlyStatistics(month time.Time) (MonthlyStatistics, error)
- func (s *Session) Login() error
- func (s *Session) UpdateStatus() (string, error)
- type TimeToFull
- type TripDetail
- type VehicleLocation
Constants ¶
const ( RegionUSA = "NNA" RegionEurope = "NE" RegionCanada = "NCI" RegionAustralia = "NMA" RegionJapan = "NML" )
const ( // Not connected to a charger NotConnected = PluginState("NOT_CONNECTED") // Connected to a normal J1772 Level 1 or 2 charger Connected = PluginState("CONNECTED") // Connected to a high voltage DC quick charger (ChaDeMo) QCConnected = PluginState("QC_CONNECTED") // Invalid state, when updating data from the vehicle fails. InvalidPluginState = PluginState("INVALID") )
const ( // Not charging NotCharging = ChargingStatus("NOT_CHARGING") // Normal charging from a Level 1 or 2 EVSE NormalCharging = ChargingStatus("NORMAL_CHARGING") // Rapidly charging from a ChaDeMo DC quick charger RapidlyCharging = ChargingStatus("RAPIDLY_CHARGING") // Invalid state, when updating data from the vehicle fails. InvalidChargingStatus = ChargingStatus("INVALID") )
Variables ¶
var ( // ErrNotLoggedIn is returned whenever an operation is run and // the user has not let logged in. ErrNotLoggedIn = errors.New("not logged in") // ErrUpdateFailed indicates an error talking to the Carwings // service when fetching updated vehicle data. ErrUpdateFailed = errors.New("failed to retrieve updated info from vehicle") // ClimateStatus method when no data is available. ErrClimateStatusUnavailable = errors.New("climate status unavailable") // BatteryStatus method when no data is available. ErrBatteryStatusUnavailable = errors.New("battery status unavailable") // not available when logging in. ErrVehicleInfoUnavailable = errors.New("vehicle info unavailable") // Debug indiciates whether to log HTTP responses to stderr Debug = false // Default URL for connecting to Carwings service. This is // changed by Nissan from time to time, so it's helpful to // have it be configurable. BaseURL = "https://gdcportalgw.its-mo.com/api_v230317_NE/gdc/" // Http client used for api requests Client = http.DefaultClient )
Functions ¶
func MetersToMiles ¶
MetersToMiles converts Carwings distances (in meters) to miles.
Types ¶
type BatteryStatus ¶
type BatteryStatus struct { // Date and time this battery status was retrieved from the // vehicle. Timestamp time.Time // Total capacity of the battery. Units unknown. Capacity int // Remaining battery level. Units unknown, but same as Capacity. Remaining int // Remaining battery level in Watt Hours. RemainingWH int // Current state of charge. In percent, should be roughly // equivalent to Remaining / Capacity * 100. StateOfCharge int // percent // Estimated cruising range with climate control on, in // meters. CruisingRangeACOn int // Estimated cruising range with climate control off, in // meters. CruisingRangeACOff int // Current plugged-in state PluginState PluginState // Current charging status ChargingStatus ChargingStatus // Amount of time remaining until battery is fully charged, // using different possible charging methods. TimeToFull TimeToFull }
BatteryStatus contains information about the vehicle's state of charge, current plugged-in state, charging status, and the time to charge the battery to full.
type ChargingStatus ¶
type ChargingStatus string
ChargingStatus indicates whether and how the vehicle is charging.
func (ChargingStatus) String ¶
func (cs ChargingStatus) String() string
type ClimateStatus ¶
type ClimateStatus struct { // Date and time this status was retrieved from the vehicle. LastOperationTime time.Time // The current climate control operation status. Running bool // Current plugged-in state PluginState PluginState // The amount of time the climate control system will run // while on battery power, in seconds. BatteryDuration int // The amount of time the climate control system will run // while plugged in, in seconds. PluggedDuration int // The climate preset temperature unit, F or C TemperatureUnit string // The climate preset temperature value Temperature int // Time the AC was stopped, or is scheduled to stop ACStopTime time.Time // Estimated cruising range with climate control on, in // meters. CruisingRangeACOn int // Estimated cruising range with climate control off, in // meters. CruisingRangeACOff int }
ClimateStatus contains information about the vehicle's climate control (AC or heater) status.
type DailyStatistics ¶
type DailyStatistics struct { TargetDate time.Time EfficiencyScale string Efficiency float64 `json:",string"` EfficiencyLevel int `json:",string"` PowerConsumedMotor float64 `json:",string"` PowerConsumedMotorLevel int `json:",string"` PowerRegeneration float64 `json:",string"` PowerRegenerationLevel int `json:",string"` PowerConsumedAUX float64 `json:",string"` PowerConsumedAUXLevel int `json:",string"` }
DailyStatistics holds the statistics for a day
type DateDetail ¶
type DateDetail struct { TargetDate string Trips []TripDetail }
DateDetail is the detail for a single date
type MonthlyStatistics ¶
type MonthlyStatistics struct { EfficiencyScale string ElectricityRate float64 ElectricityBill float64 Dates []DateDetail Total MonthlyTotals }
MonthlyStatistics is the structure returned which includes all of the trips and all of the totals as well as the electricity rate informtion that has been supplied to CarWings.
type MonthlyTotals ¶
type MonthlyTotals struct { Trips int `json:"TotalNumberOfTrips,string"` PowerConsumed float64 `json:"TotalPowerConsumptTotal,string"` PowerConsumedMotor float64 `json:"TotalPowerConsumptMoter,string"` PowerRegenerated float64 `json:"TotalPowerConsumptMinus,string"` MetersTravelled int `json:"TotalTravelDistance,string"` Efficiency float64 `json:"TotalElectricMileage,string"` CO2Reduction int `json:"TotalCO2Reductiont,string"` }
MonthlyTotals holds the various totals of things for the whole month
type PluginState ¶
type PluginState string
PluginState indicates whether and how the vehicle is plugged in. It is separate from ChargingStatus, because the vehicle can be plugged in but not actively charging.
func (PluginState) String ¶
func (ps PluginState) String() string
type Session ¶
type Session struct { // Region is one of the predefined region codes where this car operates. Region string // Filename is an optional file to load and save an existing session to. Filename string VIN string // contains filtered or unexported fields }
Session defines a one or more connections to the Carwings service
func (*Session) BatteryStatus ¶
func (s *Session) BatteryStatus() (BatteryStatus, error)
BatteryStatus returns the most recent battery status from the Carwings service. Note that this data is not real-time: it is cached from the last time the vehicle data was updated. Use UpdateStatus method to update vehicle data.
func (*Session) CabinTempRequest ¶
CabinTempRequest sends a request to get the cabin temperature. This is an asynchronous operation: it returns a "result key" that can be used to poll for status with the CheckCabinTempRequest method.
func (*Session) ChargingRequest ¶
ChargingRequest begins charging a plugged-in vehicle.
func (*Session) CheckCabinTempRequest ¶
CheckCabinTempRequest returns whether the CabinTempRequest has finished.
func (*Session) CheckClimateOffRequest ¶
CheckClimateOffRequest returns whether the ClimateOffRequest has finished.
func (*Session) CheckClimateOnRequest ¶
CheckClimateOnRequest returns whether the ClimateOnRequest has finished.
func (*Session) CheckUpdate ¶
CheckUpdate returns whether the update corresponding to the provided result key has finished.
func (*Session) ClimateControlStatus ¶
func (s *Session) ClimateControlStatus() (ClimateStatus, error)
ClimateControlStatus returns the most recent climate control status from the Carwings service.
func (*Session) ClimateOffRequest ¶
ClimateOffRequest sends a request to turn off the climate control system. This is an asynchronous operation: it returns a "result key" that can be used to poll for status with the CheckClimateOffRequest method.
func (*Session) ClimateOnRequest ¶
ClimateOnRequest sends a request to turn on the climate control system. This is an asynchronous operation: it returns a "result key" that can be used to poll for status with the CheckClimateOnRequest method.
func (*Session) Connect ¶
Connect establishes a new authenticated Session with the Carwings service.
func (*Session) GetCabinTemp ¶
GetCabinTemp returns the latest cached cabin temperature result.
func (*Session) GetDailyStatistics ¶
func (s *Session) GetDailyStatistics(day time.Time) (DailyStatistics, error)
GetDailyStatistics returns the statistics for a specified Date^W^W^Wtoday
func (*Session) GetMonthlyStatistics ¶
func (s *Session) GetMonthlyStatistics(month time.Time) (MonthlyStatistics, error)
GetMonthlyStatistics gets the statistics for a particular month
func (*Session) UpdateStatus ¶
UpdateStatus asks the Carwings service to request an update from the vehicle. This is an asynchronous operation: it returns a "result key" that must be used to poll for status with the CheckUpdate method.
type TimeToFull ¶
type TimeToFull struct { // Time to fully charge the battery using a 1.4 kW Level 1 // (120V 12A) trickle charge. Level1 time.Duration // Time to fully charge the battery using a 3.3 kW Level 2 // (240V ~15A) charge. Level2 time.Duration // Time to fully charge the battery using a 6.6 kW Level 2 // (240V ~30A) charge. Level2At6kW time.Duration }
TimeToFull contains information about how long it will take to charge the battery to full via different charging methods.
type TripDetail ¶
type TripDetail struct { // "PriceSimulatorDetailInfoTrip": [ // { // "TripId": "1", // "PowerConsumptTotal": "2461.12", // "PowerConsumptMoter": "3812.22", // "PowerConsumptMinus": "1351.1", // "TravelDistance": "17841", // "ElectricMileage": "13.8", // "CO2Reduction": "3", // "MapDisplayFlg": "NONACTIVE", // "GpsDatetime": "2018-08-05T10:18:47" // }, TripId int `json:",string"` PowerConsumedTotal float64 `json:"PowerConsumptTotal,string"` PowerConsumedMotor float64 `json:"PowerConsumptMoter,string"` PowerRegenerated float64 `json:"PowerConsumptMinus,string"` Meters int `json:"TravelDistance,string"` Efficiency float64 `json:"ElectricMileage,string"` CO2Reduction int `json:",string"` MapDisplayFlag string `json:"MapDisplayFlg"` GPSDateTime cwTime `json:"GpsDatetime"` Started time.Time `json:",omitempty"` }
TripDetail holds the details of each trip. All of the parsed detail is used in both the response and the MonthlyStatistics.