Wallbox : API Episode 3
I've received some very positive messages related to my posts about the Wallbox API. This is very rewarding and I would like to thank all the people who are reaching out 🙏🏻. In the comments, I've see people asking for API to restart the unit remotely. Since API only limit is the sky, let's see what can be done.
Hacking the APIs
Of course, I'm not sponsored by Wallbox and nothing here is supported in any case if you break something. Neither myself or Wallbox are responsible for any trouble, so play at your own risks.
Using the Chrome browser developer view (Inspect), you can really have a lot of information. I managed to catch the API call when you click on the restart button in the Wallbox website.
With this, you are able to determine the API endpoint and the payload. Easy ! ;)
I simply tried this :
function wbRestart($token,$chargerID)
{
$API="api.wall-box.com";
$config_params="
{
\"action\": 3
}
";
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS,$config_params);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
"Authorization: Bearer ".$token,
'Accept: application/json, text/plain, */*',
'Content-Type: application/json;charset=utf-8'
));
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_URL, "https://".$API."/v3/chargers/".$chargerID."/remote-action");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
and Yes !!!! It works ;)
I have a Pulsar Plus and it takes 1 min 33 secs for a full reboot cycle (from the time I issue the command to the time the charger is green again in the UI).
You can find this function in my php Framework on my GitHub repo. The sample code for restarting a Wallbox unit can be found here.
Do not hesitate to share some comments below, I interested to know what could be the use case for this new function.
I hope this helps !
Hi Frederic, thanks a lot for your work on this. This helps me with my last step in my home automation. Unfortenately I am not able to determine the token. Could you please help me with an example af on url to get the token? I use Node-red to work with api's and I want to add wallbox to this. Adjo
ReplyDeleteHi Adjo, you can check this to understand how tokens work : https://www.lets-talk-about.tech/2022/08/wallbox-get-most-of-it-with-api.html There is a specific paragraph refering to the token and how to generate it. Hope this helps !
Delete