Connecting Goodwe Solar Panel Inverter to Openhab

Hey Rudi,
I’ve got the same problem, did you find a solution?

Hi Toine,

I think I found the problem. For some reason adding code to this forum messed up the quotation marks in the shell script. I edited the original post to correct this.

You can also try the following command on shell level and should get a response now. Remember adding your account and password.

curl https://www.semsportal.com/api/v2/Common/CrossLogin --silent --header "Content-Type: application/json" --header "Connect: keep-alive" --header "User-Agent: PVMaster/2.1.0 (iPhone; iOS 13.0; Scale/2.00)" --header "Accept-Language: en;q=1" --header "Token: {\"version\":\"v2.1.0\",\"client\":\"ios\",\"language\":\"en\"}" --data-binary "{\"account\":\"secondopenhabuser@gmail.com\",\"pwd\":\"yourpassword\"}"

RogerG

Hey Roger,

Got this output

“hasError”: false,
“code”: 0,
“msg”: “Success”,
“data”: {
“agreement_agreement”: true
},
“components”: {
“para”: null,
“langVer”: 87,
“timeSpan”: 0,
“api”: “http://eu.semsportal.com:82/api/Auth/GetTokenV2”,
“msgSocketAdr”: “https://eu-xxzx.semsportal.com
},
“api”: “https://eu.semsportal.com/api/

Thanks in advance for your reply.

Hey Roger
For testing I ran this script (with my credentials) in bash.

’ RESULT=$(curl https://www.semsportal.com/api/v2/Common/CrossLogin --silent --header “Content-Type: application/json” --header “Connect: keep-alive” --header “User-Agent: PVMaster/2.1.0 (iPhone; iOS 13.0; Scale/2.00)” --header “Accept-Language: en;q=1” --header “Token: {“version”:“v2.1.0”,“client”:“ios”,“language”:“en”}” --data-binary “{“account":"me@gmail.com”,“pwd”:“passwrd”}”)

HEADER=$(echo “$RESULT”|jq “.data”|tr ‘\n’ ’ ')

echo $HEADER

RETURN=$(curl https://www.semsportal.com/api/v2/PowerStation/GetMonitorDetailByPowerstationId --silent --header “Content-Type: application/json” --header “Accept: /” --header “User-Agent: PVMaster/2.1.0 (iPhone; iOS 13.0; Scale/2.00)” --header “Accept-Language: en;q=1” --header 'Token: '"$HEADER" --data-binary “{“powerStationId”:“myID”}”)

echo “$RETURN” | jq “.data” ’

And got this output:

{ “agreement_agreement”: true }
parse error: Invalid numeric literal at line 1, column 7

1st line is output for “echo $HEADER”, so far so good.
There must be a typo in the second part of the script I guess!

Hi Toine,

I can’t find any differences in my running script and the one I’ve uploaded here.

Your test script seems not to respond with the correct HEADER. It should return something like this:

{ "uid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "timestamp": 1606820035659, "token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "client": "ios", "version": "v2.1.0", "language": "en" }

This is needed for authentication in the second curl command.

RogerG

Hi Toine,

I’ve updated my script with variables for username, password and power station. This is the only difference between my working script and the one above. Could you give this a try:

#!/bin/bash

USERNAME="me@mail.com"
PASSWORD=“MYPASSWORD”
POWERSTATION=“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”

RESULT=$(curl https://www.semsportal.com/api/v2/Common/CrossLogin --silent --header “Content-Type: application/json” --header “Connect: keep-alive” --header “User-Agent: PVMaster/2.1.0 (iPhone; iOS 13.0; Scale/2.00)” --header “Accept-Language: en;q=1” --header “Token: {"version":"v2.1.0","client":"ios","language":"en"}” --data-binary “{"account":"$USERNAME","pwd":"$PASSWORD"}”)

HEADER=$(echo “$RESULT”|jq “.data”|tr ‘\n’ ’ ')

RETURN=$(curl https://www.semsportal.com/api/v2/PowerStation/GetMonitorDetailByPowerstationId --silent --header “Content-Type: application/json” --header “Accept: /” --header “User-Agent: PVMaster/2.1.0 (iPhone; iOS 13.0; Scale/2.00)” --header “Accept-Language: DE;q=1” --header 'Token: '“$HEADER” --data-binary “{"powerStationId":"$POWERSTATION"}”)

echo “$RETURN” | jq “.data”

I’ve also added my shell-script as a file. You need to rename it of course to semsapi.sh and make it executable.

semsapi.txt (950 Bytes)

Hope this helps.

RogerG

Hey Roger,
If I run your shell script with my credentials I get this result: 请求参数:
Putting this result in an internet translation machine learns me it means: “aanvraagparameters: [nl]”
Dutch parameters, which is good, but after the “:” no parameters!!
I’ll give it a rest for now. Maybe this weekend I’ll give it another try!
Thanks.

Maybe you need to change the “Accept-Language: DE” in my script to “Accept-Language: NL”. Just a quick idea coming to mind.

RogerG

Hey Roger,

The script works fine! Turned out that you have to log in Sems Portal with the new created user to initiate him. I made the 2e user for the script but didn’t use him in the Portal.
Learning all the time! (-;
I’m going to implement it in OpenHAB now.
Thanks for your time and help!

Toine.

1 Like

Hello all, is this tread still alive?
I’ve get tis error.
2020-12-28 12:59:55.789 [WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert '{

Somebody know’s what’s wrong?

Thanks,
Harold.

Hello Roger, how do you create a new user in Sems Portal?
Can you help me?

Cheers,
Harold

Hi Harold,
You can make a new user in Sems Portal. Select the tab “Management”, select your device and ad a visitor.
Dit you ad your script to the Whitelist?

Succes,
Toine

Hello Toine,
What do you mean with whitelist?

Just add a visitor, but now i’ve got the error
2020-12-28 20:57:19.568 [WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert '{

“hasError”: false,

“code”: 0,

“msg”: “Success”,

“data”: {

"agreement_agreement": true

},

“components”: {

"para": null,

"langVer": 91,

"timeSpan": 0,

"api": "http://eu.semsportal.com:82/api/Auth/GetTokenV2",

"msgSocketAdr": "https://eu-xxzx.semsportal.com"

},

“api”: “https://eu.semsportal.com/api/

}’ to a state type which item ‘UG_PV_SoC’ accepts: [DecimalType, QuantityType, UnDefType].

Helaas,
Harold.

Hi Harold,
You seem to have a similar problem as Toine previously. You need to login to the semsportal with the newly created account at least once for it to work. Let me know if this helped.
Best Regards
RogerG

Oke logged in and i had to confirm it.
Now i don’t see anything in the log. Maybe that’s a good signs???

Edit: made a new semsapi.sh with the right email-passwd and numbers.
Now i get
Cannot convert '/etc/openhab2/scripts/semsapi.sh: line 5: jq: command not found
in the log.

And how to put it in the sitemap?
Something like?, Text item=Energy UG_PV_Total_Output

Actually, you should see the portal responses in the log …
If you add

    Text item=UG_PV_Todays_Output
    Text item=UG_PV_Output_Power
    Text item=UG_PV_Grid
    Text item=UG_PV_Loadstatus
    Text item=UG_PV_Home_Load
    Text item=UG_PV_SoC
    Text item=UG_PV_Battery
    Text item=UG_PV_Batterystatus

to the sitemap, we can maybe find out more. openhab should get new values every minute from the portal.

Did that in the sitemap, but then i’ve got a error.
Maybe because there is still something wrong.
See one reply up.

When i use the samsapi.sh of topic starter then i get,

2020-12-29 12:21:15.660 [WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert '{

“hasError”: false,

“code”: 0,

“msg”: “Success”,

“data”: {

"uid": "                 ",

"timestamp": 1609240875653,

"token": "      ",

"client": "ios",

"version": "v2.1.0",

"language": "en"

},

“components”: {

"para": null,

"langVer": 91,

"timeSpan": 0,

"api": "http://eu.semsportal.com:82/api/Auth/GetTokenV2",

"msgSocketAdr": "https://eu-xxzx.semsportal.com"

},

“api”: “https://eu.semsportal.com/api/

}’ to a state type which item ‘UG_PV_SoC’ accepts: [DecimalType, QuantityType, UnDefType].

There is still something wrong. I copied all of topic starter.

Looks like you don’t have jq installed (this is a simple JSON parser). I thought it was a default package with all Linux distributions. On what platform are you running openhab?. If it is raspbian/openhabian, ubuntu or Debian you should be able to install jq with

sudo apt-get update
sudo apt-get install jq

Can you also try just running the shell script on command line and see what it returns there?

raspbian, try sudo apt-get install jq

Edit: Nope, no joy.