Renault Zoe API
Posted: Wednesday 15 April 2020 21:11
I created a bash script to get the status from a Renault Zoe using an unofficial API back in 2018. Since then Renault have updated their API and it was recently rolled out in the UK.
I have adjusted the script to work with the new API and i would like to add it to the wiki, but I saw that the permissions have changed and I am no longer able to change anything. I saw I needed to PM a moderator to gain access, but I cannot PM anyone as I havnt posted enough, so i thought i would kill 2 birds with 1 stone, post more and share my script.
I have let jamesremuscat on github do all the hard work, he created pyze, then just use that to send the information to domoticz.
To install pyze I used the commands
You then need to add two API keys, you can see what infomation you need and the commands to add them here
Then login to pyze
Check everything is working with
Once setup you can fill out the domoticz info at the top of the script and run it
Enjoy
I have adjusted the script to work with the new API and i would like to add it to the wiki, but I saw that the permissions have changed and I am no longer able to change anything. I saw I needed to PM a moderator to gain access, but I cannot PM anyone as I havnt posted enough, so i thought i would kill 2 birds with 1 stone, post more and share my script.
I have let jamesremuscat on github do all the hard work, he created pyze, then just use that to send the information to domoticz.
To install pyze I used the commands
Code: Select all
git clone https://github.com/jamesremuscat/pyze
cd pyze/
sudo python3 setup.py install
Then login to pyze
Code: Select all
pyze login
Code: Select all
pyze status
Once setup you can fill out the domoticz info at the top of the script and run it
Code: Select all
#!/bin/bash
while true
do
#Domoticz Variables
username="Domoticz username"
password="Domoticz password"
domoticzIP="Domoticz IP address"
peridx="Percent IDX"
textidx="Text sensor IDX"
milesidx="Miles IDX"
battempidx="Battery temperature IDX"
updatetime="60" #not sure of the update frequency on the new api
#Variables
pyze status > ./zoeinfo.txt
info=`cat ./zoeinfo.txt`
battemp=`cat ./zoeinfo.txt | grep "Battery temp" | sed 's/Battery temperature //; s/.C//'`
batpercent=`cat ./zoeinfo.txt | grep "Battery level" | sed 's/Battery level //; s/ //; s/\%//'`
charging=`cat ./zoeinfo.txt | grep "Charging state" | sed 's/Charging state //; s/Not charging or plugged in/NotCharging/'`
plugged=`cat ./zoeinfo.txt | grep "Plug state" | sed 's/Plug state //; s/ //'`
range=`cat ./zoeinfo.txt | grep "Range es" | sed 's/Range estimate //; s/\..*//'`
chargecurrent=`cat ./zoeinfo.txt | grep "Charge rate" | sed 's/Charge rate //'`
remaining=`cat ./zoeinfo.txt | grep "Time rem" | grep -o ".:.." | sed 's/:/%20hours%20/'`
#Script
if [ $plugged = "Unplugged" ]
then
curl -i -H "Content-Type: application/json" "http://$username:$password@$domoticzIP:8080/json.htm?type=command¶m=udevice&idx=$textidx&nvalue=0&svalue=Not%20Plugged%20In"
elif [ $plugged = "Pluggedin" ]
then
if [ $charging = "Charging" ]
then
if [ -z "$remaining" ]
then
curl -i -H "Content-Type: application/json" "http://$username:$password@$domoticzIP:8080/json.htm?type=command¶m=udevice&idx=$textidx&nvalue=0&svalue=Charging%20at%20$chargecurrent"
else
curl -i -H "Content-Type: application/json" "http://$username:$password@$domoticzIP:8080/json.htm?type=command¶m=udevice&idx=$textidx&nvalue=0&svalue=Charging%20at%20$chargecurrent%0A$remaining%20remaining"
fi
elif [ $charging = "NotCharging" ] && [ $plugged = "Pluggedin" ]
then
curl -i -H "Content-Type: application/json" "http://$username:$password@$domoticzIP:8080/json.htm?type=command¶m=udevice&idx=$textidx&nvalue=0&svalue=Finished%20Charging"
fi
fi
if [ $range -gt 1 ]
then
curl -i -H "Content-Type: application/json" "http://$username:$password@$domoticzIP:8080/json.htm?type=command¶m=udevice&idx=$milesidx&nvalue=0&svalue=$range"
fi
if [ $batpercent -gt 1 ]
then
curl -i -H "Content-Type: application/json" "http://$username:$password@$domoticzIP:8080/json.htm?type=command¶m=udevice&idx=$peridx&nvalue=0&svalue=$batpercent"
fi
curl -i -H "Content-Type: application/json" "http://$username:$password@$domoticzIP:8080/json.htm?type=command¶m=udevice&idx=$battempidx&nvalue=0&svalue=$battemp"
#Time between updates
sleep $updatetime
done &