ID: fix status api json decoding
This commit is contained in:
parent
51f0a4153a
commit
6836c69dda
3 changed files with 327 additions and 8 deletions
298
vehicle/id/samples/status.json
Normal file
298
vehicle/id/samples/status.json
Normal file
|
|
@ -0,0 +1,298 @@
|
|||
{
|
||||
"data": {
|
||||
"batteryStatus": {
|
||||
"carCapturedTimestamp": "2021-09-05T12:04:03Z",
|
||||
"currentSOC_pct": 62,
|
||||
"cruisingRangeElectric_km": 229
|
||||
},
|
||||
"chargingStatus": {
|
||||
"carCapturedTimestamp": "2021-09-05T12:04:03Z",
|
||||
"remainingChargingTimeToComplete_min": 120,
|
||||
"chargingState": "charging",
|
||||
"chargeMode": "manual",
|
||||
"chargePower_kW": 4,
|
||||
"chargeRate_kmph": 29
|
||||
},
|
||||
"chargingSettings": {
|
||||
"carCapturedTimestamp": "2021-09-05T11:53:15Z",
|
||||
"maxChargeCurrentAC": "maximum",
|
||||
"autoUnlockPlugWhenCharged": "off",
|
||||
"targetSOC_pct": 80
|
||||
},
|
||||
"chargeMode": {
|
||||
"preferredChargeMode": "manual",
|
||||
"availableChargeModes": [
|
||||
"invalid"
|
||||
]
|
||||
},
|
||||
"plugStatus": {
|
||||
"carCapturedTimestamp": "2021-09-05T11:54:04Z",
|
||||
"plugConnectionState": "connected",
|
||||
"plugLockState": "locked"
|
||||
},
|
||||
"climatisationStatus": {
|
||||
"carCapturedTimestamp": "2021-09-05T11:53:17Z",
|
||||
"remainingClimatisationTime_min": 0,
|
||||
"climatisationState": "off"
|
||||
},
|
||||
"climatisationSettings": {
|
||||
"carCapturedTimestamp": "2021-09-05T11:53:17Z",
|
||||
"targetTemperature_K": 295.15,
|
||||
"targetTemperature_C": 22,
|
||||
"climatisationWithoutExternalPower": true,
|
||||
"climatizationAtUnlock": true,
|
||||
"windowHeatingEnabled": true,
|
||||
"zoneFrontLeftEnabled": false,
|
||||
"zoneFrontRightEnabled": false
|
||||
},
|
||||
"climatisationTimer": {
|
||||
"timers": [
|
||||
{
|
||||
"id": 1,
|
||||
"enabled": false,
|
||||
"singleTimer": {
|
||||
"startDateTime": "2021-02-23T05:00:00Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"enabled": false,
|
||||
"singleTimer": {
|
||||
"startDateTime": "1999-12-31T22:00:00Z"
|
||||
}
|
||||
}
|
||||
],
|
||||
"carCapturedTimestamp": "2021-09-05T11:53:12.226Z",
|
||||
"timeInCar": "2021-09-05T13:53:12+02:00"
|
||||
},
|
||||
"windowHeatingStatus": {
|
||||
"carCapturedTimestamp": "2021-09-05T11:53:18Z",
|
||||
"windowHeatingStatus": [
|
||||
{
|
||||
"windowLocation": "front",
|
||||
"windowHeatingState": "off"
|
||||
},
|
||||
{
|
||||
"windowLocation": "rear",
|
||||
"windowHeatingState": "off"
|
||||
}
|
||||
]
|
||||
},
|
||||
"rangeStatus": {
|
||||
"carCapturedTimestamp": "2021-09-05T12:04:03Z",
|
||||
"carType": "electric",
|
||||
"primaryEngine": {
|
||||
"type": "electric",
|
||||
"currentSOC_pct": 62,
|
||||
"remainingRange_km": 229
|
||||
},
|
||||
"totalRange_km": 229
|
||||
},
|
||||
"capabilityStatus": {
|
||||
"capabilities": [
|
||||
{
|
||||
"id": "automation",
|
||||
"expirationDate": "2023-10-06T00:00:00Z",
|
||||
"userDisablingAllowed": true
|
||||
},
|
||||
{
|
||||
"id": "batteryColdWarning",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "cdisDigitalKey",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "charging",
|
||||
"expirationDate": "2023-10-06T00:00:00Z",
|
||||
"userDisablingAllowed": true
|
||||
},
|
||||
{
|
||||
"id": "chargingStations",
|
||||
"expirationDate": "2023-10-06T00:00:00Z",
|
||||
"userDisablingAllowed": true
|
||||
},
|
||||
{
|
||||
"id": "climatisation",
|
||||
"expirationDate": "2023-10-06T00:00:00Z",
|
||||
"userDisablingAllowed": true
|
||||
},
|
||||
{
|
||||
"id": "dealerAppointment",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "destinations",
|
||||
"expirationDate": "2023-10-06T00:00:00Z",
|
||||
"userDisablingAllowed": true
|
||||
},
|
||||
{
|
||||
"id": "fuelStatus",
|
||||
"expirationDate": "2023-10-06T00:00:00Z",
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "ignition",
|
||||
"expirationDate": "2023-10-06T00:00:00Z",
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "mapUpdate",
|
||||
"expirationDate": "2023-10-06T00:00:00Z",
|
||||
"userDisablingAllowed": true
|
||||
},
|
||||
{
|
||||
"id": "measurements",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "onlineSpeech",
|
||||
"expirationDate": "2023-10-06T00:00:00Z",
|
||||
"userDisablingAllowed": true
|
||||
},
|
||||
{
|
||||
"id": "parkingBrake",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "parkingInformation",
|
||||
"expirationDate": "2023-10-06T00:00:00Z",
|
||||
"userDisablingAllowed": true
|
||||
},
|
||||
{
|
||||
"id": "parkingPosition",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "personalizationOnline",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "plugAndCharge",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "poiSearch",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "privateEmergencyCall",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "roadExperienceManagementLocalization",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "roadExperienceManagementLocalizationUpload",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "roadsideAssistant",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "routing",
|
||||
"expirationDate": "2023-10-06T00:00:00Z",
|
||||
"userDisablingAllowed": true
|
||||
},
|
||||
{
|
||||
"id": "state",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "trafficInformation",
|
||||
"expirationDate": "2023-10-06T00:00:00Z",
|
||||
"userDisablingAllowed": true
|
||||
},
|
||||
{
|
||||
"id": "vehicleHealth",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "vehicleHealthInspection",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "vehicleHealthWarnings",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "vehicleLights",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "vehicleWakeUpTrigger",
|
||||
"status": [
|
||||
1008
|
||||
],
|
||||
"userDisablingAllowed": false
|
||||
},
|
||||
{
|
||||
"id": "webRadio",
|
||||
"expirationDate": "2023-10-06T00:00:00Z",
|
||||
"userDisablingAllowed": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"lvBatteryStatus": {
|
||||
"batterySupport": "notAllowed"
|
||||
}
|
||||
},
|
||||
"error": {}
|
||||
}
|
||||
|
|
@ -8,14 +8,14 @@ import (
|
|||
// Status is the /status api
|
||||
type Status struct {
|
||||
Data struct {
|
||||
BatteryStatus
|
||||
ChargingStatus
|
||||
ChargingSettings
|
||||
PlugStatus
|
||||
RangeStatus
|
||||
ClimatisationSettings
|
||||
ClimatisationStatus // may be currently not available
|
||||
MaintenanceStatus
|
||||
BatteryStatus `json:"batteryStatus"`
|
||||
ChargingStatus `json:"chargingStatus"`
|
||||
ChargingSettings `json:"chargingSettings"`
|
||||
PlugStatus `json:"plugStatus"`
|
||||
RangeStatus `json:"rangeStatus"`
|
||||
ClimatisationSettings `json:"climatisationSettings"`
|
||||
ClimatisationStatus `json:"climatisationStatus"` // may be temporarily not available
|
||||
MaintenanceStatus `json:"maintenanceStatus"`
|
||||
}
|
||||
Error map[string]Error
|
||||
}
|
||||
|
|
|
|||
21
vehicle/id/types_test.go
Normal file
21
vehicle/id/types_test.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package id
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
//go:embed samples/status.json
|
||||
var data []byte
|
||||
|
||||
func TestStatus(t *testing.T) {
|
||||
var status Status
|
||||
if err := json.Unmarshal(data, &status); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if v := status.Data.ChargingStatus.RemainingChargingTimeToCompleteMin; v != 120 {
|
||||
t.Error("invalid RemainingChargingTimeToCompleteMin", v)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue