Page 1 of 12

Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Tuesday 08 September 2015 18:27
by galadril
EDIT: Script improved by JacquesMulders :)
EDIT2: Ginlong and MyEvolveCloud.com has now also a new platform (platform 2 they call it). I've added a new script for ginlong on platform 2!!

By default the Ginlong, Omnik Solar, Solarman and Trannergy Inverters can upload all performance values of the inverter to their own portal.

Platform 1
- http://www.ginlongmonitoring.com
- http://www.omnikportal.com
- http://log.trannergy.com
- http://www.tengtengchina.com
- http://www.solarmanpv.com

Platform 2
- http://m.ginlong.com
- http://myevolvecloud.com


PS, if you have a system that now uses Platform 2.0 (with url m.ginlong.com or myevolvecloud.com, look below for a different script!!
All the other staps stay the same, just use a different script.


But with these script, you extract some of that data from that portal to Domoticz.

If you use one of these inverters, please try my Android or iOS app:
Apple:
https://apps.apple.com/nl/app/solar-ene ... 1517272630

Android:
https://play.google.com/store/apps/deta ... ongmonitor




Any ideas?

:D :D :D :D

Prepare Domoticz
If you don't know how to create a virtual sensor chances are you have never done this before.
- Go to "Hardware"
- Fill in the name field with a desired name (like "Virtual")
- Choose for type the "Dummy, does nothing, use for virtual switches only"
- Click on "Add"
- The added hardware is now added to the hardware list. In the same row there is a "Create virtual sensor" button shown. Click on it.


Hardware
Now you are ready to create virtual devices.
- Go to "Hardware"
- Press "Create virtual sensor".
- Fill in the name with a desired name (Ginlong, or Omnik Solar for example)

Image


Devices
Now you are ready to create a devices.
- Go to "Devices"
- Press click on the green arrow at the right on the newly added device.
- Fill in the name field with a desired name

Image


Station ID
Use the stationid.py script to get the station id of your inverter.
You have to config the next parameters in the script:

Code: Select all

username 			= '' #your portal username
password 			= '' #your portal password
baseURL 			= 'http://www.ginlongmonitoring.com:10000' #base url

Ginlong script
Config the parameters in the Ginlong script:

Code: Select all

#config
username 			= '' #your portal username
password 			= '' #your portal password
baseURL 			= 'http://www.ginlongmonitoring.com:10000' #base url
stationid 			= '' #station id, get this via the station python script

#domoticz settings
domoticz_host      	= ''
domoticz_port      	= ''
domoticz_url       	= 'json.htm'
domoticz_ActualPower   = '' # idx of new device

Put the script under /domoticz/scripts and make the script executable:
"sudo chmod +x /home/pi/domoticz/scripts/ginlong.py"


Test
Run the script by calling:
"sudo python /home/pi/domoticz/scripts/ginlong.py"
It should result something like:

Code: Select all

Getting Info...
TodayIncome: 1.357
ActualPower: 183
etoday: 5.9

Create the Cronjob
Now all ingredients are available to read the data from the portal and insert them into Domoticz.
- execute "sudo crontab -e"
- add the following line "*/5 * * * * /home/pi/domoticz/scripts/ginlong.py"
- exit crontab. Now everything should be working for you.


Scripts
ginlong.py (Platform 1 script)

Code: Select all

#!/usr/bin/python

import urllib, urllib2, hashlib
from xml.etree import ElementTree as ET


#config
username 			= '' #your portal username
password 			= '' #your portal password
baseURL 			= 'http://www.ginlongmonitoring.com:10000' #base url
stationid 			= '' #station id, get this via the station python script

# example: Working base urls:
#      http://www.ginlongmonitoring.com:10000/
#      http://www.omnikportal.com:10000/
#      http://log.trannergy.com:10000/
#      http://www.solarmanpv.com:10000/

#domoticz settings
domoticz_host      	= ''
domoticz_port      	= ''
domoticz_url       	= 'json.htm'
domoticz_ActualPower   = '' #idx of new device


m = hashlib.md5()
m.update(password)


#building url
requestURL = baseURL+'/serverapi/?method=Login&username='+username+'&password='+m.hexdigest()+'&key=apitest&client=iPhone'

#login call
root = ET.parse(urllib.urlopen(requestURL)).getroot()
token = root.find('token').text

print 'Logged In: '+username

#info url
infoURL = baseURL+'/serverapi/?method=Data&username='+username+'&stationid='+stationid+'&token='+token+'&key=apitest'

print 'Getting Info... '


#login call
infoRoot = ET.parse(urllib.urlopen(infoURL)).getroot()

income = infoRoot.find('income')
TodayIncome = income.find('TodayIncome').text
ActualPower = income.find('ActualPower').text
etoday = income.find('etoday').text
etotal = income.find('etotal').text

multiply='1000.0'
etotal1000 = float(etotal) * float(multiply)
TotalIncome = income.find('TotalIncome').text
etotalstr=str(etotal1000)


#logging values
print 'TodayIncome: '+TodayIncome
print 'ActualPower: '+ActualPower
print 'etoday: '+etoday
print 'etotal: '+etotal
print 'etotal 1000: '+etotalstr

#uploading values to domoticz
url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_ActualPower+ "&nvalue=0&svalue=" + ActualPower+ ";" + etotalstr)
urllib.urlopen(url)





stationid.py

Code: Select all

#!/usr/bin/python

import urllib, urllib2, hashlib
from xml.etree import ElementTree as ET


#config
username 			= '' #your portal username
password 			= '' #your portal password
baseURL 			= 'http://www.ginlongmonitoring.com:10000' #base url


# Working base urls:
#		http://www.ginlongmonitoring.com:10000/
#		http://www.omnikportal.com:10000/
#		http://log.trannergy.com:10000/
#		http://www.solarmanpv.com:10000/
	
	
	
m = hashlib.md5()
m.update(password)

#building url
requestURL = baseURL+'/serverapi/?method=Login&username='+username+'&password='+m.hexdigest()+'&key=apitest&client=iPhone'

#login call
root = ET.parse(urllib.urlopen(requestURL)).getroot()
token = root.find('token').text

print 'Logged In: '+username

#info url
infoURL = baseURL+'/serverapi/?method=Powerstationslist&username='+username+'&token='+token+'&key=apitest'
print 'Getting station id(s)... '

#login call
infoRoot = ET.parse(urllib.urlopen(infoURL)).getroot()
for elem in infoRoot.findall('power'):
    print "StationID: "+elem.find('stationID').text


NEW SCRIPT FOR GINLONG PLATFORM 2::

Code: Select all

#!/usr/bin/python
import requests
import urllib, urllib2

#config
username 			= 'USERNAME'				#your username
password 			= 'PASSWORD'				#your password
domain 				= 'm.ginlong.com' 			#domain
plantId 			= '123456' 					#plant id
lan 				= '2' 						#lanuage (2 = English)

#domoticz settings
domoticz_host      		= 'DOMOTICZ_USERNAME:DOMOTICZ_PASSWORD@IP'
domoticz_port      		= '8080'
domoticz_url       		= 'json.htm'			#leave this
domoticz_device_idx    = '58'

# Create session for requests
session = requests.session()

#building url
url = 'http://'+domain+'/cpro/login/validateLogin.json'
params = {
    "userName": username,
    "password": password,
    "lan": lan,		
    "domain": domain,
    "userType": "C"
}

#login call
resultData = session.post(url, params=params)
resultJson = resultData.json()
if resultJson['result'].get('isAccept') == 1:
    print("Login Succesfull!")
else:
    print("Login Failed!!")
    Exit()

# Get plant details
url = 'http://'+domain+'/cpro/epc/plantDetail/showPlantDetailAjax.json'
params = {
    'plantId': int(plantId)
}

cookies = {'language': lan}
resultData = session.get(url, params=params, cookies=cookies)
resultJson = resultData.json()

TodayIncome = resultJson['result']['plantAllWapper']['plantData'].get('incomeTotal')
ActualPower = resultJson['result']['plantAllWapper']['plantData'].get('power')
etoday = resultJson['result']['plantAllWapper']['plantData'].get('energyToday')
etotal = resultJson['result']['plantAllWapper']['plantData'].get('energyTotal')

multiply='1000.0'
etotal1000 = float(etotal) * float(multiply)
etotalstr=str(etotal1000)

#logging values
print 'TodayIncome: ' + str(TodayIncome)
print 'ActualPower: ' + str(ActualPower)
print 'etoday: ' + str(etoday)
print 'etotal: ' + str(etotal)
print 'etotal 1000: ' + str(etotalstr)

#uploading values to domoticz
url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_device_idx+ "&nvalue=0&svalue=" + str(ActualPower) + ";" + str(etotalstr))
urllib.urlopen(url)


Image

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Wednesday 09 September 2015 13:23
by JacquesMulders
Why not making all in 1 device? a energy device wil porvide an actual usage and a "today" in the counter below if you uploaded the total counter it will supply a today counter. see my pic.
and the euros will also display in de report of that specific device..

with api call /json.htm?type=command&param=udevice&idx=IDX&nvalue=0&svalue=POWER;ENERGY

Power is current wattage
energy is total energy generated

Image

Image

ive edited the code, maybe you want it.

Code: Select all

#!/usr/bin/python

import urllib, urllib2, hashlib
from xml.etree import ElementTree as ET


#config
username          = '' #your portal username
password          = '' #your portal password
baseURL          = ' http://www.omnikportal.com:10000' #base url
stationid          = '' #station id, get this via the station python script

# example: Working base urls:
#      http://www.ginlongmonitoring.com:10000/
#      http://www.omnikportal.com:10000/
#      http://log.trannergy.com:10000/
#      http://www.solarmanpv.com:10000/

   
#domoticz settings
domoticz_host         = ''
domoticz_port         = ''
domoticz_url          = 'json.htm'
domoticz_ActualPower   = '' #optional

m = hashlib.md5()
m.update(password)


#building url
requestURL = baseURL+'/serverapi/?method=Login&username='+username+'&password='+m.hexdigest()+'&key=apitest&client=iPhone'

#login call
root = ET.parse(urllib.urlopen(requestURL)).getroot()
token = root.find('token').text

print 'Logged In: '+username

#info url
infoURL = baseURL+'/serverapi/?method=Data&username='+username+'&stationid='+stationid+'&token='+token+'&key=apitest'

print 'Getting Info... '



#login call
infoRoot = ET.parse(urllib.urlopen(infoURL)).getroot()

income = infoRoot.find('income')
TodayIncome = income.find('TodayIncome').text
ActualPower = income.find('ActualPower').text
etoday = income.find('etoday').text
etotal = income.find('etotal').text
multiply='1000.0'
etotal1000 = float(etotal) * float(multiply)
TotalIncome = income.find('TotalIncome').text

etotalstr=str(etotal1000)

#logging values
print 'TodayIncome: '+TodayIncome
print 'ActualPower: '+ActualPower
print 'etoday: '+etoday
print 'etotal: '+etotal
print 'etotal 1000: '+etotalstr


#uploading values to domoticz
url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_ActualPower+ "&nvalue=0&svalue=" + ActualPower+ ";" + etotalstr)
urllib.urlopen(url)

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Wednesday 09 September 2015 14:15
by galadril
Thanks! didn't knew that!
I'll change the scripts accordingly..

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Wednesday 09 September 2015 14:19
by JacquesMulders
galadril wrote:Thanks! didn't new that!
I'll change the scripts accordingly..

sorry i saw your post after edditing my post, there wil be a modified post :D :o :geek:

the only thing is that when you first run the script you will get a high day vallue... the next day it will be correct

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Wednesday 09 September 2015 14:22
by galadril
Thanks! I'll modify the root post with your script :)

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Wednesday 09 September 2015 19:37
by TheStig
Thanks for the great work!!! It works perfectly.

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Saturday 10 October 2015 14:23
by Mediacj
Thanks for this great script!

I try to implement it by someone else and get this error when we start ginlong.py:

Code: Select all

Getting Info... 
TodayIncome: 0.5324
ActualPower: 676
etoday: 2.42
etotal: 5290.6
etotal 1000: 5290600.0
Traceback (most recent call last):
  File "ginlong.py", line 69, in <module>
    urllib.urlopen(url)
  File "/usr/lib/python2.7/urllib.py", line 86, in urlopen
    return opener.open(url)
  File "/usr/lib/python2.7/urllib.py", line 207, in open
    return getattr(self, name)(url)
  File "/usr/lib/python2.7/urllib.py", line 358, in open_http
    return self.http_error(url, fp, errcode, errmsg, headers)
  File "/usr/lib/python2.7/urllib.py", line 371, in http_error
    result = method(url, fp, errcode, errmsg, headers)
  File "/usr/lib/python2.7/urllib.py", line 682, in http_error_401
    errcode, errmsg, headers)
  File "/usr/lib/python2.7/urllib.py", line 380, in http_error_default
    raise IOError, ('http error', errcode, errmsg, headers)
IOError: ('http error', 401, 'Unauthorized', <httplib.HTTPMessage instance at 0x7679b828>)
As you can see above there is data coming in so the authorization seems ok on the portal, we made a new virtual device for total usage/current usage in one as mentioned above and put the idx in the ginlong.py.

Any idea what is going wrong?

EDIT:
Found it already it was the authorization on the Domoticz database, now it works :D

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Tuesday 20 October 2015 21:54
by stimpy
awesome, my first script and it worked first time!

is there a way of getting some of the other data from the ginlong website, such as DC volts and temperature?

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Wednesday 21 October 2015 8:45
by Derik
This option would also be possible with a Sofar Solar inverter?
These logs to the site http://solarmanpv.com/index_en.html

To understand it well, with this script I get the data from this portal to Domoticz?

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Friday 23 October 2015 17:57
by Derik
Dear Thanks...
For the great work...
Got it almost i thinkl;;
ScreenShot026.jpg
ScreenShot026.jpg (52.68 KiB) Viewed 27810 times
I got:
ScreenShot027.jpg
ScreenShot027.jpg (10.38 KiB) Viewed 27810 times
I got:
ScreenShot028.jpg
ScreenShot028.jpg (7.43 KiB) Viewed 27810 times
Only my counter is not working on the crontab.
And it only works when i do a manual sudo python xxx with putty [ the way to test it ]


Perhaps a better option for the crontab:
*/5 5-23 * * * /home/
The time that the sun is online.......

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Thursday 29 October 2015 8:37
by galadril
Derik wrote:Only my counter is not working on the crontab.
Your crontab line is probably not correct. I think it misses 1 extra *:
https://www.raspberrypi.org/documentati ... ge/cron.md

so as stated in the original post:

Code: Select all

Create the Cronjob
Now all ingredients are available to read the data from the portal and insert them into Domoticz.
- execute "sudo crontab -e"
- add the following line "*/5 * * * * /home/pi/domoticz/scripts/ginlong.py"
- exit crontab. Now everything should be working for you.

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Thursday 29 October 2015 8:37
by galadril
stimpy wrote:awesome, my first script and it worked first time!
is there a way of getting some of the other data from the ginlong website, such as DC volts and temperature?
That should be possible yes

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Thursday 05 November 2015 14:41
by galadril
For the users of my Power Monitor app for Android!!
I've added Android Wear possibilities, to check the Energy levels op your watch

See attached screenshot

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Sunday 08 November 2015 21:14
by Derik
Is the script or the counter correct?
See the differents...
ScreenShot035.jpg
ScreenShot035.jpg (35.58 KiB) Viewed 27702 times
And:
ScreenShot036.jpg
ScreenShot036.jpg (13.62 KiB) Viewed 27702 times
The totals are correct...
Only the day not?

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Monday 09 November 2015 9:06
by galadril
Derik wrote:The totals are correct...
Only the day not?
see the post of JacquesMulders:
JacquesMulders wrote:The only thing is that when you first run the script you will get a high day vallue... the next day it will be correct

Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Monday 09 November 2015 9:11
by JacquesMulders
I dont think he means that... The script rounds all vallues so thats the diffrance.
its only 30 wh.... That is 0.007 ct... Other wise you have to correct the script, Derik


Verzonden vanaf mijn iPhone met Tapatalk

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Saturday 21 November 2015 20:33
by Peter112
I have a question about the omnik script

I use a windows7 thin pc wich runs Python 3.4 ( 3.5 wil not run.)
I downloaded the Omnik scripts from Woutrrr/Omnik-Data-Logger

Now the scripts are made for Python 2.x i think
Most of the conversion is done by the Python2to3 script.

But iám stuck in the InverterMsg.py script
it stops @line 97 with the decode hex part as listed below. As i have read Python3 will not use the .decode('hex'). It is also not converted with the 2to3 script.

Code: Select all

def generate_string(ser):
    '''
    The request string is build from several parts. The first part is a
    fixed 4 char string; the second part is the reversed hex notation of
    the s/n twice; then again a fixed string of two chars; a checksum of
    the double s/n with an offset; and finally a fixed ending char.
    '''
    responseString = '\x68\x02\x40\x30';

    doublehex = hex(ser)[2:]*2
    hexlist = [ doublehex[i:i+2].decode('hex') for i in 
        reversed(range(0, len(doublehex), 2))]

    cs_count = 115 + sum([ ord(c) for c in hexlist])
    cs = hex(cs_count)[-2:].decode('hex')
    responseString += ''.join(hexlist) + '\x01\x00'+cs+'\x16'
    return responseString


now i found something, but stil not working

Code: Select all

import codecs                  #added
decode_hex = codecs.getdecoder('hex_codec')

hexlist = [decode_hex(doublehex)[i:i+2] for i in       #code changed
      reversed(range(0, len(doublehex), 2)))]

      cs_count = 115 + sum([ ord(c) for c in hexlist])
     cs = hex(decode_hex(cs_count)[-2:])                   #code changed
    responseString += ''.join(hexlist) + '\x01\x00'+cs+'\x16'
    return responseString

>>>
running the script gives
connecting to 192.168.2.13 port 8899
dubbelhex 5fdd834b5fdd834b
Traceback (most recent call last):
File "C:\Python34\Scripts\omnnik\Omnik\LiveStats.py", line 55, in <module>
s.sendall(InverterMsg.generate_string(wifi_serial))

File "C:\Python34\Scripts\omnnik\Omnik\InverterMsg.py", line 97, in generate_string
cs_count = 115 + sum([ ord(c) for c in hexlist])
File "C:\Python34\Scripts\omnnik\Omnik\InverterMsg.py", line 97, in <listcomp>
cs_count = 115 + sum([ ord(c) for c in hexlist])
TypeError: ord() expected string of length 1, but tuple found
>>>

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Sunday 06 December 2015 13:03
by Peter112
Everything ok now,
Switched my other script to Python 2.7
Edited the omnik script for my easy windows7 box

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Sunday 21 February 2016 14:00
by Noppie
Hi, can anybody tell me which sensor is appropriate for Solar Panels (I've added a dummy device but don't now which sensor i have to add)

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Saturday 27 February 2016 21:01
by Haubke
Hi al,

I am following Domoticz lately, i have à solar array of 17 panels. I wanted to read it out. No luck with Domoticz. I just received a protocol datasheet of this device. I was searching for this manufacturer . I came here.

I am planning on making à driver for domoticz. Probably more devices could work directly with it.(same manufacturer?).

Can you guys log in directly to Your inverter? Or do you have WiFi/ethernet dongles?. My device has à dongle with WiFi, where i dan take data of.

My question is. Where can i write Some code for à new device. I know the protocol. And What Every piece of data Means. ITS possible it is working with more devices, ginlong omnik etc etc. Directly from inverter(if it is same as mine (WiFi/ethernet Dongle)).

Thanks