Skip to main content

A library to interact with Sungrow's iSolarCloud API

Project description

pysolarcloud

A Python package to interact with the iSolarCloud API by Sungrow.

The current version has only very basic functionality:

  • OAuth2 authentication
  • Getting a list plants
  • Getting details of a plant
  • Getting "real-time" data of a plant (Data is updated every 5 minutes according to Sungrow's documentation)

Quirks

The iSolarCloud API is quite new and not very mature. Some tips:

  • The authorisation flow is based on OAuth2 but doesn't work exactly as you would expect
  • The state parameter is not passed back after to the authorisation step. This makes it more tricky to resume the flow in a client application.
  • User is asked to approve the authorisation if the flow is invoked again, e.g. in case the tokens have expired - unlike many OAuth2 implementations who will perform a "silent" authorisation if the user has already approved the access.
  • The API documentation lists a lot of data points which do not seem to be returned from my inverter, it probably varies between models.
  • There are different iSolarCloud servers for different regions, see the pysolarcloud.Server enum
  • API endpoints accept a language code but respond with Chinese text when when English is requested

Usage

Installation

pip install pysolarcloud

Register your app

  1. Create an account in the iSolarCloud Developer Portal
  2. Create an app in the developer portal
    • Answer "Yes" to authorize with OAuth2.0
    • Enter a Redirect URL for your app (this can be changed later)
  3. Wait for approval by Sungrow
  4. Find the needed configuration details in the developer portal. You will need:
    • Appkey
    • Secret Key
    • Application Id (This is shown as a query parameter within the Authorize URL in the developer portal)

Example

from pysolarcloud import Auth, Server
from pysolarcloud.plants import Plants

app_key = "your app key"
secret_key = "your secret key"
app_id = "your app id"
redirect_uri = "your redirect uri"

auth = Auth(Server.Europe, app_key, secret_key, app_id)
url = Auth.auth_url(redirect_uri)
  1. Redirect user to url
  2. User selects plant(s) and grants authorisation
  3. iSolarCloud will redirect the user to redirect_uri with query parameter code
await auth.async_authorize(code, redirect_uri)
plants_api = Plants(auth)
plant_list = await plants_api.async_get_plants()

The Auth class keeps the access between calls and refreshes it when needed. If you prefer to manage this state yourself, you can create your own subclass of AbstractAuth.

Contributions

Ideas or contributions are welcome. I am not afiliated with Sungrow, I'm just another user of the API. My main use case will be a HomeAssistant integration based on this package.

I don't currently have a need for the Grid Control APIs and I might not be able to test them on my own plant[^1] - but let me know if you are interested.

[^1]: because it's controlled by Heartbeat

Enjoy!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysolarcloud-0.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysolarcloud-0.1.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file pysolarcloud-0.1.0.tar.gz.

File metadata

  • Download URL: pysolarcloud-0.1.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for pysolarcloud-0.1.0.tar.gz
Algorithm Hash digest
SHA256 85a749172cfad4109554583a17f79aba19c8cffacffe6a84fcf34d6739aefb83
MD5 741de6b4e1c3493ef7bc67ea6ad0b9e6
BLAKE2b-256 672b2cba138ae53e8c06321d9b05fb138ad98533d08106e68db24be6f62ce92b

See more details on using hashes here.

File details

Details for the file pysolarcloud-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pysolarcloud-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for pysolarcloud-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bebec66cd6fcd00672dbd1333bb131543cce2d915e6d9e5f76e0d5f2fdfad005
MD5 554d82e546c96ffde1c8937e6b5df165
BLAKE2b-256 fb90aef85b6b177f7d4f1c436945f19f6fd65585c929b48146397e7884724701

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page