Script for extracting realtime data from from SMA Sunny Portal

dev-master 2021-05-05 22:42 UTC

This package is not auto-updated.

Last update: 2024-12-25 20:49:39 UTC


README

Latest Version on Packagist Software License Total Downloads

This is a php class for collecting data from the SMA Home Energy Monitor via the SMA Sunny Portal Web Interface.

Install

Via Composer

$ composer require gunna-php/sma

Manually

Download the Zip file and extract

require_once '[PATH/TO]/src/SunnyPortal.php';

Usage

Create Instance

use GunnaPHP\SMA\SunnyPortal;

$portal  = new SunnyPortal([
	'username' => '{Portal Login Email}',
	'password' => '{Portal Login Password}'
]);

Get a List of Plants

$plants = $portal->getPlantList();
foreach ($plants AS $plantOID=>$plantName) {
    echo $plantName.': '.$plantOID.PHP_EOL;
}

Select Plant

Select the plant you want to collect the live data from

$poral->setPlant('{SMA Plant OID}');

Collect Data

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
}

Example output

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()
)

Credits

License

The MIT License (MIT). Please see License File for more information.