audi_connect_ha icon indicating copy to clipboard operation
audi_connect_ha copied to clipboard

Change to audi_services.py for timed charging breaks A3 etron charging

Open duckend opened this issue 2 years ago • 1 comments

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.

duckend avatar Mar 27 '22 12:03 duckend

Thank you, had the same issue. This Change works for me :-)

skl283 avatar Mar 30 '22 19:03 skl283