{"id":18645739,"url":"https://github.com/orlopau/go-sma-api","last_synced_at":"2025-10-27T22:43:13.801Z","repository":{"id":54286408,"uuid":"317618864","full_name":"orlopau/go-sma-api","owner":"orlopau","description":"Provides a http api and a cli for reading sma inverters, energy meters and plants. Supports auto discovery.","archived":false,"fork":false,"pushed_at":"2021-02-27T11:00:04.000Z","size":117,"stargazers_count":12,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-26T16:09:37.777Z","etag":null,"topics":["energymeter","iot","pv","sma","sunspec"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orlopau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-01T17:34:08.000Z","updated_at":"2025-05-09T20:35:27.000Z","dependencies_parsed_at":"2022-08-13T11:00:50.122Z","dependency_job_id":null,"html_url":"https://github.com/orlopau/go-sma-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/orlopau/go-sma-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orlopau%2Fgo-sma-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orlopau%2Fgo-sma-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orlopau%2Fgo-sma-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orlopau%2Fgo-sma-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orlopau","download_url":"https://codeload.github.com/orlopau/go-sma-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orlopau%2Fgo-sma-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262099744,"owners_count":23258671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["energymeter","iot","pv","sma","sunspec"],"created_at":"2024-11-07T06:17:02.069Z","updated_at":"2025-10-27T22:43:08.770Z","avatar_url":"https://github.com/orlopau.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoEnergy-API\n\n![build](https://github.com/orlopau/go-sma-api/workflows/build/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/orlopau/go-sma-api/badge.svg?branch=master)](https://coveralls.io/github/orlopau/go-sma-api?branch=master)\n\nGoSMAApi provides tooling for interacting with plants of SMA devices. Included are a CLI Application and a Server\nproviding an API for interacting with SunSpec compatible plants.\n\n## Table of Contents\n\n* [Energy-CLI](#energy-cli)\n    + [Fetch](#fetch)\n* [Energy-API](#energy-api)\n    + [Configuration](#configuration)\n    + [Endpoints](#endpoints)\n    + [Docker](#docker)\n\n## Energy-CLI\n\nThe application provides a simple command-line application for retrieving data from a plant using SunSpec compatible\ndevices.\n\nDocumentation is provided by calling `energy-cli help`.\n\n### Fetch\n\n`fetch` fetches data from a plant. It automatically detects the device type (e.g. PV-Inverter, Battery-Inverter). The\ndata is refreshed every 10 seconds.\n\nIf the device implements a register containing a valid device address, the address is set automatically. Else, a modbus\nslave id can be provided using the `-id` parameter.\n\nThis table contains some slave IDs:\n\n| Manufacturer | Slave ID |\n| ------------ | -------- |\n| SMA          | 126      |\n\nIn case the manufacturer of your inverter isn't listed here, you can probably find some documentation by searching for\n`\u003c your device \u003e modbus api`.\n\n**Example:**\n\nGiven three devices with the following IP addresses:\n\n| Device | IP |\n| --- | --- |\n| SMA Sunny Boy 2.5 | 192.1.1.1 |\n| SMA Sunny Boy 6.0 | 192.1.1.2 |\n| SMA Sunny Boy Storage 6.0 | 192.1.1.3 |\n\nFirst, the modbus (TCP) functionality must be unlocked using the configuration interface of the device. With SMA devices\nwe can also set a custom port there, the standard port is **502**.\n\nThe command should then be `energy-cli fetch -id 126 -a 192.1.1.1:502 -a 192.1.1.2:502 -a 192.1.1.3:502`.\n\nIf everything is successful, the output resembles something similar to this:\n\n```\n2020/12/21 20:28:54 connecting to 192.1.1.1:502...\n2020/12/21 20:28:54 connected to 192.1.1.1:502\n2020/12/21 20:28:54 connecting to 192.1.1.2:502...\n2020/12/21 20:28:54 connected to 192.1.1.2:502\n2020/12/21 20:28:54 connecting to 192.1.1.3:502...\n2020/12/21 20:28:54 connected to 192.1.1.3:502\n+--------------------+-------+-----+\n|      ADDRESS       | POWER | SOC |\n+--------------------+-------+-----+\n| 192.168.1.1:502    | 123W  |     |\n| 192.168.1.2:502    | 300W  |     |\n| 192.168.1.3:502    | -20W  | 68% |\n+--------------------+-------+-----+\n```\n\n## Energy-API\n\nThe server provides access to aggregated data of a plant via an HTTP API. A configuration file describing the plant and\nits devices is required.\n\nData is fetched after a message from the plant's energy meter is received, to retrieve the most accurate data for a\npoint in time. By default, the energymeter sends a message each second, resulting in a refresh interval of 1 second on\nthe server.\n\n### Configuration\n\n*Environment Variables:*\n\n| Environment Variable | Info | Default |\n| --- | --- | --- |\n| ENERGY_PORT | Port of the server | 8080 |\n| ENERGY_CONFIG_PATH | Path to the plant config | . |\n\n*Plant config:*\n\nThe server must be configured using a .yml file, called `plants.yml`.\n\nExample:\n\n```yaml\nplant1: # name of the plant\n  sunspec: # SunSpec compatible devices\n    - \"192.168.188.30:502\" # ip address pointing to a modbus TCP endpoint\n    - \"192.168.188.31:502\"\n    - \"192.168.188.32:502\"\n    - \"192.168.188.34:502\"\n  energymeter: \"1901401956\" # energymeter serial number\nplant2:\n  sunspec:\n    - \"192.168.188.35:502\"\n    - \"192.168.188.36:502\"\n  energymeter: \"3006138525\"\n```\n\n### Endpoints\n\n`GET /v1/summary` Returns a summary of the energy flow in one or multiple plants. The unit of each value is **watts**.\n\n```json\n{\n    \"plant1\": {\n        \"grid\": 1.9,\n        \"pv\": 0,\n        \"battery\": 120,\n        \"selfConsumption\": 121.9,\n        \"batterySoC\": 45,\n        \"timestampStart\": 1608579392,\n        \"timestampEnd\": 1608579392\n    },\n    \"plant2\": {\n        \"grid\": 929.2,\n        \"pv\": 0,\n        \"battery\": 0,\n        \"selfConsumption\": 929.2,\n        \"batterySoC\": 14,\n        \"timestampStart\": 1608579392,\n        \"timestampEnd\": 1608579392\n    }\n}\n```\n\n### Docker\n\nA docker image is provided for your convenience. It can be\nfound [here](https://hub.docker.com/repository/docker/orlopau/go-energy-api).\n\n**Example Usage:**\n\n`docker run -v /path/to/plant.yml:/go/src/app/plants.yml -p 8080:8080 orlopau/go-energy-api`\n\n## Links\n\n* SunSpec modbus resources: https://sunspec.org/sunspec-modbus-home/\n* SMA developer documentation: https://www.sma.de/en/products/sma-developer.html\n\n## Licensing\n\nThe code in this project is licensed under MIT License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forlopau%2Fgo-sma-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forlopau%2Fgo-sma-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forlopau%2Fgo-sma-api/lists"}