edent / Renault-Zoe-API

A basic API for getting information about your Renault Zoe Electric Vehicle.
92 stars 24 forks source link

Renault migrated ZE services to 'My Renault app' #18

Open pimmeh opened 5 years ago

pimmeh commented 5 years ago

I live in the Netherlands and since yesterday Renault migrated in a big bang from the Z.E. services to the 'My Renault App'. You had to re-register using VIN and activation code and the ZE-services website now redirects to https://www.services.renault-ze.com/restricted-country stating it no longer works and I have to use the My Renault App. That app works by itself but I was also using the API to view the status of my Zoe in my home automation system (Home Assistant). Shame on Renault that, without warning or migration time, they just stop supporting something we are using.

Is there any change you might look into this new API (if it is at all possible of course)?

edent commented 5 years ago

I no longer own a Renault Zoe, so I can't keep this API updated. Sorry.

ivanbuzyka commented 5 years ago

I am from Germany and here is nothing (yet) changed.

zeenix commented 5 years ago

@ivanbuzyka same here but now that it's been released in Netherlands, hopefully it's going to be launched in Germany too soon enough. At least there is actually an app now and it's just a matter of launching it here. I was scared it might all just be empty promises from Renault.

Podariss commented 5 years ago

My script I used for getting the info from my Zoe to Domoticz (https://www.domoticz.com/wiki/Renault_Zoe_API isn't working anymore as well... Damn you Renault... I'm trying to figure out the new method, but so far no luck.

(The new app is showing a new item; the number of kilometers on the odometer. That would be fun to get that info as well... and there might be more. Intresting)

TheReiner commented 5 years ago

Same Problem ... From France. @Podariss The number of kilometers, it will be great on Domoticz :) It's the new server ...

renault-wrd-prod-1-euw1-myrapp-one.s3-eu-west-1.amazonaws.com

with a proxy, i find this command, but it's a data binary :-(

curl -H 'Host: renault-wrd-prod-1-euw1-myrapp-one.s3-eu-west-1.amazonaws.com' -H 'User-Agent: MYRenault/3 CFNetwork/978.0.7 Darwin/18.6.0' -H 'Proxy-Connection: keep-alive' https://renault-wrd-prod-1-euw1-myrapp-one.s3-eu-west-1.amazonaws.com

oncleben31 commented 5 years ago

Clicking the hyperlink we have an xml response:

Edit: XML response deleted to simplify the feed.

timmchugh11 commented 5 years ago

I wrote linked the script for Domoticz and Renault API, it seems to still be working in the UK. May have to come up with a different solution soon tho if renault are migrating to the new app.

epenet commented 5 years ago

Based on Proxy analysis;

Sadly, Renault seems to have implemented some kind of certificate check on the API calls and I am unable to route the API calls throught the Proxy for packet analysis. If anyone finds a way to root the API calls through a proxy, then I can work on the new Python package.

svrist commented 5 years ago

Regarding the token

It looks like it uses gigya for tokens and login:

$ curl -v -XGET https://accounts.eu1.gigya.com/accounts.login\?apiKey\=3_5x-2C8b1R4MJPQXkwTPdIqgBpcw653Dakw_ZaEneQRkTBdg9UW9Qg_5G-tMNrTMc\&loginID\=sbv@email.dk\&password\=Somethinghere
{
  "callId": "d05b1c8b8a594040aca392a6839d0d3a",
  "errorCode": 0,
  "apiVersion": 2,
  "statusCode": 200,
  "statusReason": "OK",
  "time": "2019-04-09T08:40:45.936Z",
  "registeredTimestamp": 1550570591,
  "UID": "6dsadsa",
  "UIDSignature": "asdas",
  "signatureTimestamp": "1554799245",
  "created": "2019-02-19T10:03:11.326Z",
  "createdTimestamp": 1550570591,
  "isActive": true,
  "isRegistered": true,
  "isVerified": true,
  "lastLogin": "2019-04-09T08:40:45.927Z",
  "lastLoginTimestamp": 1554799245,
  "lastUpdated": "2019-02-19T10:03:50.220Z",
  "lastUpdatedTimestamp": 1550570630220,
  "loginProvider": "site",
  "oldestDataUpdated": "2019-02-19T10:03:11.326Z",
  "oldestDataUpdatedTimestamp": 1550570591326,
  "profile": {
    "email": "sbv@email.dk"
  },
  "registered": "2019-02-19T10:03:11.462Z",
  "socialProviders": "site",
  "verified": "2019-02-19T10:03:50.220Z",
  "verifiedTimestamp": 1550570630220,
  "newUser": false,
  "sessionInfo": {
    "cookieName": "gac_3_5x-2C8b1R4MJPQXkwTPdIqgBpcw653Dakw_ZaEneQRkTBdg9UW9Qg_5G-tMNrTMc",
    "cookieValue": "cfdsfdsfds"
  }
}

Which then can be used to a get a JWT token:

$ curl -v -XGET https://accounts.eu1.gigya.com/accounts.getJWT\?APIKey\=3_5x-2C8b1R4MJPQXkwTPdIqgBpcw653Dakw_ZaEneQRkTBdg9UW9Qg_5G-tMNrTMc\&login_token\=cfdsfdsfds(cookievaluefrom above)\&authMode\=cookie

{
  "callId": "cf44107a14bb4fd08412a2ef9735b5e2",
  "errorCode": 0,
  "apiVersion": 2,
  "statusCode": 200,
  "statusReason": "OK",
  "time": "2019-04-09T08:42:42.022Z",
  "ignoredFields": "",
  "id_token": "eyJ0....realjwttokenhere...nCA"
}

And yes it seems to be using certificate pinning for the actual api access

oncleben31 commented 5 years ago

On a french forum a Renault dev is teasing future features. API is inside.

On another post he is explaining the update logic of the data with the new app

TheReiner commented 5 years ago

Maybe it will help...

i found the ApiKey Amazon ;-)

Server: https://api-wired-prod-1-euw1.wrd-aws.com Key : IWmCqlG8cfNeNHGADD0WhkWHbi05k0RL

yoh-there commented 5 years ago

API is "cracked". I have it running on Node-RED now using the hard work of James

https://muscatoxblog.blogspot.com/2019/07/delving-into-renaults-new-api.html

Required keys are easily found in the APK.

OhSoGood commented 5 years ago

@Podariss, @TheReiner : do you intend to update Domoticz with Renault's new api described on muscatoxblog.blogspot.com ? I'm just starting / learning with Domoticz and feel too newbie to do it by myself in the short time

oncleben31 commented 5 years ago

@epenet how about a new home assistant integration ? @jamesremuscat Have you a roadmap for a python package ?

Podariss commented 4 years ago

@OhSoGood , I really hope so. Had it working in Domoticz, but now my graphs are so empty ;-(

epenet commented 4 years ago

Hi all, I have followed the instructions from https://muscatoxblog.blogspot.com/2019/07/delving-into-renaults-new-api.html, and built a simple test script in Python, but I cannot seem to get a Kamereon token. It keeps erroring regardless of the accountId I provide. If someone has managed to get it working I'd appreciate some pointers...

yoh-there commented 4 years ago

Somebody added a comment there detailing that step.

epenet commented 4 years ago

I'm still stuck, but maybe it's a problem with my account? Anyway, I created a mockup script here: https://github.com/epenet/Renault-Zoe-API/tree/newapimockup/Test

You'll need to edit the Credentials.json file, and set the four parameters

Then just run MyRenault.py

yoh-there commented 4 years ago

A user reported in muscat's blog comments a possible solution (at least for him/her)

epenet commented 4 years ago

Following latest comment in muscat's blog, and analysing the Node-RED implementation (https://canze.fisch.lu/access-renault-api-using-node-red-v2/), I was able to get it working in Python.

The updated mockup scripts are available on https://github.com/epenet/Renault-Zoe-API/blob/newapimockup/Test/MyRenault.py

jamesremuscat commented 4 years ago

Clicking the hyperlink we have an xml response:

<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
...
<Contents>
<Key>configuration/android/config_en_GB.json</Key>
<LastModified>2019-02-07T08:39:02.000Z</LastModified>
<ETag>"2f3611d63139e7568d5680b1ae162a57"</ETag>
<Size>29144</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
...
</ListBucketResult>

Incidentally, following any of the links to the config_LANG.json files will reveal the two API keys you need (gigyaProd and wiredProd). Yup, that's in plain text via Renault's own S3 domain. :man_facepalming:

I've now published my code at https://github.com/jamesremuscat/pyze.

TheReiner commented 4 years ago

@epenet I Have this error with your script ...

File "MyRenault.py", line 9 async def get_android_config(session, location): ^ SyntaxError: invalid syntax

Do you have any idea ?

Merci et bon Week-end.

zeenix commented 4 years ago

@TheReiner Likely you tried it with python2. Try with python3 .

TheReiner commented 4 years ago

@zeenix Thanks :) But i have a new error :-(

python3 MyRenault.py

Traceback (most recent call last): File "MyRenault.py", line 185, in loop.run_until_complete(main()) File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete return future.result() File "MyRenault.py", line 111, in main await mainwithsession(session) File "MyRenault.py", line 122, in mainwithsession in_file = open('android_config.json', 'r') FileNotFoundError: [Errno 2] No such file or directory: 'android_config.json'

LacazeThomas commented 4 years ago

@zeenix Thanks :) But i have a new error :-(

python3 MyRenault.py

Traceback (most recent call last): File "MyRenault.py", line 185, in loop.run_until_complete(main()) File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete return future.result() File "MyRenault.py", line 111, in main await mainwithsession(session) File "MyRenault.py", line 122, in mainwithsession in_file = open('android_config.json', 'r') FileNotFoundError: [Errno 2] No such file or directory: 'android_config.json'

Same issue, I created an android_condig.json file. But after I have json decode issue....

epenet commented 4 years ago

@LacazeThomas, @TheReiner,

I've just now tweaked the code so that it grabs the "android_config.json" from the renault website (on AWS). It should work better for you now.

LacazeThomas commented 4 years ago

Thank you, it's awesome. I use your script with Prometheus and this is what I'm resulting grafana zoe

TheReiner commented 4 years ago

@epenet Thanks :) It's Work fine :)

{'data': {'type': 'Car', 'id': 'XXXXXXXXXX', 'attributes': {'lastUpdateTime': '2019-07-29T17:00:50Z', 'batteryTemperature': 27, 'plugStatus': 0, 'chargeStatus': -1, 'batteryLevel': 76, 'rangeHvacOff': 240}}}

Do you think it is possible to recover the odometer of the car ?

yoh-there commented 4 years ago

The odometer is given by the /cockpit call, but it does not work for all cars. It does not for my Q210. See muscat's blog

fungus75 commented 4 years ago

home

I created a small iobroker-Adapter for the old API: https://github.com/fungus75/ioBroker.zoe ==> Worked quite nice just up to last week. Looks like Austria switched than to the new App. Currently I'm trying to get my car linked to the new App (still allways getting: "Code is invalid"). After that I'm going to try to adjust the iobroker-Adapter to the new API.

sumoo13 commented 4 years ago

@epenet i have add two fonction to your new MyRenault.py on https://github.com/epenet/Renault-Zoe-API/tree/newapimockup/Test

with i make a little php page to do this :

Capture

ironpipp commented 4 years ago

@epenet WOW wonderful, thanks for your work!!! @sumoo13 Where can I find your new functions to get total km and external air temperature? Which api calls are you making?

epenet commented 4 years ago

@sumoo13, if you send a PR I can merge it in...

sumoo13 commented 4 years ago

@epenet : i do it !

ironpipp commented 4 years ago

Hi, lately the last call to

https://api-wired-prod-1-euw1.wrd-aws.com/commerce/v1/accounts/kmr/remote-services/car-adapter/v1/cars//battery-status

returns a 403 status code with this response {"error":{"title":"authentication","code":"forbidden","details":"authentication failed"}} Have you the same error?

Decompiling the original app (ver 2.13.4) I notice that the url called is

https://api-wired-prod-1-euw1.wrd-aws.com/commerce/v1/accounts//kamereon/kca/car-adapter/v2/cars//battery-status?country=FR

but with STRANGE behavior: sometimes WORKS returning slightly different attributes:

"attributes": { "timestamp": "2020-04-04T20:14:37+02:00", //was "lastUpdateTime" "batteryLevel": 98, "batteryTemperature": 17, "batteryAutonomy": 207, //was "rangeHvacOff" "batteryCapacity": 0, "batteryAvailableEnergy": 0, "plugStatus": 0, "chargingStatus": -1 //was "chargeStatus" }

most of the times returns this ERROR:

{"type":"FUNCTIONAL","messages":[{"code":"err.func.403","message":"{\"errors\":[{\"status\":\"403\",\"code\":\"security.access\",\"detail\":\"Access is denied for this resource\"}]}"}],"errors":[{"errorCode":"err.func.403","errorMessage":"{\"errors\":[{\"status\":\"403\",\"code\":\"security.access\",\"detail\":\"Access is denied for this resource\"}]}"}],"error_reference":"FUNCTIONAL"}

What is your situation? Thanks!!!

yannickh commented 4 years ago

I'm running into the same issues. The new URL you mention does work for me, for the battery-status-endpoint. Thanks! The HVAC endpoint(s) don't work for me anymore...

epenet commented 4 years ago

I suggest you all move to https://github.com/jamesremuscat/pyze. The API from edent is dead and won't be updated...

The pyze repository from jamesremuscat is actively maintained.

yannickh commented 4 years ago

Will do, thanks