This API wrapper was written to allow me to get better metrics and usage out of my wallbox EVSE.
To start, simply download the package using composer:
composer require dutchie027/wallbox
After downloading it with composer, open wallbox.ini
and enter your variables and credentials.
Once you have all of that, depending on how you want to use it, create a simple PHP file that calls the library:
#!/usr/bin/php
<?php
include_once 'vendor/autoload.php';
$wallbox = new dutchie027\Wallbox\Wallbox();
...
The most common use case for the script(s) are a monitoring system. To accomplish this, there is a function called monitor
that uses a lot of defaults and will notify you of changes to the system. It will check the EVSE every 30 seconds by default and notify you of any changes using pushover with the configuration settings in .env
. To monitor the system, first create a file called monitor.php
using the below:
#!/usr/bin/php
<?php
include_once 'vendor/autoload.php';
$wallbox = new dutchie027\Wallbox\Wallbox();
$wallbox->monitor();
After you've created the monitoring file, ensure it's executable by running chmod +x monitor.php
. Once you've done that, simply trigger it with a nohup
so it runs in the background:
nohup ./monitor.php >/dev/null 2>&1 &
Returns true/false if the charger is locked. true
if the charger is locked, false
if the charger is unlocked.
print $wallbox->checkLock($id);
Returns a JSON payload of stats for the charger between start and int (epoch times).
print $wallbox->getStats($id, $start, $end);
Returns a JSON payload of status of the specific charger. Sample payload
print $wallbox->getChargerStatus($id);
Returns a JSON payload of status of the all chargers. Sample payload
print $wallbox->getFullPayload();
Returns time in xh xm if hours and minutes. If only minutes it returns xm xs.
print $wallbox->getLastChargeDuration();
Checks if the firmware is up-to-date. Returns a human string about the status
print $wallbox->checkFirmwareStatus($id);
Unlocks the charger.
print $wallbox->unlockCharger($id);
Locks the charger.
print $wallbox->lockCharger($id);
Returns JSON payload of the specific charger data sample
print $wallbox->getChargerData($id);
Returns time in xh xm if hours and minutes. If only minutes it returns xm xs.
print $wallbox->getTotalChargeTime($id);
Returns an integer denoting total charge sessions
print $wallbox->getTotalSessions($id);
The code uses a few external libraries, but they're all bundled in the composer.json file.
- monolog/monolog
- guzzlehttp/guzzle
- serhiy/pushover
Shout out to the Python work that cliviu74 did. This was the foundation that gave me a lot of the URLs.