PythonScript files to access Sungrow’s iSolarCloud Open API
MickMake (https://github.com/MickMake) has a wonderful app named GoSungrow (https://github.com/MickMake/GoSungrow) that creates MQTT sensors in HA for ALL the data points available. It uses a generic AppKey and the user’s login information. I have it installed and working without any problems.
MickMake explicitly says that using the standard API is not the best, but it works, and it’s fun to program and debug by yourself. Please be sure to access his repository to see why he finally opted for his solution.
While setting up MickMake’s app I had some problems with the appkey. So I accesed the ‘Applications’ menu option from ISolarCloud and was asked to create an app to obtain the appkey. In a couple of days I got my appkey, which didn’t work with GoSungrow, and started looking at the API requirements. So, when I finally got GoSungrow working I decided to continue studying this other solution.
It is a DIY way of reading data from a Sungrow installation. You can choose what and when to read it
These files implement the minimum ISolarCloud API calls needed to integrate the data into Home-Assistant.
First you login into ISolarCloud’s developer portal
In the developer portal you will see a link to the documentation, we will use it later. Click on the link to applications
You must give some information about why you need access to the api. In my case I just said I wanted access from Home Assistant, WITHOUT access with OAuth2.0. In a couple of days I entered the screen and the app was approved.
You can go to the Documentation section and then use the following calls (for each call there is a ‘try it’ button). Be sure to select V1 (no OAuth2.0):
[
Start with the login call:
and you will get a token.
Then repeat with different calls: the Plant List Information Query, then Query Device List and Query Basic Plan Info. Finally you will find the ps_key
pyscript: !include pyscript/config.yaml
allow_all_imports: true
hass_is_global: true
apps:
Sungrow_RSA:
appkey: !secret sungrow_appkey
sung_secret: !secret sungrow_secret
username: !secret sungrow_user
password: !secret sungrow_password
RSA_public: !secret sungrow_rsa_public
Home Assistant will update all Sensors on startup. In case the token is not valid it will renew it.
Right now it works well enoough for me, and I want to test it before adding additional stuff: