PHPackages                             gunna-php/sma - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. gunna-php/sma

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gunna-php/sma
=============

Script for extracting realtime data from from SMA Sunny Portal

6234[2 issues](https://github.com/gunna-php/sma/issues)PHP

Since May 5Pushed 5y ago2 watchersCompare

[ Source](https://github.com/gunna-php/sma)[ Packagist](https://packagist.org/packages/gunna-php/sma)[ RSS](/packages/gunna-php-sma/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

SMA Sunny Portal Extractor
==========================

[](#sma-sunny-portal-extractor)

[![Latest Version on Packagist](https://camo.githubusercontent.com/08b3a8365268705cf850ca542e39f332df045dcd0c148ae4b01daf76ae6d15da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67756e6e612d7068702f736d612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gunna-php/sma)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/887eacacfa9e6018df8e0a0c19639d7656b04c25303dc5cbb0aea31b39d934b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67756e6e612d7068702f736d612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gunna-php/sma)

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

Install
-------

[](#install)

### Via Composer

[](#via-composer)

```
$ composer require gunna-php/sma
```

### Manually

[](#manually)

Download the Zip file and extract

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

Usage
-----

[](#usage)

### Create Instance

[](#create-instance)

```
use GunnaPHP\SMA\SunnyPortal;

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

### Get a List of Plants

[](#get-a-list-of-plants)

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

### Select Plant

[](#select-plant)

Select the plant you want to collect the live data from

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

### Collect Data

[](#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

[](#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
-------

[](#credits)

- [Steven Miles](https://www.srmiles.com)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1708004?v=4)[Steven Miles](/maintainers/srmiles)[@srmiles](https://github.com/srmiles)

---

Top Contributors

[![daniellienert](https://avatars.githubusercontent.com/u/642226?v=4)](https://github.com/daniellienert "daniellienert (6 commits)")[![srmiles](https://avatars.githubusercontent.com/u/1708004?v=4)](https://github.com/srmiles "srmiles (6 commits)")

### Embed Badge

![Health badge](/badges/gunna-php-sma/health.svg)

```
[![Health](https://phpackages.com/badges/gunna-php-sma/health.svg)](https://phpackages.com/packages/gunna-php-sma)
```

###  Alternatives

[byrokrat/id

Data types for swedish personal identity and corporation id numbers

1599.8k5](/packages/byrokrat-id)[shubhamjain/php-id3

A MP3 ID3 tags reader in native PHP

434.4k](/packages/shubhamjain-php-id3)[verbb/shippy

A framework agnostic, multi-carrier shipping library for PHP.

1611.3k2](/packages/verbb-shippy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
