audi_connect_ha
audi_connect_ha copied to clipboard
Change to audi_services.py for timed charging breaks A3 etron charging
We recently lost the ability to start the charger on our A3 etron, we could still stop the charger but requesting a start would result in a 403 Forbidden error being returned.
Delving into it a bit more this morning I discovered that it appeared to be objecting to the new start format
async def set_battery_charger(self, vin: str, start: bool, timer: bool):
if start and timer:
data = '{ "action": { "type": "selectChargingMode", "settings": { "chargeModeSelection": { "value": "timerBasedCharging" } } }}'
elif start:
data = '{ "action": { "type": "selectChargingMode", "settings": { "chargeModeSelection": { "value": "immediateCharging" } } }}'
else:
data = '{ "action": { "type": "stop" }}'
Changing it to the following allowed the code to successfully request a new charge to start…
async def set_battery_charger(self, vin: str, start: bool, timer: bool):
if start and timer:
data = '{ "action": { "type": "selectChargingMode", "settings": { "chargeModeSelection": { "value": "timerBasedCharging" } } }}'
elif start:
data = '{ "action": { "type": "start" }}'
else:
data = '{ "action": { "type": "stop" }}'
Hope this helps anyone else hitting the same issue.
Thank you, had the same issue. This Change works for me :-)