Simple PHP Client for reading realtime data from the Solax inverter
Via Composer: If you just want to get started quickly you should run the following:
$ composer require mstroink/solax-inverter php-http/guzzle6-adapter php-http/message
Why php-http/guzzle6-adapter php-http/message
? We are decoupled from any HTTP messaging client with help by
HTTPlug. Read about clients in the HTTPlug docs.
Ensure inverter is connected to your network. Guide (pdf) Confirm datastream from inverter by checking you can access the following URL and get a response. http://INVERTERIP/api/historyData.htm
Initializing Inverter client with guzzle6-adapter and some default settings (timeout etc.)
require 'vendor/autoload.php';
use MStroink\Solax\Inverter;
$inverter = Inverter:create('192.168.178.10');
Here is a list of all officially supported clients and adapters by HTTPlug: http://docs.php-http.org/en/latest/clients.html
Note the timeout: At night there is not enough sunlight to power the inverter.
require 'vendor/autoload.php';
use MStroink\Solax\Http\HttpClientConfigurator;
use MStroink\Solax\Inverter;
use Cake\Http\Client as CakeClient;
$clientConfigurator = (new HttpClientConfigurator())
->setHost('192.168.178.10');
->setClient(new CakeClient(['timeout' => 10]));
$inverter = new Inverter($clientConfigurator)
try {
$response = $inverter->getRealTimeData();
echo $response->Inverter->getYieldToday() . "\n";
echo $response->Inverter->getYieldTotal() . "\n";
echo $response->Inverter->getInnerTemperature() . "\n";
$response->Grid->getCurrent();
$response->Grid->getExported();
$response->Grid->getFeedInPower();
$response->Grid->getFrequency();
$response->Grid->getImported();
$response->Grid->getPower();
$response->Grid->getVoltage();
$response->Meta->getMethod();
$response->Meta->getSerialNumber();
$response->Meta->getStatus();
$response->Meta->getType();
$response->Meta->getVersion();
$response->Pv->getPv1Current();
$response->Pv->getPv1Power();
$response->Pv->getPv1Voltage();
$response->Pv->getPv2Current();
$response->Pv->getPv2Power();
$response->Pv->getPv2Voltage();
$response->toArray();
} catch (HttpServerException $e) {
//inverter is offline?
}
vendor/bin/phpunit
Please open an issue for support.