Closed zcopter closed 2 years ago
@mpredfearn
These are the payloads required for Audi e-tron to program the charging timer (up to 5 timers) and enable/disable timer based charging.
Timer programming
POST to https://mal-3a.prd.eu.dp.vwg-connect.com/api/bs/profiletimer/v1/vehicles/WAUZZZ.../actions
Payload: { "action": { "type": "setTimers", "timerList": { "timer": [ { "timerID": 1, "activationState": "activated", "timerSettings": { "timerFrequency": "cyclic", "timerTime": "05:30", "weekdayMask": "yyyyyyy" }, "chargerSettings": { "chargeOption": "enabled" }, "climatisationOption": "enabled" } ] } }}
Enable timer based charging
POST to https://fal-3a.prd.eu.dp.vwg-connect.com/fs-car/bs/batterycharge/v1/Audi/DE/vehicles/WAUZZZ.../charger/actions
Payload: { "action": { "type": "selectChargingMode", "settings": { "chargeModeSelection": { "value": "timerBasedCharging" } } }}
Immediate charing / disable timer based charging
POST to https://fal-3a.prd.eu.dp.vwg-connect.com/fs-car/bs/batterycharge/v1/Audi/DE/vehicles/WAUZZZ.../charger/actions
Payload: { "action": { "type": "selectChargingMode", "settings": { "chargeModeSelection": { "value": "immediateCharging" } } }}
@t0bias-r awesome, thank you! The current code forms an XML payload https://github.com/arjenvrh/audi_connect_ha/blob/master/custom_components/audiconnect/audi_services.py#L460 - should I chnange it to JSON, or do you suppose I can re-encode the payload in XML? I'll give it a try. Thanks again!
What I have seen in the Android apps (v4.5/v4.6) is that all actions are json encoded. I guess that Audi switched the API from XML to Json and they turn off the deprecated XML support step by step. Like they did it with the login procedure. So I would change to Json but I cannot garantuee that it works for all users.
But what I can confirm is, that my Audi A7 PHEV MY2020 and e-tron MY2021 do not support XML encoded actions anymore!
This is the returned service information from the operationlist query. See here #119 how to get the operationlist.
{
"serviceId": "rbatterycharge_v1",
"serviceType": "mbb",
"serviceStatus": {
"status": "Enabled"
},
"licenseRequired": true,
"cumulatedLicense": {
"status": "ACTIVATED",
"warn": false,
"activationBy": "automatic",
"activationDate": {
"content": "2020-11-20T00:00:00Z"
},
"expirationDate": {
"content": "2030-11-20T00:00:00Z"
},
"licenseProfiles": {
"lastUsedProfile": "LPBundle00004935",
"licenseProfile": [
{
"content": "LPBundle00004935",
"ltype": "regular",
"profileType": "implicit",
"salesPartNo": null,
"duration": "P10Y"
}
]
}
},
"primaryUserRequired": true,
"termsAndConditionsRequired": false,
"blockDisabling": false,
"personalized": false,
"configurable": false,
"deviceType": "OTHER",
"serviceEol": "2122-01-24T10:08:06Z",
"privacyGroups": {
"privacyGroup": [
"personalUser"
]
},
"parameters": {
"parameter": [
{
"content": "1",
"name": "chargeRateSupported"
},
{
"content": "1",
"name": "chargingModeSupported"
},
{
"content": "1",
"name": "chargeTargetTimeSupported"
},
{
"content": "65534",
"name": "maxRemainingChargingTime"
},
{
"content": "1",
"name": "chargingPowerSupported"
}
]
},
"rolesAndRightsRequired": true,
"invocationUrl": {
"content": "https://fal-3a.prd.eu.dp.vwg-connect.com/fs-car/bs/batterycharge/v1/{brand}/{country}/vehicles/{vin}/"
},
"operation": [
{
"id": "P_START",
"version": "1",
"xsd": "startBatteryChargingJob_v1_0_2",
"remoteCommand": "startBatteryCharging",
"permission": "granted",
"requiredUserRole": "SECONDARY_USER",
"requiredSecurityLevel": "HG_2b",
"authenticationScope": [
{
"content": "sc2:fal",
"authLevel": "T2"
}
]
},
{
"id": "P_CHRGMOD",
"version": "1",
"xsd": "chargingModeSelectionJob_v1_0_0",
"remoteCommand": "chargingModeSelectionJob",
"permission": "granted",
"requiredUserRole": "SECONDARY_USER",
"requiredSecurityLevel": "HG_2b",
"authenticationScope": [
{
"content": "sc2:fal",
"authLevel": "T2"
}
]
},
{
"id": "P_START_NOSET",
"version": "1",
"xsd": "startBatteryChargingJob_v1_0_2",
"remoteCommand": "startBatteryCharging",
"permission": "granted",
"requiredUserRole": "SECONDARY_USER",
"requiredSecurityLevel": "HG_2b",
"authenticationScope": [
{
"content": "sc2:fal",
"authLevel": "T2"
}
]
},
{
"id": "G_JOBSTATUS",
"version": "1",
"xsd": null,
"permission": "granted",
"requiredUserRole": "SECONDARY_USER",
"requiredSecurityLevel": "HG_2b",
"authenticationScope": [
{
"content": "sc2:fal",
"authLevel": "T2"
}
]
},
{
"id": "G_DATA",
"version": "1",
"xsd": "getAllChargingReportJob_v1_0_0",
"remoteCommand": "getAllChargingReport",
"permission": "granted",
"requiredUserRole": "SECONDARY_USER",
"requiredSecurityLevel": "HG_2b",
"authenticationScope": [
{
"content": "sc2:fal",
"authLevel": "T2"
}
]
},
{
"id": "P_RESET",
"version": "1",
"xsd": "resetRemoteBatteryChargingToDefaultJob_v1_0_0",
"remoteCommand": "resetRemoteBatteryChargingToDefault",
"permission": "granted",
"requiredUserRole": "SECONDARY_USER",
"requiredSecurityLevel": "HG_2b",
"authenticationScope": [
{
"content": "sc2:fal",
"authLevel": "T2"
}
]
},
{
"id": "P_SETTINGS",
"version": "1",
"xsd": "setBatteryChargingSettingsJob_v1_0_2",
"remoteCommand": "setBatteryChargingSettings",
"permission": "granted",
"requiredUserRole": "SECONDARY_USER",
"requiredSecurityLevel": "HG_2b",
"authenticationScope": [
{
"content": "sc2:fal",
"authLevel": "T2"
}
]
},
{
"id": "P_ALLOWPLUGUNLOCK",
"version": "1",
"xsd": "rbcAllowAutomaticPlugUnlockJob_v1_0_0",
"remoteCommand": "allowAutomaticPlugUnlockJob",
"permission": "granted",
"requiredUserRole": "SECONDARY_USER",
"requiredSecurityLevel": "HG_2b",
"authenticationScope": [
{
"content": "sc2:fal",
"authLevel": "T2"
}
]
},
{
"id": "P_CURRENT",
"version": "1",
"xsd": "getAllChargingReportJob_v1_0_0",
"remoteCommand": "getAllChargingReport",
"permission": "granted",
"requiredUserRole": "SECONDARY_USER",
"requiredSecurityLevel": "HG_2b",
"authenticationScope": [
{
"content": "sc2:fal",
"authLevel": "T2"
}
]
},
{
"id": "G_SETTINGS",
"version": "1",
"xsd": null,
"permission": "granted",
"requiredUserRole": "SECONDARY_USER",
"requiredSecurityLevel": "HG_2b",
"authenticationScope": [
{
"content": "sc2:fal",
"authLevel": "T2"
}
]
},
{
"id": "P_STOP",
"version": "1",
"xsd": "stopBatteryChargingJob_v1_0_0",
"remoteCommand": "stopBatteryCharging",
"permission": "granted",
"requiredUserRole": "SECONDARY_USER",
"requiredSecurityLevel": "HG_2b",
"authenticationScope": [
{
"content": "sc2:fal",
"authLevel": "T2"
}
]
},
{
"id": "G_STATUS",
"version": "1",
"xsd": "getBatteryStateReportJob_v1_0_0",
"remoteCommand": "getBatteryStateReport",
"permission": "granted",
"requiredUserRole": "SECONDARY_USER",
"requiredSecurityLevel": "HG_2b",
"authenticationScope": [
{
"content": "sc2:fal",
"authLevel": "T2"
}
]
}
]
},
I want to be able to start and "stop" the charger from HomeAssistant. start_charger is working correctly, but stop_charger does not work. Therefore, I am using a workaround; I put the target State of Charge at 100% and I manually put the timer at a far later hour (eg. 3 in the afternoon). Now, if I want to "stop" the charger at 7 in the morning, I simply "pause" the charger by using the start_timed_charger (thanks @mpredfearn !). On an average day, I disconnect the charger cable in the morning, so the timer is interrupted, but a better solution would be to be able to change the target hour via HA.
So, if I could also do the "timer programming" from HomeAssistant, I could make this solution more robust. @t0bias-r mentioned the POST and payload to do this, but I am not technical enough to make this working.
Can anybody help?
@mpredfearn
These are the payloads required for Audi e-tron to program the charging timer (up to 5 timers) and enable/disable timer based charging.
Timer programming POST to https://mal-3a.prd.eu.dp.vwg-connect.com/api/bs/profiletimer/v1/vehicles/WAUZZZ.../actions Payload:
{ "action": { "type": "setTimers", "timerList": { "timer": [ { "timerID": 1, "activationState": "activated", "timerSettings": { "timerFrequency": "cyclic", "timerTime": "05:30", "weekdayMask": "yyyyyyy" }, "chargerSettings": { "chargeOption": "enabled" }, "climatisationOption": "enabled" } ] } }}
Enable timer based charging POST to https://fal-3a.prd.eu.dp.vwg-connect.com/fs-car/bs/batterycharge/v1/Audi/DE/vehicles/WAUZZZ.../charger/actions Payload:
{ "action": { "type": "selectChargingMode", "settings": { "chargeModeSelection": { "value": "timerBasedCharging" } } }}
Immediate charing / disable timer based charging POST to https://fal-3a.prd.eu.dp.vwg-connect.com/fs-car/bs/batterycharge/v1/Audi/DE/vehicles/WAUZZZ.../charger/actions Payload:
{ "action": { "type": "selectChargingMode", "settings": { "chargeModeSelection": { "value": "immediateCharging" } } }}
Hi Tobias,
Do you perhaps also now the call for setting the chargelimit at a location? I would like to implement that to the integration to be able to control the charger of my e-tron 55 more reliable.
Thanks!
Hi Tobias,
Do you perhaps also now the call for setting the chargelimit at a location? I would like to implement that to the integration to be able to control the charger of my e-tron 55 more reliable.
Thanks!
I'm sorry, I do not have these commands. My e-tron 55 does not support this feature (as far as I know 🤔), so I'm not able to capture the traffic for that command.
Hi @tieskuh
I was able to capture the traffic, here are two Json examples. The keys and values look quite understandable:
{ "profile": { "minSOC_enabled": false, "name": "testlocation", "position": { "lat": 48.137245, "lon": 11.575359 }, "preferredChargingTimes": [ { "id": 1, "enabled": false, "startTimeLocal": "07:50", "endTimeLocal": "07:50" } ], "targetSOC_pct": 50 } }
2nd:
{ "profile": { "minSOC_enabled": true, "name": "testloc2", "position": { "lat": 48.137245, "lon": 11.575359 }, "preferredChargingTimes": [ { "id": 1, "enabled": true, "startTimeLocal": "07:55", "endTimeLocal": "15:55" } ], "targetSOC_pct": 100 } }
I can see a new URL, but I guess that the request works on the "old" URL, too.
http POST with Json to: https://emea.bff.cariad.digital/vehicle/v1/vehicles/insert_fin/charging/profiles
Polling status: https://emea.bff.cariad.digital/vehicle/v1/vehicles/insert_fin/selectivestatus?jobs=chargingProfiles
Response while operation is in progress:
{ "chargingProfiles": { "chargingProfilesStatus": { "value": { "carCapturedTimestamp": "2022-12-19T18:18:50Z", "profiles": [] }, "requests": [ { "status": "in_progress", "operation": "profiles", "body": { "profile": { "minSOC_enabled": true, "name": "testloc2", "position": { "lat": 48.137245, "lon": 11.575359 }, "preferredChargingTimes": [ { "id": 1, "enabled": true, "startTimeLocal": "07:55", "endTimeLocal": "15:55" } ], "targetSOC_pct": 100 } }, "requestId": "68ee5413-8e61-4a8e-9a42-357bd1b6a4b2", "vcfRequestId": "1223419359" } ] } } }
Response on success:
{ "chargingProfiles": { "chargingProfilesStatus": { "value": { "carCapturedTimestamp": "2022-12-22T06:56:42Z", "vehiclePositionedInProfileID": 1, "profiles": [ { "id": 1, "name": "testloc2", "maxChargingCurrent": null, "minSOC_pct": 25, "targetSOC_pct": 100, "options": { "autoUnlockPlugWhenCharged": "unsupported" }, "preferredChargingTimes": [ { "id": 1, "enabled": true, "startTimeLocal": "07:55", "endTimeLocal": "15:55" } ], "timers": [], "minSOC_enabled": true, "position": { "lat": 48.137245, "lon": 11.575359 } } ] }, "requests": [ { "status": "successful", "operation": "profiles", "body": { "profile": { "position": { "lat": 48.137245, "lon": 11.575359 }, "preferredChargingTimes": [ { "id": 1, "enabled": true, "startTimeLocal": "07:55", "endTimeLocal": "15:55" } ], "targetSOC_pct": 100, "minSOC_enabled": true, "name": "testloc2" } }, "requestId": "68ee5413-8e61-4a8e-9a42-357bd1b6a4b2", "vcfRequestId": "1223419359" } ] } } }
To delete a profile, a http DELETE is sent followed by regular progress polling. URL: https://emea.bff.cariad.digital/vehicle/v1/vehicles/insert_fin/charging/profiles/1
Happy coding and merry christmas :)
Hi @tieskuh
I was able to capture the traffic, here are two Json examples. The keys and values look quite understandable:
{ "profile": { "minSOC_enabled": false, "name": "testlocation", "position": { "lat": 48.137245, "lon": 11.575359 }, "preferredChargingTimes": [ { "id": 1, "enabled": false, "startTimeLocal": "07:50", "endTimeLocal": "07:50" } ], "targetSOC_pct": 50 } }
2nd:{ "profile": { "minSOC_enabled": true, "name": "testloc2", "position": { "lat": 48.137245, "lon": 11.575359 }, "preferredChargingTimes": [ { "id": 1, "enabled": true, "startTimeLocal": "07:55", "endTimeLocal": "15:55" } ], "targetSOC_pct": 100 } }
I can see a new URL, but I guess that the request works on the "old" URL, too. http POST with Json to: https://emea.bff.cariad.digital/vehicle/v1/vehicles/insert_fin/charging/profiles Polling status: https://emea.bff.cariad.digital/vehicle/v1/vehicles/insert_fin/selectivestatus?jobs=chargingProfiles Response while operation is in progress:
{ "chargingProfiles": { "chargingProfilesStatus": { "value": { "carCapturedTimestamp": "2022-12-19T18:18:50Z", "profiles": [] }, "requests": [ { "status": "in_progress", "operation": "profiles", "body": { "profile": { "minSOC_enabled": true, "name": "testloc2", "position": { "lat": 48.137245, "lon": 11.575359 }, "preferredChargingTimes": [ { "id": 1, "enabled": true, "startTimeLocal": "07:55", "endTimeLocal": "15:55" } ], "targetSOC_pct": 100 } }, "requestId": "68ee5413-8e61-4a8e-9a42-357bd1b6a4b2", "vcfRequestId": "1223419359" } ] } } }
Response on success:
{ "chargingProfiles": { "chargingProfilesStatus": { "value": { "carCapturedTimestamp": "2022-12-22T06:56:42Z", "vehiclePositionedInProfileID": 1, "profiles": [ { "id": 1, "name": "testloc2", "maxChargingCurrent": null, "minSOC_pct": 25, "targetSOC_pct": 100, "options": { "autoUnlockPlugWhenCharged": "unsupported" }, "preferredChargingTimes": [ { "id": 1, "enabled": true, "startTimeLocal": "07:55", "endTimeLocal": "15:55" } ], "timers": [], "minSOC_enabled": true, "position": { "lat": 48.137245, "lon": 11.575359 } } ] }, "requests": [ { "status": "successful", "operation": "profiles", "body": { "profile": { "position": { "lat": 48.137245, "lon": 11.575359 }, "preferredChargingTimes": [ { "id": 1, "enabled": true, "startTimeLocal": "07:55", "endTimeLocal": "15:55" } ], "targetSOC_pct": 100, "minSOC_enabled": true, "name": "testloc2" } }, "requestId": "68ee5413-8e61-4a8e-9a42-357bd1b6a4b2", "vcfRequestId": "1223419359" } ] } } }
To delete a profile, a http DELETE is sent followed by regular progress polling. URL: https://emea.bff.cariad.digital/vehicle/v1/vehicles/insert_fin/charging/profiles/1
Happy coding and merry christmas :)
Thanks Tobias! I will try to find some time to add these commands!
Is there the possibility that this action be added on a future update? For example trigger the car to be set in timer mode when arriving at a specific location rather than manually having to set it on the app or mmi. I see it can be done from "shortcuts" but this would be a nice feature to automate the car to use timer mode without manually setting it every day.