dutchie027 / wallbox
This library calls on the Wallbox API to get information about the EV statistics from their charger
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.5
- monolog/monolog: ^3.0
- serhiy/pushover: ^1.1
Requires (Dev)
- composer/composer: ^2.4
- friendsofphp/php-cs-fixer: ^3.8
- phpstan/phpstan: ^1.5
- phpunit/phpunit: ^9
- psalm/phar: ^4.27
- dev-master
- 1.1.1
- 1.1.0
- 1.0.4
- 1.0.2
- 1.0.1
- 1.0.0
- 0.1.0
- dev-dependabot/composer/phpstan/phpstan-1.10.11
- dev-dependabot/composer/psalm/phar-5.9.0
- dev-dependabot/composer/composer/composer-2.5.5
- dev-dependabot/composer/phpunit/phpunit-9.6.6
- dev-dependabot/composer/serhiy/pushover-1.3.2
- dev-dependabot/github_actions/actions/cache-3.3.1
This package is auto-updated.
Last update: 2024-11-10 21:08:18 UTC
README
Overview
This API wrapper was written to allow me to get better metrics and usage out of my wallbox EVSE.
Usage
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(); ...
Running as a monitor
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 &
Functions
checkLock
Returns true/false if the charger is locked. true
if the charger is locked, false
if the charger is unlocked.
print $wallbox->checkLock($id);
getStats
Returns a JSON payload of stats for the charger between start and int (epoch times).
print $wallbox->getStats($id, $start, $end);
getChargerStatus
Returns a JSON payload of status of the specific charger. Sample payload
print $wallbox->getChargerStatus($id);
getFullPayload
Returns a JSON payload of status of the all chargers. Sample payload
print $wallbox->getFullPayload();
getLastChargeDuration
Returns time in xh xm if hours and minutes. If only minutes it returns xm xs.
print $wallbox->getLastChargeDuration();
checkFirmwareStatus
Checks if the firmware is up-to-date. Returns a human string about the status
print $wallbox->checkFirmwareStatus($id);
unlockCharger
Unlocks the charger.
print $wallbox->unlockCharger($id);
lockCharger
Locks the charger.
print $wallbox->lockCharger($id);
getChargerData
Returns JSON payload of the specific charger data sample
print $wallbox->getChargerData($id);
getTotalChargeTime
Returns time in xh xm if hours and minutes. If only minutes it returns xm xs.
print $wallbox->getTotalChargeTime($id);
getTotalSessions
Returns an integer denoting total charge sessions
print $wallbox->getTotalSessions($id);
Dependencies
The code uses a few external libraries, but they're all bundled in the composer.json file.
- monolog/monolog
- guzzlehttp/guzzle
- serhiy/pushover
Acknowledgements
Shout out to the Python work that cliviu74 did. This was the foundation that gave me a lot of the URLs.