Example on how to access the Renault Zoe API using exec binding and python

Hi all,
I stumbled over this web site on reverse engineering the Renault Zoe API and as I have such a electric car I decided to integrate this into my openHAB set-up.


I know that there is a Zoe API binding in beta status out there as well, but a few curl requests seemed to me overdone for a binding. So here 's my take on this - in case somebody likes to use it:

  • Obviously you need a Renault Zoe to test this, but there are other APIs described out there (e.g. BMW). You can use the script as a basis.
  • this script assumes you have registered your-self with Renault Service.

Some python code in the file ze.py:


import requests
import json

headers = {    'Content-Type': 'application/json',}
data = '{"username":"you@email.com","password":"YourPassword"}'
response = requests.post('https://www.services.renault-ze.com/api/user/login', headers=heade$
token = response.json()["token"]
user = response.json()["user"]
vin = user["vehicle_details"]["VIN"]

# curl -H "Authorization: Bearer AAAA" "https://www.services.renault-ze.com/api/vehicle/VVVV$
headers = {    'Authorization': 'Bearer '+token,}
response = requests.get('https://www.services.renault-ze.com/api/vehicle/'+vin+'/battery', h$

print (response.json()["charge_level"])

Some notes to this script:

  • replace you@email.com and YourPassword with your credentials for the Renault service
  • make this script executable (chmod +x ze.py). If the script works well you should receive a number between 0 to 100
  • I received an [ERROR] [untime.internal.engine.RuleEngineImpl] when I tried to return the full json response to openHab (it worked in the console though) and couldn’t resolve that. Send me a note if you know why. Anyhow I was just interested in the charge status, therefor it returns only this (see the last line with [“charge_level”])
  • the web site has various other examples (air condition, etc.) on the API which should be easily implementable using this script as basis

Further implementation in openHAB is pretty straight forward:
the thing file

Thing exec:command:zoe [command="/home/pi/ze.py", interval=600, timeout=15, autorun=true]

the items file

String Zoe_Out {channel="exec:command:zoe:output"}
Number ZoeLevel "Zoe Batterie [%.0f %%]" <ecar> (gAU) 

a rule file

rule "Zoe"
     Item Zoe_Out received update
    logInfo("Zoe ", Zoe_Out.state.toString )
    var String data = Zoe_Out.state.toString
    var String level = transform("JSONPATH", "$.charge_level", data)
    ZoeLevel.postUpdate( (Float::parseFloat(level) as Number )  )

That’s it. Have fun.


I think as with the binding in beta status, this won’t work with the new ZE Services any more !?

You’re right - currently this example on how to access the Renault Zoe API isn’t working anymore. Not so much because of the exec binding, but rather due to Renault changing the API since January 2020.

I will update the tutorial as soon as I find the time, in the meantime have a look at PyZE from James Muscat or this python script by Micahel Eck.

Any news on that?