tillsteinbach / WeConnect-python

Python API for the Volkswagen WeConnect Services
MIT License
108 stars 30 forks source link

I have a Cupra Born, and I'd love to help make this. #26

Open initdebugs opened 2 years ago

initdebugs commented 2 years ago

Hi there! I recently picked up my Cupra Born and I'd love to make this work with my car as well. Could you tell me what I can do to help?

tillsteinbach commented 2 years ago

Good new, and congratulations to your new car. I hope you love it :) First question: Is the mycupra app already working for you? If it is working the complicated part starts. I would prepare a test version for you to try out.

initdebugs commented 2 years ago

Yes it is working! I can send you screenshots or whatever you need if you want. Would it be easier to discuss this via Discord or would you like to keep everything in Github?

initdebugs commented 2 years ago

Just let me know what information you need :)

tillsteinbach commented 2 years ago

I would prefer if we could keep the discussion here at GitHub to allow potentially others to also try it out. Also it helps a bit my working style as I can answer asynchronously :) If we have confidential parts let's use an email.

Are you a bit experienced in SW development and using python? I have a first version in a separate branch that we could use for initial testing.

initdebugs commented 2 years ago

I have some experience in python, but I have no idea what steps I should take when trying this out. Could you explain what I should do?

tillsteinbach commented 2 years ago

sure, you need to clone the project: git clone https://github.com/tillsteinbach/WeConnect-python.git and cd WeConnect-python install all requirements: pip3 install -r requirements.txt then you switch to the seat branch: git checkout feature/seat then go to the examples folder: cd examples and try out python allVehicles.py -b seat -u yourmyseatusername -p yourpassword

I guess it won't work out of the box, but we can try continuing from there with the error messages we get.

initdebugs commented 2 years ago

Traceback (most recent call last): File "allVehicles.py", line 32, in <module> main() File "allVehicles.py", line 13, in main parser.add_argument('-b', '--brand', help='Brand if other (e.g. seat)', required=False, type=weconnect.WeConnect.Brand, AttributeError: type object 'WeConnect' has no attribute 'Brand'

tillsteinbach commented 2 years ago

Can you do a python --version for me? We need at least python 3.7

initdebugs commented 2 years ago

I'm on 3.8.8

tillsteinbach commented 2 years ago

hmmmm, can you try to install it like that: pip3 install -e . and then execute the command again? might have something todo with paths

initdebugs commented 2 years ago

image

tillsteinbach commented 2 years ago

ah sorry you need to execute that in the WeConnect-python folder, not examples

initdebugs commented 2 years ago

Initialize WeConnect

Login

update

print results

done

That's what it said in command prompt. What now?

tillsteinbach commented 2 years ago

so on the positive side: you did not get an error :) on the negative side: also no data. I would need to see now what is coming back from the server. Can you add weConnect.persistCacheAsJson('test.json') right after print('# done') this should write a file with the answer from the server

initdebugs commented 2 years ago

The file is empty :(

tillsteinbach commented 2 years ago

hmmm, ok, new try: Lets use the CLI it has more logging options: git clone https://github.com/tillsteinbach/WeConnect-cli.git cd WeConnect-cli git checkout feature/seat pip3 install -e . and then: weconnect-cli -vvv -b seat -u yourmyseatusername -p yourpassword get / this should give you more output

initdebugs commented 2 years ago

I assume the last line should be python weconnect-cli -vvv -b seat -u yourmyseatusername -p yourpassword get /

I get the error about WeConnect not having attribute 'Brand'. I tried doing the pip3 install -e . but that doesn't help

tillsteinbach commented 2 years ago

no, after the pip3 install -e . the python in front should not be necessary.

tillsteinbach commented 2 years ago

what does weconnect-cli --version say?

initdebugs commented 2 years ago

Without python works, but gives the same error about the attribute 'Brand'.

weconnect-li --version gives the same error as well

tillsteinbach commented 2 years ago

maybe it has overwritten the library, can you do a pip3 install -e . in the WeConnect-python folder again and then try weconnect-cli?

initdebugs commented 2 years ago

When trying pip3 install -e . in WeConnect-python: image

tillsteinbach commented 2 years ago

yes, but I think it still overwrite the package. Can you now do a weconnect-cli --version ?

initdebugs commented 2 years ago

It still gives the attribute error

tillsteinbach commented 2 years ago

grrr. Maybe try a pip3 install -e . --force

initdebugs commented 2 years ago

weconnect-cli --version now gives: weconnect-cli develop (using WeConnect-python develop

tillsteinbach commented 2 years ago

ok, that is better. now we can go back to: weconnect-cli -vvv -b seat -u yourmyseatusername -p yourpassword get /

initdebugs commented 2 years ago

The Cache file is empty, the token file has, well, tokens.

tillsteinbach commented 2 years ago

with -vvv it should also output something about the communication that is going on

initdebugs commented 2 years ago

I'll post it, is there no sensitive data about my account in there?

tillsteinbach commented 2 years ago

There might be the VIN maybe: You can also send me an email: steinbach.till@gmx.de

initdebugs commented 2 years ago

I send you an email

initdebugs commented 2 years ago

Did you receive it? Let me know if you need anything else :)

tillsteinbach commented 2 years ago

Yes, I answered your mail. I think we are a bit stuck here. It is very hard to debug that remotely

initdebugs commented 2 years ago

{"vehicles":[{"vin":"myvin","enrollmentStatus":"completed","userRole":"primary","vehicleNickname":"CUPRA Born","specifications":{"salesType":"K11B3C","colors":{"exterior":"C2","interior":"UC","roof":"C2"},"wheels":{"rims":"F35","tires":"J49"},"steeringRight":false,"sunroof":false,"heatedSeats":true,"marketEntry":2}}]}

this came out of the thing you mailed me.

tillsteinbach commented 2 years ago

hmmm, this looks a lot different than the volkswagen version. I think for now there is not so much I can do without having access to a car and looking if there is another way to access the data in a similar way like the Volkswagen API

initdebugs commented 2 years ago

What would you exactly need from me?

tillsteinbach commented 2 years ago

trust :) You would need to change your password, send me your user and password. I would analyse the traffic between the App and the Code and after a day or two you could change your password back. Unfortunately secondary users are not yet possible. That would be the variant where you would need less trust ;)

initdebugs commented 2 years ago

I send you an email

tillsteinbach commented 2 years ago

You can change your password back

tillsteinbach commented 2 years ago

I analysed a bit what is going on. I believe that cupra is not using the same version of the API (it looks like a very early version, so maybe they are a bit behind). The requests and responses look a bit different. I think we need to look again in some months if something was changed

initdebugs commented 2 years ago

Okay, is there nothing you can do with the current version? Thanks for checking it out

tillsteinbach commented 2 years ago

Unfortunately this would be close to completely writing the library again. I can put that on the TODO list, but for now it would have low priority due to the lack of CUPRA vehicles on the streets. But that might change in the future.

initdebugs commented 2 years ago

I understand. When the My Cupra app or my car updates, I'll let you look again! Thanks for the help anyway

martenjacobs commented 2 years ago

There has been a new release of the MyCupra app. Would now be a good time to re-investigate this?

tillsteinbach commented 2 years ago

I have had a look again. It is going "in the right direction" I can see that the correct endpoints are there, but most give a 500 error back.

davmatjo commented 2 years ago

I am interested with where this is going and am willing to lend a hand if there's anything I can do. I have python experience and a Cupra Born for testing.

I'm really not surprised about the 500 errors. Up until about 2 weeks ago, the app would pretty much have a permanent "something went wrong" popping up, probably due to those broken endpoints. Recently at least the app seems to have been fully working, or at least working enough such that the errors have stopped, so it would be interesting to test again.

I gave it a quick try myself but it seems to fail after

GET /signin-service/v1/3c756d46-f1ba-4d78-9f9a-cff0d5292d51@apps_vw-dilab_com/login/authenticate

with No credentials form found

tillsteinbach commented 2 years ago

So you tried the cupra session? https://github.com/tillsteinbach/WeConnect-python/blob/main/weconnect/auth/my_cupra_session.py I have no cupra account so maybe they changed the login sequence and I would have to update it.

daernsinstantfortress commented 1 year ago

Hi all, another couple of months have passed and it looks like the Cupra mobile app has been pretty stable through this time. Could this be a good time to investigate whether it can be integrated properly? It would be great to have this work started as it's key to getting some form of integration into HA and the lovely bit of hardware I have sat waiting to display charge / range status has been sadly neglected since the car arrived earlier in the summer!

I know that myself and at least one other person here are happy to share app credentials for our own vehicles in order to facilitate this development, if this would help things.

initdebugs commented 1 year ago

Yes I agree. I would like to check again. If needed I can share my My Cupra account credentials. Let me know