PHP code example of mstroink / steca-grid

1. Go to this page and download the library: Download mstroink/steca-grid library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mstroink / steca-grid example snippets


use MStroink\StecaGrid\Inverter;

2.168.178.10'); // host

$measurements = $inverter->getMeasurements();

$measurements->getAcCurrent();
$measurements->getAcFrequency();
$measurements->getAcPower();
$measurements->getAcVoltage();
$measurements->getDcCurrent();
$measurements->getDcPower();
$measurements->getDcVoltage();
$measurements->getTemp();

// Measurement object
echo $measurements->getDcVoltage()->getValue(); // 123.123;
echo $measurements->getDcVoltage()->getUnit(); // V;
echo $measurements->getDcVoltage()->getType(); // DC_Voltage;

// As string
echo (string) $measurements->getDcVoltage(); // '123.123 V'

// As array
print_r($measurements->toArray()); // ['dc_voltage' => ['value' => 123.123, 'unit' => DC_Voltage, 'type' => 'V']]
print_r($measurements->toList()); // ['dc_voltage' => 123.123, 'ac_power' => 12.12]


$yield = $inverter->getYieldToday();
$yield->getTotal(); // 123.45;

//As string
echo (string) $yield; // "123.45 kWh"