Page 1 of 3
GoodWe Solar PV Generation Capture
Posted: Monday 01 June 2015 11:47
by mikegrimwade
Just thought I'd share my first Lua script to pull solar PV generation data from the GoodWe web portal.
More detail can be seen on my blog...
http://persistantillusion.blogspot.co.u ... -from.html
-- Script to pull GoodWe power generation data into Domoticz
-- Written by M Grimwade 2015
-- Function to update a Domoticz sensor object
function update(device, id, power, energy)
commandArray[1] = {['UpdateDevice'] = id .. "|0|" .. energy}
return
end
-- Command array to populate with Domoticz instructions
commandArray = {}
-- The switch ID of my device in Domoticz
switchIdx = 50
-- Load the JSON Lua module
JSON = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
-- Reference the HTTP module enabling web calls
http = require 'socket.http'
-- Perform an HTTP request to get the raw string from the REST endpoint
html = http.request '
http://www.goodwe-power.com/Mobile/GetM ... =mGrimwade'
-- Decode the JSON formatted string to a Lua table
local t = JSON:decode(html)
-- Pull out the sub table containing the data from the main table
local t2 = t[1]
-- Get the currentPower value from the sub table into a string
local currentPowerStr = t2.currentPower
-- Check the length of that string
local currentPowerLen = string.len(currentPowerStr)
-- Trim off the Kwh from the string and cast it to an integer
local currentPowerKwVal = tonumber(string.sub(currentPowerStr,1,currentPowerLen-2))
-- Multiply the Kwh value to get the wh value
local currentPowerWVal = currentPowerKwVal * 1000
-- Call the update function to add the data to Domoticz
update("Usage", switchIdx, currentPowerWVal, currentPowerWVal)
return commandArray
Re: GoodWe Solar PV Generation Capture
Posted: Monday 28 September 2015 19:37
by free_nsc
Mike
Nice work. I already commented on your blog - your post helped greatly.
There are other figures that I'd be interested to be able to read but they are not published via their JSON see e.g. the Voltage, Current or even Temperature inverter is operating at. These numbers are sent to the GoodWe portal so there might be another way of reading them (website scrape) but this is still not ideal.
I initially thought I'd be able to use the WiFi connection for this but there are no ports that it listen to anything other than port 80. I've also reach out to the GoodWe's tech support and I was able to get the communication protocol documentation. I am currently waiting for the RS485 to USB converter to give this a try but as I have no experience in connecting via this kind of protocol it might be a while before I get anything working. Just thought that putting it put there might create bigger interest and someone can contribute towards getting me on the right track.
Re: GoodWe Solar PV Generation Capture
Posted: Sunday 01 May 2016 11:14
by TimSmall
Hello,
I'd be interested in seeing the GoodWe communication protocol docs if you have them - I was looking at pulling data out over the USB interface, and was wondering if the protocol may be the same (or at least sufficiently similar)? Did you get anywhere with the RS485 interface?
Cheers,
Tim.
Re: GoodWe Solar PV Generation Capture
Posted: Thursday 05 May 2016 12:44
by free_nsc
Hi Tim
No, I havent had much luck with rs485. Partially to due with restricted time I had for this and also the fact that these units only work during daylight.
I ordered lan to rs485 and then a regular usb unit but couldnt get any response. I attach the doc I got so maybe if you get anything just please let me know.
Re: GoodWe Solar PV Generation Capture
Posted: Monday 23 May 2016 11:17
by ricvee
Hi, Is there anybody who has got this to work?
Do I have to create virtual hardware for the Goodwe first?
You say:
-- The switch ID of my device in Domoticz
switchIdx = 50
Can someone give me more detailed information about this?
I see this in the logs:
2016-05-23 11:48:23.571 Error: EventSystem: in pv.lua: error loading module 'socket.core' from file '/usr/local/lib/lua/5.2/socket/core.so':
/usr/local/lib/lua/5.2/socket/core.so: wrong ELF class: ELFCLASS32
Re: GoodWe Solar PV Generation Capture
Posted: Friday 10 June 2016 16:51
by free_nsc
ricvee wrote:Hi, Is there anybody who has got this to work?
Do I have to create virtual hardware for the Goodwe first?
You say:
-- The switch ID of my device in Domoticz
switchIdx = 50
Can someone give me more detailed information about this?
I see this in the logs:
2016-05-23 11:48:23.571 Error: EventSystem: in pv.lua: error loading module 'socket.core' from file '/usr/local/lib/lua/5.2/socket/core.so':
/usr/local/lib/lua/5.2/socket/core.so: wrong ELF class: ELFCLASS32
Yes it works fine for me.
What is your lua script file called exactly?
I think you're missing socket library which is used to read the Web site. If you searched the forum you will have seen this post which has all relevant files and steps required
http://www.domoticz.com/forum/viewtopic ... 638#p22638
Thanks
Re: GoodWe Solar PV Generation Capture
Posted: Thursday 11 August 2016 23:30
by louisL
The master repository now contains a native Goodwe adapter. Every 5 minutes it reads the data from the Goodwe-power site and stores it in Domoticz. It provides the power/energy values as well as status and error code values. Just enter your goodwe-power.com username and Bob is your uncle.... If you just want to try the adapter use "demo" (without quotes) as username. The adapter automatically supports multiple "stations" for a single username and even multiple inverters in a station are shown separately. If you happen to have multiple inverters in a single station, please let me know as I may be able to add a station entry as well, which I in that case expect to contain the totals.
I am trying to contact Goodwe to see if they can provide an API to read the real time detailed data that can be found on their website.
BR, Louis
Re: GoodWe Solar PV Generation Capture
Posted: Friday 12 August 2016 12:03
by free_nsc
@Louis excellent work!! I am going to start testing it now. In relation to real time data I think the data is only refreshed every 5 minutes.
It would be good if we could figure out the rs485 protocol to poll the inverter directly thus cut out the middle man altogether and this way also have visibility of few other extra parameters eg. Temperature.
Re: GoodWe Solar PV Generation Capture
Posted: Thursday 18 August 2016 23:38
by louisL
USB (not RS485) is on my TODO list.
I have found a document that describes the RS485 protocol. It is most likely NOT modbus. My Goodwe (GW3000NS-D) does not have RS485 but I hope that the USB interface works the same. But the USB connector is hidden behind the WIFI dongle, so I need to find a way to connect USB and mount the dongle at the same time.
I guess you are right that the updates to Goodwe-power.com happens every 5 minutes. The device uploads a lot more data than what is available in the apps. On the website you can find temperature and a lot more information in the "real time" tab. I have already asked Goodwe for a web api that provides all that data. We will see if they react. If not I will try to see if I can make a contraption that allows me to fix the Wifi dongle and USB at the same time.
Louis
Re: GoodWe Solar PV Generation Capture
Posted: Tuesday 23 August 2016 23:39
by free_nsc
Your plugin works 100% i have it on for last few weeks and all working well, thanks.
I havent looked at the website since it had its new layout but my gw1000-ns doesnt seem to be sending the Temperature up.
Both inverters look pretty much the same so what i did is i left the wifi antenna hanging so that i could plug the USB in. I know thats not ideal but it works fine. In relation integration, if we could get USB working then better still! The protocol documentation that I attached few posts up will not work thought as that is for serial-bus not modbus. Maybe USB sniffer might help out? E.g. wireshark plus the usbpcap project.
Re: GoodWe Solar PV Generation Capture
Posted: Monday 03 October 2016 20:56
by louisL
yeah, I was indeed planning to use a usb capture under Windows to see what I can get a trace of the official Ezviewer Windows app. If I just had some time. Soory fornot replying sooner: I am too busy with other things.
Just a question: what is the size of the screws for the Wifi adapter? M3/m4?
And even the serial bus is not modbus, so there is still a chance that the protocol spec may be of help
Re: GoodWe Solar PV Generation Capture
Posted: Wednesday 19 October 2016 10:17
by derherb
Hi Guys, i'm fairly new to Domoticz and it's capabilities are overwhelming. Now i want to try to get domoticz configured to my Goodwe Solar convertor. User louisL mentioned something about a native goodwe adapter in the master repository. Where can i find the master repository? Or do i have to work my way through this script?
Re: GoodWe Solar PV Generation Capture
Posted: Thursday 27 October 2016 2:00
by free_nsc
derherb wrote:Hi Guys, i'm fairly new to Domoticz and it's capabilities are overwhelming. Now i want to try to get domoticz configured to my Goodwe Solar convertor. User louisL mentioned something about a native goodwe adapter in the master repository. Where can i find the master repository? Or do i have to work my way through this script?
You need to switch your release to beta and download an update. Once installed, go to hardware and pick from the drop down list Goodwe solar inverter via Web API.
Then configure the username and click add new hardware. couple of new devices should then be added in to devices where you can activate them. Good luck
Re: GoodWe Solar PV Generation Capture
Posted: Sunday 19 February 2017 15:11
by ThijsN
Hello, I am new to this forum in order to seek some support for my project.
I am attempting to communicate with a GoodWe inverter via USB with a RaspberryPi.
In order to do so, among other things, I have used wireshark to log the EzExplorer USB communication.
My current issue is that the log file seems to "abuse" the USB protocol.
I can share the file.
Is this a correct thread or do I need to start a new thread.
please note, my goal is not to use Domoticz per se as well to enable the USB interface on the GoodWe PV to be no longer depending on the Chineze GoodWe portal.
Re: GoodWe Solar PV Generation Capture
Posted: Friday 24 February 2017 12:49
by tiaanv
A couple of things.
the USB port can be used, but be aware that it is USB HID device, so it is a little bit tricky to get working on most platforms that are generally serial orientated.
Then the next big thing is RS485. This is an option but NOT for the ES series of inverters, as Goodwe have disabled all rs485 functionality (EZLOGGER), and dedicated these ports on the ES for BMS (battery management) and the EZMeter (energy meter). so you will have no joy in that regard.
Most ES inverters however come with the Wifi connection.... This is rather simple to get working using UDP datagrams. The protocol is similar to the RS485 protocol, but it uses a different data structure.
I have implemented this with perfect success using the VERA platform with a custom plugin (I use this as my home controller, but also have domoticz).
I may not disclose the exact protocol details, as there is a confidentiality agreement with Goodwe that binds me, but drop me a personal message if you need some guidance.
This approach makes the interaction with the inverter mealtime, I poll every 2 seconds in my environment, and has the benefit of being wireless
Re: GoodWe Solar PV Generation Capture
Posted: Friday 24 February 2017 14:30
by Sircuri
ThijsN wrote:Hello, I am new to this forum in order to seek some support for my project.
I am attempting to communicate with a GoodWe inverter via USB with a RaspberryPi.
In order to do so, among other things, I have used wireshark to log the EzExplorer USB communication.
My current issue is that the log file seems to "abuse" the USB protocol.
I can share the file.
Is this a correct thread or do I need to start a new thread.
please note, my goal is not to use Domoticz per se as well to enable the USB interface on the GoodWe PV to be no longer depending on the Chineze GoodWe portal.
Can you please tell what you have done so far? Do you have successfully connected to the GoodWe inverter using USB? I'm currently trying the same thing, but my Mac can't seem to see the inverter. I have fixed the raspberry pi to the wall, so its not easy for me to try that one. Perhaps i have to remove it and connect it to the inverter before trying anything else.
The document above with the protocol description should allow anybody to make a successful connection.
Re: GoodWe Solar PV Generation Capture
Posted: Saturday 25 February 2017 13:32
by Sircuri
tiaanv wrote:A couple of things.
I have implemented this with perfect success using the VERA platform with a custom plugin (I use this as my home controller, but also have domoticz).
I may not disclose the exact protocol details, as there is a confidentiality agreement with Goodwe that binds me, but drop me a personal message if you need some guidance.
This approach makes the interaction with the inverter mealtime, I poll every 2 seconds in my environment, and has the benefit of being wireless
I'm unable to find a way to drop you a pm on this website.
But you are saying that you can connect using the wifi option of the inverter? How do you connect to the inverter using wifi? I would realy like to know how you manager to get the data out of the inverter without using the usb connection and goodwe portal. Could you point me in the right direction?
Re: GoodWe Solar PV Generation Capture
Posted: Thursday 09 March 2017 21:10
by free_nsc
tiaanv wrote:
I may not disclose the exact protocol details, as there is a confidentiality agreement with Goodwe that binds me, but drop me a personal message if you need some guidance.
This approach makes the interaction with the inverter mealtime, I poll every 2 seconds in my environment, and has the benefit of being wireless
I'd love to be able to poll the inverter every 5 second please give some guidance - sent you a PM. If not I will just move to fronius they are much more open and supportive it seems.
GoodWe Solar inverter logger based on ESP8266
Posted: Tuesday 04 July 2017 21:24
by CodeItAway
I've just finished a project to poll the GoodWe inverters using an ESP8266 using the RS485 connection (under the WIFI module). The ESP polls the inverter every second and uploads the data to Pvoutput (optional) and MQTT (optional). Using node-red I convert the MQTT messages and upload the data to Domoticz. This works stable for multiple weeks.
The connection to the GoodWe website is no longer needed. More information can be found on the
Github page
Re: GoodWe Solar inverter logger based on ESP8266
Posted: Monday 04 September 2017 0:48
by free_nsc
CodeItAway wrote: ↑Tuesday 04 July 2017 21:24
I've just finished a project to poll the GoodWe inverters using an ESP8266 using the RS485 connection (under the WIFI module). The ESP polls the inverter every second and uploads the data to Pvoutput (optional) and MQTT (optional). Using node-red I convert the MQTT messages and upload the data to Domoticz. This works stable for multiple weeks.
The connection to the GoodWe website is no longer needed. More information can be found on the
Github page
Excellent work. I got the rs232->rs485 and flashed your Goodwe image. All seems to be set up and it appears that messages are read from the Inverter. See the log below, for some reason it looks like it is not confirming the address and so we are not requesting any info - is this normal?
Code: Select all
Sending discovery
Sending data to inverter(s): 0xAA 0x55 0xAB 0x7F 0x0 0x0 0x0 CRC high/low: 0x2 0x29 .
MQTT send status: 1
Parsing incoming data with length: 0x17 . 0xAA 0x55 0x7F 0xAB 0x0 0x80 0x10 0x31 0x31 0x30 0x30 0x30 0x53 0x53 0x4E 0x31 0x35 0x37 0x30 0x30 0x30 0x38 0x39 0x6 0x3D .
CRC received: 0x6 0x3D , calculated CRC: 0x6 0x3D .
CRC match.
New inverter found. Current # registrations: 1
SendAllocateRegisterAddress address: 1
Sending data to inverter(s): 0xAA 0x55 0xAB 0x7F 0x0 0x1 0x11 0x31 0x31 0x30 0x30 0x30 0x53 0x53 0x4E 0x31 0x35 0x37 0x30 0x30 0x30 0x38 0x39 0x1 CRC high/low: 0x5 0xC0 .
Not asking inverter with address: 1 for information. Addressconfirmed: 0, isOnline: 1.
MQTT send status: 1
I want to use these values to feed into devices in Domoticz, I know you used nodeRed, could you share your flow please?
I need to figure this part out myself but some guidance would be appreciated
I guess, also I could also change the code to publish into Domoticz using the http requests but I'd like to try the mqtt as I didnt have any previous experience of it before.