Collect Inverter data from Solarman API

So as I say…then you create template sensors from the data list for what you want to see in frontend.
One API call and you control the sensors…just ignore what you don’t want…

1 Like

hi Dilligaf I pm you

I’ve emailed what I’ve got. Let me know how you get on!

Damn, i’ve reverse-engineerded half of the kstars registers with the assumption no rs-485 manual could be obtained. That’s a few days of work you just made completely irrelevant.

Hello everyone,

I am facing an issue while trying to query a list of devices using the SolarMAN API. I successfully obtained my access token, but when I try to make a POST call to the URL https://globalapi.solarmanpv.com/account/v1.0/role, I get the following error:

{
“code”: “2101019”,
“msg”: “auth invalid token”,
“success”: false,
“requestId”: “aad2630256fd0a1a”
}

Here are the details of my POST call:

URL: https://globalapi.solarmanpv.com/account/v1.0/role
Method: POST
Authorization Header: Bearer MY_TOKEN_HERE
Content-Type: application/json

I have already checked the following:

  1. The token has not expired.
  2. I am using “Bearer” (with a capital B) in the authorization header.
  3. There are no extra spaces or line breaks in the token.
  4. The Content-Type is set to application/json.

Has anyone faced a similar issue or have any suggestions on how to resolve this? Any help would be greatly appreciated.

Thank you!

you need a “deviceSn”: “SERIALNUMBER” in there at the end

I am making a call to retrieve a list of devices.

Expected Response:
{
“code”: null,
“msg”: null,
“success”: true,
“requestId”: “9300c3b735c6470bb583 a0bf58d4daa5”,
“total”: 27,
“deviceList”: [
{
“deviceSn”: “1800072201”,
“deviceId”: 200197997,
“deviceType”: “COLLECTOR”,
“deviceState”: 3,
“updateTime”: 1582772840
},
{
“deviceSn”: “1800072201-Igen”,
“deviceId”: 200206455,
“deviceType”: “INVERTER”,
“deviceState”: 3,
“updateTime”: 1582772840
}
]
}

How many characters does an access token have? 1084?

Anyone having issues with the API today? Mine stopped working overnight and can’t seem to get to the bottom of it? Reset my key OK, can retrieve settings when running code manually… but HA unable to retrieve… Can’t find an error message to check either.

Mine seems to have 878 characters.

Hmm after all that, did a HA reboot and everything seems to be working now. False alarm sorry :slight_smile:

hmmm…
the same with me
I renewed the key and still the same
yesterday everything was working

The only thing I think I did actually change was from the “old” https://api.solarmanpv.com to the new 'https://globalapi.solarmanpv.com in my script. I recall when they switched over, globalapi worked for a bit for me but then stopped. I then returned to just “api” and it worked. But that was all on the same day. Today even changing to globalapi didn’t fix anything for me until I did a reboot of HA?

I try to get this method working.
I do have an old Omnik convertor. I’m able to acces by solarmansmart.
I did ask for API key and did receive these
I am able to get my acces token of the first step mentioned above
Then I try to get data but get the next error:


I quess that is the SN? because If i enter a wrong authorization code it mentioning wrong authorization code. I did grap the SN from the Solarman site.
image

I also do have a logger SN I tried that as well without succes ( The logger serial number is starting with a 0. In the past I had an error using this code. I removed the 0 and it worked. Now I tried both, without succes)
EDIT 2: I checked my convertor itseld for the right SN. It still gives an error
image

EDIT: I do see that the access token changes everytime I do run the url.
Is that allright? Don’t it need to be constantly the same?

What am I doing wrong?

w
https://reqbin.com/curl wpisz:

curl --request POST \
  --url 'https://api.solarmanpv.com/account/v1.0/token?appId=<appId>&language=en&=' \
  --header 'Content-Type: application/json' \
  --data '{
	"appSecret": "<appSecret>",
	"email": "<email>",
	"password": "<passwordConvertedToSHA256>"
}'

Where:
appSecret – you will receive it by email after unlocking the API
email - to the Solarman account
password – the password for the Solarman account – you need to replace it with SHA256 on the SHA256 Online website:
https://emn178.github.io/online-tools/sha256.html

I did found my fault
I did use for url: --url 'https://globalapi.solarmanpv.com/account/v1.0/token?appId=xxxxxxxxx&language=en&=' \
I need to use: https://globalapi.solarmanpv.com/device/v1.0/currentData?appId=XXXXXXXXX&language=en&=

I now need to try to make my rest sensors

Edit2: I did totally succeed.
Nice. Thanks for this thread!

I just installed this method for collecting data from my Omnik solar system.
It is working fine except the energy dashboard.
There it is showing on 9:00 hr a huge negative value. after that the next hours nothing.


The energy dashboard does need device class and state class. I did add that to the sensor code:
image
The values of the sensor self is oke:
image

how come the energy dashboard shows this figure?
And how to correct?

EDIT:

I think it was a Database item.
After day one it was all fine

Hi, can you send me the pdf too, I’m in your usual situation, thanks

Sure. Send me a private message with your email.

This stuff needs to just work for my purposes. Can’t imagine idea what solarman thinks it’s good enough or how anyone could work with the polava that is their API.

Hello all,

First of all tnx for this guide, took me some time but I’m almost there

When I run the Curl online I’m able to get the values from my logger.

"key": "T_MDU1",
        "value": "40",
        "unit": "℃",
        "name": "Module temperature1"

When I enter the code in my Homeasistant the value stays 'unknown.

### Solarman ###
  - platform: rest
    resource: https://globalapi.solarmanpv.com/device/v1.0/currentData?appId="myapiid"&language=en&=
    method: POST
    name: "Total AC Output Power"
    unique_id: Total_AC_Output_Power
    force_update: true
    scan_interval: 60
    headers:
     Authorization: bearer "Mytoken"
     Content-Type: application/json
    payload: '{  "deviceSn": "myserial"}'
    value_template: "{{ value_json.dataList[14].value | round(0) }}"

The above is stored in the sensor.yaml and the configuration.yamls has an include in it

someone able to see what I"m missing?