Collect Inverter data from Solarman API

Hello all, I hope you find this useful, this should work for any Inverter/Logger that reports to Solarman Smart website. I am not very comfortable with REST, API etc so I am sure that some of it could be done better but hopefully this will help someone.

1 -
Email [email protected] and ask for API access. You will receive documentation and an ID and Key.

2 -
Go to Run Curl Commands Online
Paste the below into the left window, make sure you amend the relevant sections.

appSecret is your key.

You can hash your password by visiting SHA256 Online. I’ve had issues with other websites but this one works consistently for me

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>"
}'

image

3 -
You will see this in the box on the right

image
Grab your access_token for the next step

4 -
Check to make sure you can see data from your inverter. Paste this into the box on the left, replacing values as appropriate.

curl --request POST \
  --url 'https://api.solarmanpv.com/device/v1.0/currentData?appId=<appId>&language=en&=' \
  --header 'Authorization: bearer <accessToken>' \
  --header 'Content-Type: application/json' \
  --data '{
	"deviceSn": "<deviceSerial>"
}'

You should get the following result (truncated for here)

5 -
Copy everything and paste it into https://jsonpathfinder.com/

6 -
Create a rest sensor in configuration.yaml. I have split my config up so your configuration.yaml file may look slightly different to mine. Make sure you replace the relevant sections with your details

### Solarman API ###
 - platform: rest
   resource: https://api.solarmanpv.com/device/v1.0/currentData?appId=<APPID>&language=en&=
   method: POST
   name: "Cumulative Production kWh"
   scan_interval: 3600
   headers:
    Authorization: bearer <AUTH>
    Content-Type: application/json
   payload: '{  "deviceSn": "<SN>"}'
   value_template: "{{ value_json.dataList[16].value }}"

To get the correct sensor reading, use the JSON Path Finder website to get the appropriate value_json. In my example I’m looking at Cumulative Production (Active)

7 -
Save your file, check the config and restart. You should then see your sensor in Home Assistant

image

TODO - Try to understand the difference between auth and refresh token and when to use each one

I will try and answer any questions you have but as I said, I am not very knowledgable.

8 Likes

Hi Skully,

Thanks for making this extensive guide. Without this I would never have managed to connect my inverter to Home Assistant, so your knowledge is not so bad at all. I can now read my Omnik inverters linked to Solarman. Keep up the good work :+1:

2 Likes

This works great! Thank you very much.

I want to mention that you have to declare “sensor:” in your config.yaml in order to get it working.

sensor:

  • platform …
    …
    …
2 Likes

Thanks, I think I left it out as I have split my config up. I’ll edit the OP :slight_smile:

Thank you for this. I use Trannergy inverter and they have switched to a Solarman system, and do not support forwarding to PVOutput.

I got the sensor Daily Production (Active) with data. I do want to add this sensor to the energy panel as Solar Production. Any ideas why the sensor is not listed there?

You will need to take a look at the energy blog but basically it isn’t yet supported.

You can fiddle it by adding in some lines but exactly which ones escape me right now. It may be worth waiting until the new version is released later today as I know they’re adding support for more sensors.

Maybe not for this topic, but the solution is to define a sensor for your sensor using template. In this you define that it is about a measurement. I got it working like this:

template:
  - sensor:
      - name: "Solarman  Cumalative Production"
        unit_of_measurement: "kWh"
        state: >
          {{ (states("sensor.cumulative_production_kwh") | float) | round(2) }}
        device_class: energy
        state_class: measurement
        attributes:
          last_reset: "1970-01-01T00:00:00+00:00"

@Skully thank you for your Integration! Works like a charm!

I noticed that the data from the API is delayed by about 15 minutes. Is this the same for you guys?

Is there a way to correct the timestamps? e.g. with a template?

Hi,

Yes it’s the same for me, I believe that’s how often it’s sent to the Solarman servers.

Maybe it is helpful for someone. Works quite well so far:

1 Like

hello @lechk82
I have some doubts about filling out the config.sample.json file

{
“name”: “Trannergy”,
“url”: “api.solarmanpv.com”,
“appid”: “ok I have this”,
“secret”: “ok I have this”,
“username”: “would be the access email to the api?”,
“passhash”: “ok I have this”,
“stationId”: how can I found this one?,
“inverterId”: how can I found this one?,
“loggerId”: how can I found this one?,
“debug” : false,
“mqtt”:{
“broker”: “ok I have this”,
“port”: 1883,
“topic”: “solarmanpv”,
“username”: “ok I have this”,
“password”: “ok I have this”
}
}

Can you help me on it ?

Sure,
just go to https://home.solarmanpv.com and create an account and pair it with your inverter hardware (similar to what you probably already did with the smartphone app)
Use the credentials of your just created account for the api access (email, password) The password must be hashed using e.g. SHA256 Online as already mentioned above.

Then you can See S/N of logger and inverter if you chose devices on left menu panel:

The next step is to create a “Display” using “Function” from the top menu:

Enter your “Display” using the play button. Now you can see the plant id (station id) in the address bar of your webbrowser:

Note that StationID and Logger/Inverter S/N in config.json are not considered as strings but as numbers which should not be quoted.

1 Like

Thanks a lot. loggerId I found, on inverterId for me appears leters and numbers, but on de script dont accept letters just numbers, any Idea to solve this?

ok, that’s new. have you tried to quote the device ids in config.json?

I quoted. Now it seems to be working. Thanks you for your support

1 Like

I’m trying to get this working, maybe use lechk82’s project later.

My problem is getting the access token, I always get this error:

{
    "code": "2101025",
    "msg": "{\"error\":\"invalid_request\",\"error_description\":\"\",\"code\":\"AUTH_INVALID_USERNAME_OR_PASSWORD\",\"param\":null}",
    "success": false,
    "requestId": "b8592b6c5647cbe4",
    "access_token": null,
    "token_type": null,
    "refresh_token": null,
    "expires_in": null,
    "scope": null,
    "uid": null
}

curl command in op with:
ID from the customer support email as <appId>
KEY from the same email as <appSecret>
my email address used for the solaman account and for the api as <email>
my solarman account password run through SHA256 Online as <passwordConvertedToSHA256>

Any help?

Can you try a different SHA256 generator? See if the results are the same? That’s what helped me narrow down my errors.

I’ve tried multiple (as in 10+) SHA256 tools online, all produce the exact same hash. Maybe my password is the problem, 64 char, lower case letters, upper case letters, numbers, special characters.

Just changed the password, now 16 chars. Now it works…was able to lo into the app/website just fine, api doesn’t like long passwords.

Thanks for your help.

1 Like

I have pasted the data into configuration.yaml but I have an error:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:

  • platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
#frontend:
# themes: !include themes.yaml
### Solarman API ###

  • platform: rest
    resource: https://api.solarmanpv.com/device/v1.0/currentData?appId=xxxxx&language=en&=
    method: POST
    name: “Cumulative Production kWh”
    scan_interval: 3600
    headers:
    Authorization: bearer xxxxxxx
    Content-Type: application/json
    payload: ‘{ “deviceSn”: “SF4xxxx”}’
    value_template: “{{ value_json.dataList[16].value }}”

----error:
Error loading /config/configuration.yaml: while parsing a block mapping
in “/config/configuration.yaml”, line 3, column 1
expected , but found ‘’
in “/config/configuration.yaml”, line 16, column 2