dev-master
9999999-dev https://github.com/gunna-php/smaScript for extracting realtime data from from SMA Sunny Portal
MIT
The Requires
- php >=5.5.0
- ext-curl >=5.5.0
by Steven Miles
gunnaphp sma sunnyportal
Wallogit.com
2017 © Pedro Peláez
Script for extracting realtime data from from SMA Sunny Portal
![Software License][ico-license]
, (*1)
This is a php class for collecting data from the SMA Home Energy Monitor via the SMA Sunny Portal Web Interface., (*2)
``` bash $ composer require gunna-php/sma, (*3)
### Manually Download the Zip file and extract ``` PHP require_once '[PATH/TO]/src/SunnyPortal.php';
``` PHP use GunnaPHP\SMA\SunnyPortal;, (*4)
$portal = new SunnyPortal([ 'username' => '{Portal Login Email}', 'password' => '{Portal Login Password}' ]);, (*5)
### Get a List of Plants
``` PHP
$plants = $portal->getPlantList();
foreach ($plants AS $plantOID=>$plantName) {
echo $plantName.': '.$plantOID.PHP_EOL;
}
Select the plant you want to collect the live data from, (*6)
``` PHP $poral->setPlant('{SMA Plant OID}');, (*7)
### Collect Data ``` PHP while ( true ) { $data = $portal->liveData(); echo 'PV Generation: '.$data->PV.'kW'.PHP_EOL; echo 'Grid Consumption: '.$data->GridConsumption.'kW'.PHP_EOL; sleep(60); // Note: Minimum Interval between data reads is 15 secs }
``` PHP stdClass Object ( [__type] => LiveDataUI [Timestamp] => stdClass Object ( [__type] => DateTime [DateTime] => 2015-12-12T08:15:10 [Kind] => Unspecified ) [PV] => [FeedIn] => 0 [GridConsumption] => 0 [DirectConsumption] => [SelfConsumption] => [SelfSupply] => [TotalConsumption] => 0 [DirectConsumptionQuote] => [SelfConsumptionQuote] => [AutarkyQuote] => [BatteryIn] => [BatteryOut] => [BatteryChargeStatus] => [OperationHealth] => [BatteryStateOfHealth] => [InfoMessages] => Array() [WarningMessages] => Array() [ErrorMessages] => Array() [Info] => stdClass Object() ), (*8)
```, (*9)
The MIT License (MIT). Please see License File for more information., (*10)
Script for extracting realtime data from from SMA Sunny Portal
MIT
gunnaphp sma sunnyportal