Python Plugin: GoodWe solar inverter via SEMS API

Python and python framework

Moderator: leecollings

Alfagek
Posts: 26
Joined: Sunday 09 February 2020 15:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Leeuwarden
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by Alfagek »

Hello JanJaap,

First: Thanks for maintaining the plugin! 8-)

It’s running for a month here now. But in that month I did notice some difference between the data from Sems portal (app) and the data in Domoticz.
For example: today I have in Sems Portal 6 times a reading above 2900 watt. But in Domoticz i only see one back.
I do have auto refresh on 30sec. Did also try 10sec. But that didn’t make a difference.
If I’m right the converter updates to the portal every minute.

I’ll hope you can explain this difference.
Thanks in advanced :D
lbuijk
Posts: 4
Joined: Friday 14 July 2017 22:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by lbuijk »

Plugin is working. Thanks a lot.

Is there a way to login directly to the inverter and get the data? I have a Delta inverter which can get the data even without internet connection (handy if the website / portal is down)
JanJaap
Posts: 191
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by JanJaap »

Hi guys,

To answer both questions in 1 reply:
- the GoodWE API has the tendency to sometimes 'hang' with respect to the actual generated power (it's a known problem reported elsewhere in this or other topics). The produced energy amount which is of course the accumulated power, is always correct. In the GoodWE app the power is updated over time (backwards) but Domoticz doesn't allow this. Summarizing, the accumulated energy is always correct, the power graph not. Can't fix that unfortunately;
- I've taken the plugin from Dylian, we worked from the GW4200D-NS type inverter. These cannot be accessed directly (there is a way to do this via the RS485 port if I remember correctly, you can find some links elsewhere in this topic). So this for me is no option. And to develop a direct access plugin without being able to test it is pretty difficult so I can't do it for you (can provide some advice though), presuming you have info about the API of the inverter.

Hope this helps. Should you have any feature request for this plugin, let me know.
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
Nodri
Posts: 16
Joined: Saturday 03 November 2018 21:29
Target OS: -
Domoticz version:
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by Nodri »

Hi guys, i'm back :)

So it seemed my SD card crashed so i had to install a new one and re-install raspbian and domoticz.

Than i added the GoodWe via SEMS portal in the hardware tab and i get data, however i don't get Watts etc.

I than added the dylian github script and later the janjaap script but everythin i do i don't get the watt tile or data coming in.

I've done all the things what's written in this thread, how do i make a debug log??
Nodri
Posts: 16
Joined: Saturday 03 November 2018 21:29
Target OS: -
Domoticz version:
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by Nodri »

Yes!

I got the plugin, now to get it too work.
I needed to install the latest version of Python. After some googling founf out how to get the correct version and presto! the goodwe via sems web api thingy came in the dropdown menu.

Now i filled all the information in and i get this message: 2020-07-23 22:24:34.446 Error: (Zonnepanelen) GoodWe SEMS API returned a Server Error.

I checked to see if i have the correct version installed of the plugin and it says this:

pi@domoticz:~/domoticz/plugins/domoticz-GoodWeSEMS $ git pull https://github.com/janjaapko/domoticz-GoodWeSEMS
From https://github.com/janjaapko/domoticz-GoodWeSEMS
* branch HEAD -> FETCH_HEAD
Already up to date.
pi@domoticz:~/domoticz/plugins/domoticz-GoodWeSEMS $ git status
On branch master
Your branch is ahead of 'origin/master' by 24 commits.
(use "git push" to publish your local commits)

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: __pycache__/GoodWe.cpython-37.pyc
modified: __pycache__/plugin.cpython-37.pyc

no changes added to commit (use "git add" and/or "git commit -a")
Alfagek
Posts: 26
Joined: Sunday 09 February 2020 15:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Leeuwarden
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by Alfagek »

JanJaap wrote: Thursday 09 July 2020 20:54 Hi guys,

To answer both questions in 1 reply:
Hope this helps. Should you have any feature request for this plugin, let me know.
Sorry @JanJaap, i thought i did give a reaction on this.
But its explaint clearly.

But a other question,
i do get this in my error log. Someone knows, whats the reason is why i get it, and how can i fix this.

Thanks in advanced.

Code: Select all

 2020-09-02 14:13:46.155 Error: (Zonnepanelen): Async Secure Read Exception: 9, Bad file descriptor
2020-09-02 14:13:46.208 Error: (Zonnepanelen) 'onMessage' failed 'JSONDecodeError'.
2020-09-02 14:13:46.208 Error: (Zonnepanelen) ----> Line 345 in '/home/pi/domoticz/plugins/domoticz-GoodWeSEMS/plugin.py', function onMessage
2020-09-02 14:13:46.208 Error: (Zonnepanelen) ----> Line 153 in '/home/pi/domoticz/plugins/domoticz-GoodWeSEMS/plugin.py', function onMessage
2020-09-02 14:13:46.208 Error: (Zonnepanelen) ----> Line 348 in '/usr/lib/python3.7/json/__init__.py', function loads
2020-09-02 14:13:46.208 Error: (Zonnepanelen) ----> Line 337 in '/usr/lib/python3.7/json/decoder.py', function decode
2020-09-02 14:13:46.208 Error: (Zonnepanelen) ----> Line 355 in '/usr/lib/python3.7/json/decoder.py', function raw_decode 
And this error I see now and then

Code: Select all

 2020-09-03 16:15:49.325 Error: (Zonnepanelen): Async Secure Read Exception: 104, Connection reset by peer   
JanJaap
Posts: 191
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by JanJaap »

Hi,

The 'bad file descriptor' error comes from trying to do something to a file without the right access to it. It happens once in a while, I think it comes from the GoodWE API not returning the correct data or somewhere the software tries to store it where something goes wrong. I need to dive into that a bit more. At least catch the exception a bit more elegant. I'll let you know when I found something.
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
Alfagek
Posts: 26
Joined: Sunday 09 February 2020 15:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Leeuwarden
Contact:

Python Plugin: GoodWe solar inverter via SEMS API

Post by Alfagek »

JanJaap wrote:I'll let you know when I found something.
Thanks JanJaap, will wait when you find it. If I need to try something, you have to say it.
JanJaap
Posts: 191
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by JanJaap »

Just pushed a commit to handle the JSON error more elegantly. It should reduce it to only one error line (which is more then enough :) )
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
Alfagek
Posts: 26
Joined: Sunday 09 February 2020 15:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Leeuwarden
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by Alfagek »

JanJaap wrote: Saturday 05 September 2020 19:58 Just pushed a commit to handle the JSON error more elegantly. It should reduce it to only one error line (which is more then enough :) )
Works, now indeed one line json 104 error

Edit 18:54: did reacting to quickly.
Did update plugin yesterday with python plugin manager

Code: Select all

 2020-09-07 18:24:58.165 Error: (Zonnepanelen): Async Secure Read Exception: 104, Connection reset by peer
2020-09-07 18:24:58.174 Error: (Zonnepanelen) 'onMessage' failed 'NameError'.
2020-09-07 18:24:58.174 Error: (Zonnepanelen) ----> Line 353 in '/home/pi/domoticz/plugins/domoticz-GoodWeSEMS/plugin.py', function onMessage
2020-09-07 18:24:58.174 Error: (Zonnepanelen) ----> Line 159 in '/home/pi/domoticz/plugins/domoticz-GoodWeSEMS/plugin.py', function onMessage
2020-09-07 18:41:13.148 Error: (Zonnepanelen): Async Secure Read Exception: 9, Bad file descriptor
2020-09-07 18:41:13.203 Error: (Zonnepanelen) 'onMessage' failed 'NameError'.
2020-09-07 18:41:13.203 Error: (Zonnepanelen) ----> Line 353 in '/home/pi/domoticz/plugins/domoticz-GoodWeSEMS/plugin.py', function onMessage
2020-09-07 18:41:13.203 Error: (Zonnepanelen) ----> Line 159 in '/home/pi/domoticz/plugins/domoticz-GoodWeSEMS/plugin.py', function onMessage
JanJaap
Posts: 191
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by JanJaap »

Well at least that was 2 error lines less :lol:

Should be fixed now
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
Alfagek
Posts: 26
Joined: Sunday 09 February 2020 15:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Leeuwarden
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by Alfagek »

JanJaap wrote: Tuesday 08 September 2020 19:28 Well at least that was 2 error lines less :lol:
:lol: True JanJaap.
That error I didn’t see anymore in multi lines.

But now I have the next error. Don’t know if it’s important

Code: Select all

 2020-09-23 15:45:51.848 Error: (Zonnepanelen) 'onMessage' failed 'KeyError'.
2020-09-23 15:45:51.848 Error: (Zonnepanelen) ----> Line 353 in '/home/pi/domoticz/plugins/domoticz-GoodWeSEMS/plugin.py', function onMessage
2020-09-23 15:45:51.848 Error: (Zonnepanelen) ----> Line 163 in '/home/pi/domoticz/plugins/domoticz-GoodWeSEMS/plugin.py', function onMessage  
JanJaap
Posts: 191
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by JanJaap »

Hi,

Without the message itself it's pretty difficult to see what is wrong. Sometimes the JSON format of the API return is a bit misshaped. Can't help that much. I presume that this only happens rarely? If not, when switching on debug logging, you can see the faulty message.
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
MeAlbert
Posts: 65
Joined: Friday 06 December 2019 14:23
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by MeAlbert »

JanJaap
I have the following error message quite often. It looks that the GoodWe plugin is stuck for more than 10 seconds before it starts again. After a while my Pi stops and a restart helps to get it going again.

Code: Select all

 2020-10-30 13:09:44.822 Error: EventSystem: Warning!, lua script /home/pi/domoticz/dzVents/runtime/dzVents.lua has been running for more than 10 seconds
2020-10-30 13:09:56.050 Error: BasePush: Could not determine data push value
2020-10-30 13:09:56.056 Error: BasePush: Could not determine data push value
2020-10-30 13:09:56.057 Error: BasePush: Could not determine data push value
2020-10-30 13:09:56.059 Error: BasePush: Could not determine data push value
2020-10-30 13:10:00.661 Error: InfluxLink: Error sending data to InfluxDB server! (check address/port/database/username/password)
2020-10-30 13:10:06.458 Error: EventSystem: Warning!, lua script /home/pi/domoticz/dzVents/runtime/dzVents.lua has been running for more than 10 seconds
2020-10-30 13:10:18.205 Error: EventSystem: Warning!, lua script /home/pi/domoticz/dzVents/runtime/dzVents.lua has been running for more than 10 seconds
2020-10-30 13:11:01.508 Error: EventSystem: Warning!, lua script /home/pi/domoticz/dzVents/runtime/dzVents.lua has been running for more than 10 seconds
2020-10-30 13:11:31.738 Error: InfluxLink: Error sending data to InfluxDB server! (check address/port/database/username/password)
2020-10-30 13:11:34.232 Error: EventSystem: Warning!, lua script /home/pi/domoticz/dzVents/runtime/dzVents.lua has been running for more than 10 seconds
2020-10-30 13:11:53.827 Error: GoodWE Garage hardware (11) thread seems to have ended unexpectedly
2020-10-30 13:11:56.878 Error: EventSystem: Warning!, lua script /home/pi/domoticz/dzVents/runtime/dzVents.lua has been running for more than 10 seconds
2020-10-30 13:12:09.779 Error: EventSystem: Warning!, lua script /home/pi/domoticz/dzVents/runtime/dzVents.lua has been running for more than 10 seconds
2020-10-30 13:12:30.830 Error: EventSystem: Warning!, lua script /home/pi/domoticz/dzVents/runtime/dzVents.lua has been running for more than 10 seconds
2020-10-30 13:13:03.100 Error: InfluxLink: Error sending data to InfluxDB server! (check address/port/database/username/password)
2020-10-30 13:13:14.052 Error: BasePush: Could not determine data push value
2020-10-30 13:13:14.063 Error: BasePush: Could not determine data push value
2020-10-30 13:13:14.111 Error: BasePush: Could not determine data push value
2020-
Is it caused by GoodWe and if so what to do about it. Could it be a data push problem? I use grafana so need to push data to influx.
whoami
Posts: 73
Joined: Tuesday 31 March 2020 22:31
Target OS: -
Domoticz version:
Location: Dutch
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by whoami »

JanJaap wrote: Friday 04 September 2020 8:24 Hi,

The 'bad file descriptor' error comes from trying to do something to a file without the right access to it. It happens once in a while, I think it comes from the GoodWE API not returning the correct data or somewhere the software tries to store it where something goes wrong. I need to dive into that a bit more. At least catch the exception a bit more elegant. I'll let you know when I found something.
JanJaap, plugin works perfect! Now I'm trying to get also the amount earned in euro's in domoticz, so I adjusted some script (https://ehoco.nl/stroom-gas-en-waterkos ... -domoticz/) and used the device of my solar panels also with the 'CounterToday'.
Because when I make a json output I see that CounterToday is the same as in de script. This works and I see every day the euro's earned in my dummy domoticz device.

Now I wanted to adjust the script to also show a dummy device that contains the total amount earned in euro's so I used the 'Data' subdevice, because my json gives:
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CounterToday" : "0.000 kWh",
"CustomImage" : 0,
"Data" : "17.400 kWh",
"Description" : "",
"EnergyMeterMode" : "0",
"Favorite" : 0,
"HardwareID" : 10,
"HardwareName" : "GoodWe Zonnepanelen",
"HardwareType" : "GoodWe solar inverter via SEMS API",
"HardwareTypeVal" : 94,
"HaveTimeout" : false,
"ID" : "000A0004",
"LastUpdate" : "2021-01-11 10:41:42",
"Name" : "Zonnepanelen",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" :
Now I get an error, for CounterToday it works for the Data field I get the error:

2021-01-11 11:00:00.293 Error: dzVents: Error: (3.0.15) An error occurred when calling event handler Script #1
2021-01-11 11:00:00.293 Error: dzVents: Error: (3.0.15) ...ticz/var/scripts/dzVents/generated_scripts/Script #1.lua:21: attempt to perform arithmetic on a nil value (local 'vandaagKwh')

Can you see the issue?
JanJaap
Posts: 191
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by JanJaap »

Not sure as to why you want to do this, since Domoticz offers this out of the box (although not on hourly level but for me I only want to know the total score):
Solar panel earnings.png
Solar panel earnings.png (149.78 KiB) Viewed 2111 times
It is under log -> report of the power widget of the solar panel

The for your question; the error says that the local variable 'vandaagKwh' has no data assigned. This is no issue of the plugin but your script (you mention you changed the one from ehoco so it is not possible for me to see what is going on). I propose to post it in the forum of the ehoco page?

As a hint to debug: try printing the contents of the variables to logging of Domoticz, LUA should have features for that and see where you loose the data.
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
jgaalen
Posts: 15
Joined: Monday 11 February 2019 9:05
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by jgaalen »

For what it's worth, I've changed to url in the inverter from www.goodwe-power.com to my local webserver. Created 2 php scripts for /Datalog and /GetSendinterval and now I'm getting updates every 10/11 seconds.
The php script is pushing the data to influxdb and domoticz. No need for a very flacky and slow SEMS portal
Falcon8
Posts: 2
Joined: Monday 05 September 2016 0:52
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by Falcon8 »

Hello JanJaap,

i am using the script now for one week and have a issue with the data beeing swapped between the 2 inverters.
I am using two Goodwe inverters (1x East and 1x West) GW-2000XS.
When adding the 2 inverters you can see in the device list 2 different serial numbers so that's looking great. however after adding them to domoticz it could happen that the next day after startup the values are swapped between them. it happend now 3 times for me.
Any clou on how I could fix it?
The thing I already tried was making two different power plants and then add those to Domoticz, but I will then get only values from one power plant and nothing from the other?
For now I also run a LUA script directly in Domoticz to get the totals from the power plant , but it would be nice if your script could work with 2 inverters so I can see them separately without swapping.

thx in advance and love the work you all are putting in this!
whoami
Posts: 73
Joined: Tuesday 31 March 2020 22:31
Target OS: -
Domoticz version:
Location: Dutch
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by whoami »

2021-01-26 13:38:03.843 Error: Plugin: Connection Exception: 'resolve: Host not found (non-authoritative), try again later' connecting to 'eu.semsportal.com:443'

I keep getting this error since this morning, any ideas?

when I do a traceroute to eu.semsportal.com I eventually end with ip: 8.209.71.108
Can I use this one and where to adjust it?
JanJaap
Posts: 191
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python Plugin: GoodWe solar inverter via SEMS API

Post by JanJaap »

Hi Whoami, no, I don't see the same errors (am connected to EU server as well).

Hi Falcon8. That is an interesting situation, please switch to verbose logging and show me the loglines so I can see what the response from the webserver looks like, so I can improve handling multiple power stations. Since I've got only 1, did not exactly know what it would look like. Preferably, create an issue in the Goodwe github.
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest