Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start/Stop/Timed Charging Not Working #227

Open
devslash0 opened this issue Feb 17, 2024 · 23 comments
Open

Start/Stop/Timed Charging Not Working #227

devslash0 opened this issue Feb 17, 2024 · 23 comments
Labels
bug Something isn't working

Comments

@devslash0
Copy link

Anyone got start_charger and stop_charger to work?

I can lock and unlock, but when i try to setup smart charging with home assistant i get:

2024-02-17 18:38:05.713 ERROR (MainThread) [custom_components.audiconnect.util] Unable to stop charger of vehicle XXX: Cannot stop charger, return code 'failed'

Running:

service: audiconnect.execute_vehicle_action
data:
vin: XXX
action: 'stop_charger'

XXX is my VIN.

@cdnninja
Copy link
Collaborator

cdnninja commented Mar 5, 2024

Try latest.

@devslash0
Copy link
Author

Same, but new error message:

2024-03-05 17:32:48.897 ERROR (MainThread) [custom_components.audiconnect.util] Unable to start charger of vehicle XXX: 403, message='', url=URL('https://msg.volkswagen.de/fs-car/bs/batterycharge/v1/Audi/DE/vehicles/XXX/charger/actions')
2024-03-05 17:33:00.451 ERROR (MainThread) [custom_components.audiconnect.util] Unable to start charger of vehicle XXX: 403, message='', url=URL('https://msg.volkswagen.de/fs-car/bs/batterycharge/v1/Audi/DE/vehicles/XXX/charger/actions')
2024-03-05 17:33:20.668 ERROR (MainThread) [custom_components.audiconnect.util] Unable to stop charger of vehicle XXX: 403, message='', url=URL('https://msg.volkswagen.de/fs-car/bs/batterycharge/v1/Audi/DE/vehicles/XXX/charger/actions')
2024-03-05 17:33:29.862 ERROR (MainThread) [custom_components.audiconnect.util] Unable to start charger of vehicle XXX: 403, message='', url=URL('https://msg.volkswagen.de/fs-car/bs/batterycharge/v1/Audi/DE/vehicles/XXX/charger/actions')

VIN replaced with XXX.

@DutchKillerbee
Copy link

Any update on the issue?
I am wondering if start stop charging is actually working for someone.

@coreywillwhat
Copy link
Contributor

Is start_charger working, but stop_charging isn't? Can you provide logs during the service call?

@devslash0
Copy link
Author

devslash0 commented Apr 16, 2024

None of them work. Testet start_charging, stop_charging and start_timed_charging during the weekend. My car is not connected at the moment (at work), so I can provide logs)

.. few hours later. The error message in my logs are the same as above. 403 error.

@coreywillwhat coreywillwhat changed the title Unable to stop charger of vehicle XXX: Cannot stop charger, return code 'failed' Start/Stop/Timed Charging Not Working Apr 17, 2024
@coreywillwhat coreywillwhat pinned this issue Apr 17, 2024
@coreywillwhat coreywillwhat added the bug Something isn't working label Apr 17, 2024
@DutchKillerbee
Copy link

DutchKillerbee commented Apr 17, 2024

I can tell that start stop charging is working for me! I am using version 1.6.2
I by coincident removed the pin code protection of my account in my car (Q3 tfsie) and after that it seems to be working!
So I assume when you protected your account in your car with a pin code in some way you need to send the pin code as well
Part of my debug log

2024-04-17 19:58:53.446 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Sending command to start charger to vehicle *************3327
2024-04-17 19:59:13.971 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Successfully started charger of vehicle *************3327
2024-04-17 19:59:13.972 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Sending command to refresh vehicle data for VIN: *************3327
2024-04-17 19:59:14.049 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] ClientResponseError with status 403 while refreshing vehicle data for VIN: *************3327. Disabling refresh vehicle data support.
2024-04-17 19:59:14.049 DEBUG (MainThread) [custom_components.audiconnect.audi_account] Refresh vehicle data is disabled for VIN: *************3327
2024-04-17 19:59:14.049 DEBUG (MainThread) [custom_components.audiconnect.audi_account] Requesting to refresh cloud data in 5 seconds...

I could only see a 403 error message...

@coreywillwhat
Copy link
Contributor

Thank you for this @DutchKillerbee! this is a great hint towards a solution. We'll have to look into how this service call is implemented. Wondering if you could provide more information about the PIN though:

  • When you had the PIN implemented on your account, did you have to enter it to start the charger?
  • If so, was that always the case, or did that recently change?

Thanks for your help!

@devslash0
Copy link
Author

Hmm. I have two Audi Accounts. The one i use in HA is a guest account, and I see now that "remote charging" is only visable in the main user. I'll try to swap to my main user and test again.

@devslash0
Copy link
Author

Testet with main account, still 403 error :/
I have my PIN entered in HA.

@DutchKillerbee
Copy link

@coreywillwhat
Sorry for my late response but let me try to describe what happened.

At a certain day (I forgot what day) I had to login with my audi account in my car profile!
The message was something like "your account has not been used for a while. Please login" Funny I used my car the day before.
I didn't have my credentials by hand so I used the profile of my son.
Both profile didn't have a pincode.
The day after I logged in my car with my credentials and all seems to be fine.
But Audi forced me to set a pin code to protect my profile.
I added a pin code and later I removed it again.
In my car everything is back to normal now. My profile is working and also all the other users profiles/accounts in my car.

Since that moment start/stop charging is working for me!
Still I have a pin code configured in the HA integration, but I think this is another pincode than the pincode in your car (to protect anybody else using your profile)

To be honest I don't know if there is any relation what I did but I can tell that start/stop charging is working for me now

If I can help you providing some logs/other stuff please let me know.

@DutchKillerbee
Copy link

Some additional (maybe helpful) information:

  • I have set timed charging on as well (using the app) Everyday at 7:50
  • Audi Q3 tfsi-e

@coreywillwhat
Copy link
Contributor

coreywillwhat commented Apr 25, 2024

Thank you so much @DutchKillerbee this is great information.
I took a look and it doesn't look like we're passing a PIN for setting the vehicle charger, which would explain why removing your PIN from the Audi Vehicle Account might allow it to work. I can see if implementing the same method as used in "lock"/"unlock", will fix it.

The problem is, I can't test this, and there is a chance any changes will break your ability to use it without a PIN @DutchKillerbee . At least until we get the chance to revert it back. I would rather test this prior to pushing to the master branch. If I draft up a PR, would either @DutchKillerbee or @devslash0 be willing to test the code before we push to the master branch?

@coreywillwhat
Copy link
Contributor

An additional question: What region are each of you? NA, EU, etc..

@devslash0
Copy link
Author

I can test yes :) available this weekend. EU (Norway)

@DutchKillerbee
Copy link

@coreywillwhat
EU Netherlands. Ready to do some tests.
Probably I will have to alter the files manually or could you prep a command to apply this patch to the current code.
Currently running 1.7.0

@harmendp
Copy link

If need be, I can test as well.
Audi Q4 etron, EU BE

@coreywillwhat
Copy link
Contributor

@coreywillwhat EU Netherlands. Ready to do some tests. Probably I will have to alter the files manually or could you prep a command to apply this patch to the current code. Currently running 1.7.0

We've debated a beta release, but it would complicate the auto-release schedule, so we haven't made any decisions on that yet. For testing, I would suggest using Studio Code Server add-on in HA to modify files/lines for testing based on the PR. It will be more clear what needs to be done when I actually put the PR together and you can take a look.

I've run into an issue with this update though, as I'm in the US, and my car doesn't support start/stop/timed charging, I won't be able to figure out the action required for the S-PIN security token.

@t0bias-r I'm not sure if you can help out here.... @DutchKillerbee is reporting that removing the SPIN from their audi account allows them to use the execute vehicle action to start/stop the charger. Looking at set_battery_charger it doens't look like we're using a security_token for this. If it is required for starting/stopping the charger, then we need to add it similar to the set_vehicle_lock. The only piece i think we're missing would be the action for the _get_security_token(). Is the action something you could help figure out?

@t0bias-r
Copy link
Contributor

@t0bias-r I'm not sure if you can help out here.... @DutchKillerbee is reporting that removing the SPIN from their audi account allows them to use the execute vehicle action to start/stop the charger. Looking at set_battery_charger it doens't look like we're using a security_token for this. If it is required for starting/stopping the charger, then we need to add it similar to the set_vehicle_lock. The only piece i think we're missing would be the action for the _get_security_token(). Is the action something you could help figure out?

@coreywillwhat I try to help :-) Just so I'm doing the right thing. I need to capture the API request for an action that requires the SPIN, right?

@coreywillwhat
Copy link
Contributor

thank you @t0bias-r! Yes, specifically the start/stop/timed charging action, if you can.

@t0bias-r
Copy link
Contributor

t0bias-r commented May 3, 2024

No matter which charging setting I change or charing action is execute (timer, immediately) in the app, I never have to enter the SPIN (for my Q8 etron).
I just need the SPIN for locking and unlocking the car.

Here are the API calls:
audi-car-locking.txt

What I don't currently know is which internal (security) calls are used for the challenge-response and for the hashing....

@TFhdKi95ae8L
Copy link

Same for me, start charging does not work anymore for a while. Willing to test / share logs if needed.
A3 Etron

@TFhdKi95ae8L
Copy link

Same for me, start charging does not work anymore for a while. Willing to test / share logs if needed. A3 Etron

Started working again. Not sure since which version, but at least as from latest 1.10.4, maybe even 1 earlier.

@thomas-hass
Copy link

thomas-hass commented Nov 11, 2024

Same here :/

2024-11-11 11:36:21.203 ERROR (MainThread) [custom_components.audiconnect.util] Unable to start charger of vehicle xxx: 403, message='', url='https://msg.volkswagen.de/fs-car/bs/batterycharge/v1/Audi/DE/vehicles/xxx/charger/actions'

Same with stop and start_timed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants