Solarman has an API | Sofar Solar

I just found out that the Solarman has build an open API. But pvoutput does not integrate with this API yet. I was checking out if there are more users that want to log their output from solarman to here.

The platforms are:
SOLARMAN Smart:https://home.solarmanpv.com/login build for endusers
SOLARMAN Business:switch home with pro in the link above → build for professionals

I emailed with customerservice@solarmanpv.com for API acces to the old portal and they offered to migrate from the old portal to the ‘new’ solarman smart without dataloss. So that’s great.

edit
they made a thorough manual for the API too. I can share this, but not sure how.

2 Likes

Yes, please! I had my (second, on a different house) PV system installed in November last year with a Sofar Hybrid Inverter which uploads to the Solarman pages by default. Have been trying to get an upload script I found on GitLab to work for ages, but my python is not great and I can’t get past the errors. Got the API key and all from Solarman, but an automatic integration to PVOutput would be amazing!

2 Likes

@beninho & @Aquaholic

Thanks for the API documentation @beninho.

Someone has put together a Python script for uploading Solarman data to PVO

In order to access the Solarman API you will need to contact them ( per the instructions ) in order to obtain your unique Solarman API Key.

Looking at the script you will also need to know the smpv_plant_id of your respective systems. I’d assume that this ID is visible within the web portal that they provide.

Hi @grannos,

Yes, they have send me an APP ID and an APP secret. I think this is the API.

@grannos

I’ve downloaded the script to my homeserver. But am unable to run/start it. I’ve edited the file SolarmanPV-to-PVoutput.py with APP ID and APP secret + API from PVoutput.

But I think I maby must be editing another file.

Hi @beninho

What version of Python are you using? ‘python -V’ should give you the answer.

What error message(s) are you getting?

It appears that the script has a dependency that you may need to install first.

I had to install ‘requests’ before I could run the script without error using Python version 3.

‘pip install requests’ OR ‘pip3 install requests’ depending on your Python version.

Grannos

2 Likes

Hi @grannos i totally missed your reply.

  • Python 3.8.5

I now installed requiests via → python3-pip

When i try to run the script i get the error blow. It seems trivial, i’ll look into it now.

-bash: ./SolarmanPV-to-PVoutput.py: /usr/bin/python: bad interpreter: No such file or directory

/solved this above issue with: sudo apt install python --this installed it again somehow. Bu okay.

New error:

File “./SolarmanPV-to-PVoutput.py”, line 41
smpv_client_secret = XXX
^
SyntaxError: invalid syntax

hmm @grannos

Now i’am not sure anymore.
Which one do i have to edit & run:

  • ./doit-example.sh
  • ./SolarmanPV-to-PVoutput.py

I filled all the data and still get and error on plant id.

./doit-example.sh: line 9: syntax error near unexpected token XXX' ./doit-example.sh: line 9: --smpv_plant_id ’

I’ve taking it from here: https://home.solarman.cn/main.html → that is the old page that is still up and running. I cannot find a plant ID on the new solarman smart UI.

Hi @beninho. Looking at the two scripts the easiest option is to edit ./doit-example.sh and populate it with the identifiers for YOUR system and YOUR account. Within SolarMax_PVoutLiveLog.py line #30 may need to be edited to set the correct IP address for your inverter[s].

I’m unable to access the solar man.cn link without an account.

-=-=-=

#!/bin/bash

Simple script to run the Python code with personal parameters

replace the IDs and keys with yours below

/home/chrismc/src/SOLAR-INVERTER-SOLARMAN/Solarman-PV-to-PVoutput-logger/SolarmanPV-to-PVoutput.py
–smpv_client_id
–smpv_client_secret
–smpv_plant_id
–pvo_key
–pvo_system_id

END OF FILE

Hi @grannos i’ve used all these personal parameters. But, it hangs on the plant id. I found it only in the previous enviroment, not in the ‘new’ smart one. But since they are both the same, it hought i could use it. Gues not, just emailed the solarman people the help my identify it.

and… when i leave it empty → it skips the error but gaves me the same on line 11 pvo_system_id → and i know for sure i’ve got the right parameters set here

I will lookinto the IP adres for my inverter:

Array of inverters in system. IP address and device number
factory default is likely 192.168.1.123:12345 1
inverters = {‘10.0.1.190’: [1, ]}

Device number refers to the amount of inversters/loggers in the system?

Hi @beninho,

Potentially you could have more than one inverter at a single place. From github there’s more information about the parameters required. The first two would identify YOU as a person whereas the the plant_id would identify a specific system. A single account holder could have lots of systems. You must be able to get the plant_id for your system from somewhere as it is the unique identifier for your system.

Good luck…

–smpv_client_id SMPV_CLIENT_ID
SolarmanPV API client ID
–smpv_client_secret SMPV_CLIENT_SECRET
SolarmanPV API client secret
–smpv_plant_id SMPV_PLANT_ID
ID of the plant (i.e. The solar PV site within
SolarmanPV)
–pvo_key PVO_KEY PVoutput API key
–pvo_system_id PVO_SYSTEM_ID
PVoutput system ID

Hi, can you share the API manual for Solarman? Have you done with the successful integration with pvoutput.org?

Can you share the API manual to me via email? Please send it at furqan.ullah@gmail.com

No luck so far. And i only have 1 inverter in this setup. I’am kinda lost now.

I have been trying to get the python script to work myself for sometime. Whilst my credentials to the plant seem to be ok, and connect I don’t get any power data back and in the end have a timedate format error.
I had to set the timezone in the script and made other changes, to no avail.

However, even if I can get this script to work I am not convinced the data would upload to pvoutput because it is such a mess when it comes from the inverter and would fail the pvoutput validation each day.

When I download the inverter data manually via the web site I need to do a lot of manipulation in excel to be able to load the csv values (remove duplicate rows, extract the columns I want to upload)

Issues I found with the inverter data are

  • the timestamp is arbitrary and does not follow the 5, 10, 15, 20 , 25 min… interval
  • lots of duplicated rows for the same timestamp, but to varying degrees each day. These often result in the max row value being exceeded for upload.
  • data from the previous day transferred to the night time records of the next day with the full generation value from the preceding day. Luckily the load validation to Pvoutput now ignores these.
  • lots of rounding down errors in the Energy generation column so it does not increment correctly and fails PVoutput validation.
    etc…

For info my debug output looks like this:
Connection successful
2021-07-16T11:34:58.118000: getPower()
2021-07-16T11:34:58.134000: today == 2021-07-16
2021-07-16T11:34:58.140000: Getting plant power (for a day)
response == <Response [200]>
response.url == https://openapi.solarmanpv.com/v1/plant/power?date=2021-07-16&plant_id=dummy&timezone_id=Europe%2FDublin
response.encoding == utf-8
response.text == {“data”:{“powers”:[{“time”:“2021-07-16T00:00:00Z”,“power”:0},{“time”:“2021-07-16T00:02:47Z”,“power”:0},{“time”:“2021-07-16T00:05:00Z”,“power”:0},{“time”:“2021-07-16T00:07:47Z”,“power”:0},{“time”:“2021-07-16T00:10:00Z”,“power”:0},{“time”:“2021-07-16T00:12:47Z”,“power”:0},{“time”:“2021-07-16T00:15:00Z”,“power”:0}
[cut]
Then the errors:
Traceback (most recent call last):
File “C:\Solarman\SolarmanPV-to-PVoutput_v2.py”, line 117, in
power_details = smpv.getPower(datetime.date.today().strftime("%Y-%m-%d"), True)
File “C:\Solarman\SolarmanPVAPI\solarmanpv_api.py”, line 245, in getPower
power_data.sort(key=self.__extractTimePowerData, reverse=True)
File “C:\Solarman\SolarmanPVAPI\solarmanpv_api.py”, line 181, in __extractTimePowerData
unix_ts = datetime.datetime.strptime(json[‘time’], “%Y-%m-%dT%H:%M:%SZ”).strftime("%s")
ValueError: Invalid format string.

I just load the csv’s manually ever so often now.

hey @Aquaholic that’s not very motivating, should i get it working, it probably does not :sweat_smile:

But how do you export data from the solarman portal? I have yet to find the option.

Hi. Sorry. @beninho
Only just noticed your question.
Under the device tab is an export option just above the bar chart area

Hello, for the first time, I am trying to configure solarmanpv with pvoutput.
I already got my app_id and app_secret from solarmanpv .

But when I try to start the script, with all parameters, I get this error:

SolarmanPVAPI: __connect(): ValueError == Expecting value: line 1 column 1 (char 0)

response == <Response [502]>

An issue with connection to the SolarmanPV API

Hello Leo,

Did you get this script working?

I’m having the same error here.

Hey Guys, I got a little frustrated trying to get these tools to work.

So I wrote a dotnet core version of it with an API layer that you can use if you host it somewhere.
Check out:

It’s fairly simple and straightforward, feel free to fork and modify it to your needs