Ginlong, Omnik Solar, Solarman and Trannergy Inverters Topic is solved

Python and python framework

Moderator: leecollings

Post Reply
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by Derik »

Dear Alla..
Did run this script for a few years...
I need to do a clean install.
And now i cannot get the script to work..
When i read the topic i need a specail version of python..:

Code: Select all

odroid@odroid:~$  sudo apt-get install idle-python3.4
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 idle-python3.4 : Depends: python3.4 but it is not going to be installed
                  Depends: python3.4-tk
E: Unable to correct problems, you have held broken packages.
Only i still get an error..
hope some will help me

Thanks
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
RichardBokker
Posts: 39
Joined: Thursday 09 April 2015 20:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9317
Location: Netherlands
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by RichardBokker »

Still working like a charm! thnx.

anyone idea how fast i can run crontab to read out Ginlong? Because 5 minutes interval is to slow, thinking about 10 seconds or so.. :D
Don't know if ginlong will run at that frequency..?
TimZon
Posts: 2
Joined: Saturday 30 June 2018 12:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by TimZon »

Where do i have to start?

Installed Domoticz on raspberry.

Version 4.97 and python is 3.5.3

First make the virtual device and what sensor type do i need to choose?

And which version of the scripts can i use?

Thanks for helping Tim
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by sincze »

TimZon wrote: Saturday 30 June 2018 14:09 Where do i have to start?

Installed Domoticz on raspberry.

Version 4.97 and python is 3.5.3

First make the virtual device and what sensor type do i need to choose?

And which version of the scripts can i use?

Thanks for helping Tim
Using the wiki would be a nice start to get some ideas on how to create the virtual sensors.
https://www.domoticz.com/wiki/Omnik_Solar_Inverter
The rest comes down to writing down the idx values and using the script in cron.
Version of script depends on the inverter type you have. Probably the last script in the forum is usually the best one. I always start reading at the end and move my wake back to front of the thread.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
TimZon
Posts: 2
Joined: Saturday 30 June 2018 12:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by TimZon »

sincze wrote: Sunday 01 July 2018 11:44
TimZon wrote: Saturday 30 June 2018 14:09 Where do i have to start?

Installed Domoticz on raspberry.

Version 4.97 and python is 3.5.3

First make the virtual device and what sensor type do i need to choose?

And which version of the scripts can i use?

Thanks for helping Tim
Using the wiki would be a nice start to get some ideas on how to create the virtual sensors.
https://www.domoticz.com/wiki/Omnik_Solar_Inverter
The rest comes down to writing down the idx values and using the script in cron.
Version of script depends on the inverter type you have. Probably the last script in the forum is usually the best one. I always start reading at the end and move my wake back to front of the thread.
Thanks a lot!
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by Toulon7559 »

Step1
Got the Ginlong-script running with a SOLIS DLS_L aka DLS_E hooked to a SOLIS700.

Step2
My other inverters by means of their loggers upload info to PVOutput.
;-) Obviously (for complete picture at one place) than a desire to include/upload the SOLIS-information in this collection at PVOutput.
Info on Power and Energy is available from the script 'helping' Domoticz,
Have produced & tested an annex to the Ginlong-script doing that extra job.

Step3
For compatibility of graphs at PVOutput now looking for a source of SOLIS' info on Input_Voltage and Inverter_Temperature.
In the Ginlong monitoring pictures this info is present.
However, calling the infoURL does not show this information.
Therefore the question is: which other URL should be called to get access to that info?
Somebody having that information?

Are any other 'interesting' URLs available to get info from the SOLIS inverters (documented + undocumented)?
Either on the LAN, or at the Ginlong-website?
Example for my FP4All-Loggers: http-URLs, json-URLs and xml-URLs.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by Toulon7559 »

As announced under Step2 of my previous message, have extended the script which reads & feeds for Domoticz with a 2nd section feeding to PVOutput.

The code of the full package is below.
Changes relative to the original script:
- text-bar at the start of the 1st, original identifying the script and it's status
- line numbers added in the 1st section to help in trouble-shooting
- 'closing' bar for the 1st section after line 75
- 2nd section prepares and performs the upload to PVOutput
- I could have used the same parameter-names all over the script, but ;-) I'm lazy, and therefore a transition section performs translation between the variables from the 1st section towards the application in the 2nd section
- The 1st section performing upload to Domoticz applies etotal: it works => OK
However, the resolution of etotal is 1 kWh and the resolution of etoday is 0.1 kWh: therefore etoday seems the better choice for the upload to PVOutput.
In the transition section therefore a formula to multiply etoday by 1000, because PVOutput requires all energy-uploads to be in Wh.
- pay attention to proper setting of the cum-flag (due to above argument now set for upload of etoday)!
- Printlines in the 2nd section are aid for checking the upload.
- On purpose no linenumbers added to the 2nd section, because to be foreseen that some people will modify & squeeze the script by taking out the redundancies and by application of the same variable-names all over the script.

Code: Select all

#!/usr/bin/python
# --------------------------------------------------
# script compiled by Toulon7559 from various material from forums, 
# version 0.3 for download from Ginlong and upload to Domoticz and to PVOutput on same processor
# --------------------------------------------------
# Line 6
import urllib, urllib2, hashlib
from xml.etree import ElementTree as ET

#config                         <xx> = value or text to fill-in
username 			= '<un>' #your portal username
password 			= '<pw>' #your portal password
baseURL 			= 'http://www.ginlongmonitoring.com:10000' #base url
stationid 			= '<si>' #station id, get this via the station python script
# Line 15
# example: Working base urls:
#      http://www.ginlongmonitoring.com:10000/
#      http://www.omnikportal.com:10000/
#      http://log.trannergy.com:10000/
#      http://www.solarmanpv.com:10000/
# Line 21
#domoticz settings
domoticz_host      	= '127.0.0.1' # 127.0.0.1 is for local host
domoticz_port      	= '8080'
domoticz_url       	= 'json.htm'
domoticz_ActualPower   = '<idx>' #idx of new device

# Line 28
m = hashlib.md5()
m.update(password)

# Line 32
#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

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

print 'Getting Info... '

# Line 47
#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)

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

# Line 70
#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)

# Line 75
# --------------------------------------------------
# END OF UPLOAD TO DOMOTICZ
# --------------------------------------------------

# Setting & Translation for values in next section
TEMPINV = 0
VOLTAGE = 0
POWER = ActualPower
LIFEENERGY = etotal1000   # Energy in Wh
multiply='1000.0'
etoday1000 = float(etoday) * float(multiply)
DAYENERGY = etoday1000  # Energy in Wh

# --------------------------------------------------
# START OF UPLOAD TO PVOUTPUT
# --------------------------------------------------
# Settings for PVOutput
pvout_enabled   = True
pvout_apikey    = "<your full API-key for PVOutput>"
pvout_sysid     = <SID at PVOutput>
pvout_cumflag   = 0   # flag is 1 if you apply lifetime-energy Wh_life / LIFEENERGY
                      # flag must be 0 if you upload day-energy Wh_today / DAYENERGY
                      
# Imports for script-operation

import datetime       # used for timestamps & timecheck
import subprocess
from time import strftime
import time

# Linking of parameters

SYSTEMID = pvout_sysid
APIKEY = pvout_apikey
t_date = format(strftime('%Y%m%d'))
t_time = format(strftime('%H:%M'))
Wh_life=LIFEENERGY
Wh_today=DAYENERGY
pv_temp=TEMPINV
pv_volts=VOLTAGE
pv_power=POWER
if pvout_cumflag == 1:
   Wh_upload=Wh_life
else:
   Wh_upload=Wh_today

Starthour = 4
Stophour = 22

# Determine Uploadtime

now = datetime.datetime.now()
print 'Upload-window PVO opens when start-hour =',Starthour
print 'Upload-window PVO closes after stop-hour=',Stophour
uploadtime = (now.hour >= Starthour) and (now.hour <= Stophour)
if uploadtime:
   print 'inside upload-window'
else:
   print 'outside upload-window'

# Determine Values & Compile for upload to PVOutput

if pvout_enabled and uploadtime:
   print 'uploading'
   pv_power=POWER
   pv_temp=TEMPINV
   pv_volts=VOLTAGE
   cum=pvout_cumflag
   cmd=('curl -d "d=%s" -d "t=%s" -d "v1=%s" -d "v2=%s" -d "v5=%s" -d "v6=%s" -d "v10=%s" -d "c1=%s" -H \
   "X-Pvoutput-Apikey: %s" -H \
   "X-Pvoutput-SystemId: %s" \
   http://pvoutput.org/service/r2/addstatus.jsp'\
   %(t_date, t_time, Wh_upload, pv_power, pv_temp, pv_volts, Wh_life, cum, \
   APIKEY, SYSTEMID))
   ret = subprocess.call(cmd, shell=True)

print
print '= Info for PVOutput ='
print 't_date %s' %t_date
print 't_time %s' %t_time
print 'pv_power %s' %pv_power
print 'Wh_today %s'%Wh_today 
print 'Wh_life %s' %Wh_life
print 'Wh_upload %s' %Wh_upload
print 'pv_temp %s' %pv_temp
print 'pv_volts %s' %pv_volts
# --------------------------------------------------
# END OF UPLOAD TO PVOUTPUT
# --------------------------------------------------

Last edited by Toulon7559 on Wednesday 22 September 2021 12:35, edited 1 time in total.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
sabiwa
Posts: 3
Joined: Thursday 30 August 2018 21:47
Target OS: -
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by sabiwa »

devros wrote: Thursday 17 August 2017 8:45
sincze wrote: Wednesday 16 August 2017 21:53 So forum member devros and myself have been playing around to see if we could modify the initial shinemonitor script in such a way that it should work for all kinds of inverters that report their data to shinemonitor.

Kudo's to the devros and his wireshark skills. :D

Pay special attention to the following values:
pn= on your wifi stick or can be found on the shinemonitor portal after signing in the regular way
sn= the serial number of your inverter. Can also be found on the official portal
devcode= this tricky number you have to extract using for example chrome f12 (under network) to see an initial string between your browser and shinemonitor. It seems every brand has its own devcode.

Just run with Python3 as cronjob every 5 minutes or so.

Have fun!!.
devros & sincze.

[/code][/spoiler]
Thanks to sincze for his great help. I can confirm that script works great.
I tried to get this one working, as i have a shinemonitor wifi plug, but I only get a fault message. Please can you help me with this one ?

Code: Select all

Traceback (most recent call last):
  File "shinemonitor.py", line 54, in <module>
    print (r.json())
  File "/usr/lib/python3/dist-packages/requests/models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
devros
Posts: 183
Joined: Saturday 29 October 2016 20:55
Target OS: -
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by devros »

sabiwa wrote: Thursday 30 August 2018 22:23
devros wrote: Thursday 17 August 2017 8:45
sincze wrote: Wednesday 16 August 2017 21:53 So forum member devros and myself have been playing around to see if we could modify the initial shinemonitor script in such a way that it should work for all kinds of inverters that report their data to shinemonitor.

Kudo's to the devros and his wireshark skills. :D

Pay special attention to the following values:
pn= on your wifi stick or can be found on the shinemonitor portal after signing in the regular way
sn= the serial number of your inverter. Can also be found on the official portal
devcode= this tricky number you have to extract using for example chrome f12 (under network) to see an initial string between your browser and shinemonitor. It seems every brand has its own devcode.

Just run with Python3 as cronjob every 5 minutes or so.

Have fun!!.
devros & sincze.

[/code][/spoiler]
Thanks to sincze for his great help. I can confirm that script works great.
I tried to get this one working, as i have a shinemonitor wifi plug, but I only get a fault message. Please can you help me with this one ?

Code: Select all

Traceback (most recent call last):
  File "shinemonitor.py", line 54, in <module>
    print (r.json())
  File "/usr/lib/python3/dist-packages/requests/models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

hello, afaik they changed something in url here is my latest dirty working code :)

Code: Select all

#!/usr/bin/python3
import urllib, hashlib
from urllib.request import urlopen
from pprint import pprint         #we only need this one for debugging 
import requests
import json
import time as time_             #make sure we don't override time

def salt():
    return int(round(time_.time() * 1000))

usr='XXX'            #your username
pwd='XXX'            #your password
companykey='XXX'      #your companykey ( mine is 2kRg8sPB1E6Vshla)

# needed to retrieve data, can be obtained from portal
pn='XXX'            #your plant id X2117100093XXX
sn='XXX'            #your serial number 1705120XXX
baseURL = 'http://ws.shinemonitor.com'
URL_API = 'http://api.shinemonitor.com'
# Password is in SHA1 format, so we need to convert it.
passwd=hashlib.sha1()            #create a sha1 type hashlib
passwd.update(pwd.encode('utf-8'))   #update the value with the password

#domoticz settings
debug = 0
domoticz = 1
domoticz_host = 'XXX.XXX.XXX.XXX'      #or the official IP adres
domoticz_port = '8080'         #domoticz port defaul 8080
domoticz_url = 'json.htm'


#building url
# print ('http://www.shinemonitor.com/ws?sign=b0ed453a993fdec7424d1b8557ca44a4ad9a0995&salt=1502720220&action=authV2&user=devrosx')
salt=salt()                  #we need a salt
# print ('SALT:' + (str(salt)))
# print ('SHA1:' + (str(passwd.hexdigest())))
action= '&action=authV2&user=XXX'
pwdaction= str(salt) + str(passwd.hexdigest()) + action   #this complete string needs sha1 encryption  
# pwdaction= str(salt) + str(passwd.hexdigest()) + action   #this complete string needs sha1 encryption  

# A little more hasing is needed to create a sign.
auth_sign=hashlib.sha1()
auth_sign.update(pwdaction.encode('utf-8'))
sign = str(auth_sign.hexdigest())
solarurl= baseURL+'/ws?sign='+ sign + '&salt=' + str(salt) + action # WS
print (solarurl)
# Process results to variables
r = requests.get(solarurl)
print (r.json())
token=r.json()['dat']['token']
secret=r.json()['dat']['secret']
expire=r.json()['dat']['expire']

# # We now have a token and secret so start collecting values.

#salt=salt()
action= '&action=queryDeviceLastData&i18n=en_US&pn=' + pn + '&devcode=512&devaddr=1&sn=' + sn
reqaction= str(salt) + secret + token + action

# A little more hasing is needed to create a sign.
req_sign=hashlib.sha1()
req_sign.update(reqaction.encode('utf-8'))
sign = str(req_sign.hexdigest())

requrl= URL_API + '/public/?sign='+ sign + '&salt=' + str(salt) + '&token=' + token + '&action=queryDeviceLastData&i18n=en_US&pn=' + pn + '&devcode=512&devaddr=1&sn=' + sn
print (requrl)

# Process results into variables
r = requests.get(requrl)
# print(r.json())


# domoticz_ActualPower = '226'       #idx of virtual domoticz device 
# domoticz_DCVoltage1 = '227'       #idx of virtual domoticz device 
# domoticz_DCcurrent1 = '228'       #idx of virtual domoticz device 
# domoticz_gridvoltageA = '230'       #idx of virtual domoticz device 
# domoticz_gridcurrentA = '229'       #idx of virtual domoticz device 

domoticz_total_energy = '140'			#celkem počítadlo
domoticz_gridvoltage_AB = '230'		#napětí v síti A OK
domoticz_output_power = '218'			#výstup W OK
domoticz_DCvoltage1 = '227'			#napětí panelů A
domoticz_status = '471'

total_energy=r.json()['dat'][43]['val']
gridvoltage_AB=r.json()['dat'][47]['val']
output_power=r.json()['dat'][59]['val']
DCvoltage1=r.json()['dat'][70]['val']
today_energy=r.json()['dat'][41]['val']
running_state=r.json()['dat'][39]['val']

if debug == 1:
	pprint(r.json()) #Uncomment to see a nice output
	print ('Total energy: (idx 140): ' + total_energy)
	print ('Gridvoltage_AB: (idx 230): ' + gridvoltage_AB)
	print ('Output_power: (idx 218): ' + output_power)
	print ('Output_woltage: (idx 227): ' + DCvoltage1)
	print ('Today energy: ' + today_energy)
	print ('Stav: ' + running_state)



multiply= 1000
etotalstr = str(float(today_energy)*float(multiply))
# print (etotalstr)
if domoticz == 1:
	print ('domoticz output OK')
	url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_output_power+ "&nvalue=0&svalue=" + output_power+ ";" + etotalstr)
	# print (url)
	urlopen(url)
	url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_gridvoltage_AB+ "&nvalue=0&svalue=" + gridvoltage_AB)
	urlopen(url)
	url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_DCvoltage1+ "&nvalue=0&svalue=" + DCvoltage1)
	urlopen(url)
	url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_total_energy+ "&nvalue=0&svalue=" + total_energy)
	urlopen(url)


sabiwa
Posts: 3
Joined: Thursday 30 August 2018 21:47
Target OS: -
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by sabiwa »

@devros, where can I find the companykey ?
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by Toulon7559 »

@devros & sincze

How applicable is your latter script for the Ginlong-inverters?
[In my configuration a cabled monitor-plug is the interface between the Ginlong SOLIS700-inverter and the LAN.
imho that is equivalent to a wifi-monitorplug]

Any further hints where to look and for what?
Last edited by Toulon7559 on Tuesday 29 January 2019 19:00, edited 2 times in total.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
StKilda
Posts: 5
Joined: Thursday 18 October 2018 18:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by StKilda »

Totally new to both domoticz and most things to do with home automation so please bear with me.

I have a solis inverter that sends via a wifi dongle to ginlongmonitoring.com. At the monist I'm failing at the first hurdle of running stationed.py successfully!

I've saved the script from page 1 of this thread to my pi inserting my username and password that i normally use to log on to the website to view the inverter data online and then run the script and get this.

Code: Select all

pi@raspberrypi2:~ $ python stationid.py
Traceback (most recent call last):
  File "stationid.py", line 29, in <module>
    token = root.find('token').text
AttributeError: 'NoneType' object has no attribute 'text'
Normally I log in to https://www.ginlongmonitoring.com and noted the script uses http:// but changing this gives the error below. Any suggestions to retrieve the station id please?

Code: Select all

pi@raspberrypi2:~ $ python stationid.py
Traceback (most recent call last):
  File "stationid.py", line 28, in <module>
    root = ET.parse(urllib.urlopen(requestURL)).getroot()
  File "/usr/lib/python2.7/urllib.py", line 87, in urlopen
    return opener.open(url)
  File "/usr/lib/python2.7/urllib.py", line 213, in open
    return getattr(self, name)(url)
  File "/usr/lib/python2.7/urllib.py", line 443, in open_https
    h.endheaders(data)
  File "/usr/lib/python2.7/httplib.py", line 1038, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 882, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 844, in send
    self.connect()
  File "/usr/lib/python2.7/httplib.py", line 1263, in connect
    server_hostname=server_hostname)
  File "/usr/lib/python2.7/ssl.py", line 363, in wrap_socket
    _context=self)
  File "/usr/lib/python2.7/ssl.py", line 611, in __init__
    self.do_handshake()
  File "/usr/lib/python2.7/ssl.py", line 840, in do_handshake
    self._sslobj.do_handshake()
IOError: [Errno socket error] [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:661)
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by Toulon7559 »

@StKilda

Sometimes small things make the difference:
what did you use for Username?
Must be the email-address with which you login to the website, NOT a choosen username!
And don't forget the '' around the inserted info!

Have adapted the py-script a bit to make that clear, incl. addition of line-numbers as aid for erro-trapping.

Code: Select all

#!/usr/bin/python

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

#config
username 			= '[email protected]' #your portal username [= email-address]
password 			= 'zzzzz' #your portal password
baseURL 			= 'http://www.ginlongmonitoring.com:10000' #base url
stationid 			= '<si>' #station id, get this via the station python script
# Working base urls:
#		http://www.ginlongmonitoring.com:10000/
#		http://www.omnikportal.com:10000/
#		http://log.trannergy.com:10000/
#		http://www.solarmanpv.com:10000/	
# Line 16
m = hashlib.md5()
m.update(password)

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

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

# Line 29
print 'Logged In: '+username

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

# Line 36
#login call
infoRoot = ET.parse(urllib.urlopen(infoURL)).getroot()
for elem in infoRoot.findall('power'):
    print "StationID: "+elem.find('stationID').text
Last edited by Toulon7559 on Saturday 03 November 2018 11:41, edited 1 time in total.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
StKilda
Posts: 5
Joined: Thursday 18 October 2018 18:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by StKilda »

thanks - although fairly sure I got that right. as I am using my email address and password within the quotes. I have noted that when logged into ginseng the url of the website is

https://www.ginlongmonitoring.com/Termi ... ?pid=12345

I am guessing 12345 (not the real numbers) is the station id?
StKilda
Posts: 5
Joined: Thursday 18 October 2018 18:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by StKilda »

ok so there is the text: As far as I can see it is as per your instruction: note my email address:

Code: Select all

#!/usr/bin/python

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


#config
username                        = '[email protected]' #your portal username
password                        = 'notmypassword' #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
this returns:

Code: Select all

pi@raspberrypi2:~ $ python stationid.py
Traceback (most recent call last):
  File "stationid.py", line 29, in <module>
    token = root.find('token').text
AttributeError: 'NoneType' object has no attribute 'text'
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by Toulon7559 »

Compared with my script-version you miss 1 line with definition of station-id.
Without that line 14 the script obviously misses data.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
arnaudarduino
Posts: 21
Joined: Wednesday 06 July 2016 22:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by arnaudarduino »

I do have the same error with this script.

Code: Select all

 #!/usr/bin/python
# --------------------------------------------------
# script compiled by Toulon7559 from various material from forums, 
# version 0.3 for download from Ginlong and upload to Domoticz and to PVOutput on same processor
# --------------------------------------------------
# Line 6
import urllib, urllib2, hashlib
from xml.etree import ElementTree as ET

#config                         <xx> = value or text to fill-in
username 			= '<[email protected]>' #your portal username
password 			= '<12ety>' #your portal password
baseURL 			= ' http://www.omnikportal.com:10000' #base url
stationid 			= '<31111>' #station id, get this via the station python script
# Line 15
# example: Working base urls:
#      http://www.ginlongmonitoring.com:10000/
#      http://www.omnikportal.com:10000/
#      http://log.trannergy.com:10000/
#      http://www.solarmanpv.com:10000/
# Line 21
#domoticz settings
domoticz_host      	= '192.168.2.18' # 127.0.0.1 is for local host
domoticz_port      	= '8080'
domoticz_url       	= 'json.htm'
domoticz_ActualPower   = '<31>' #idx of new device

# Line 28
m = hashlib.md5()
m.update(password)

# Line 32
#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

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

print 'Getting Info... '

# Line 47
#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)

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

# Line 70
#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)

# Line 75
# --------------------------------------------------
# END OF UPLOAD TO DOMOTICZ
# --------------------------------------------------

# Setting & Translation for values in next section
TEMPINV = 0
VOLTAGE = 0
POWER = ActualPower
LIFEENERGY = etotal1000   # Energy in Wh
multiply='1000.0'
etoday1000 = float(etoday) * float(multiply)
DAYENERGY = etoday1000  # Energy in Wh

# --------------------------------------------------
# START OF UPLOAD TO PVOUTPUT
# --------------------------------------------------
# Settings for PVOutput
pvout_enabled   = True
pvout_apikey    = "<3cf0000000000000000374edc1f83>"
pvout_sysid     = "<67773>"
pvout_cumflag   = 0   # flag is 1 if you apply lifetime-energy Wh_life / LIFEENERGY
                      # flag must be 0 if you upload day-energy Wh_today / DAYENERGY
                      
# Imports for script-operation

import datetime       # used for timestamps & timecheck
import subprocess
from time import strftime
import time

# Linking of parameters

SYSTEMID = pvout_sysid
APIKEY = pvout_apikey
t_date = format(strftime('%Y%m%d'))
t_time = format(strftime('%H:%M'))
Wh_life=LIFEENERGY
Wh_today=DAYENERGY
pv_temp=TEMPINV
pv_volts=VOLTAGE
pv_power=POWER
if pvout_cumflag == 1:
   Wh_upload=Wh_life
else:
   Wh_upload=Wh_today

Starthour = 4
Stophour = 22

# Determine Uploadtime

now = datetime.datetime.now()
print 'Upload-window PVO opens when start-hour =',Starthour
print 'Upload-window PVO closes after stop-hour=',Stophour
uploadtime = (now.hour >= Starthour) and (now.hour <= Stophour)
if uploadtime:
   print 'inside upload-window'
else:
   print 'outside upload-window'

# Determine Values & Compile for upload to PVOutput

if pvout_enabled and uploadtime:
   print 'uploading'
   pv_power=POWER
   pv_temp=TEMPINV
   pv_volts=VOLTAGE
   cum=pvout_cumflag
   cmd=('curl -d "d=%s" -d "t=%s" -d "v1=%s" -d "v2=%s" -d "v5=%s" -d "v6=%s" -d "v10=%s" -d "c1=%s" -H \
   "X-Pvoutput-Apikey: %s" -H \
   "X-Pvoutput-SystemId: %s" \
   http://pvoutput.org/service/r2/addstatus.jsp'\
   %(t_date, t_time, Wh_upload, pv_power, pv_temp, pv_volts, Wh_life, cum, \
   APIKEY, SYSTEMID))
   ret = subprocess.call(cmd, shell=True)

print
print '= Info for PVOutput ='
print 't_date %s' %t_date
print 't_time %s' %t_time
print 'pv_power %s' %pv_power
print 'Wh_today %s'%Wh_today 
print 'Wh_life %s' %Wh_life
print 'Wh_upload %s' %Wh_upload
print 'pv_temp %s' %pv_temp
print 'pv_volts %s' %pv_volts
# --------------------------------------------------
# END OF UPLOAD TO PVOUTPUT
# --------------------------------------------------
Traceback (most recent call last):
File "ginlong.py", line 38, in <module>
token = root.find('token').text
AttributeError: 'NoneType' object has no attribute 'text'

Has it something to do with Omnik wifi sn 0637000000
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by Toulon7559 »

@arnaudarduino

If username, password and stationid are correct, then the script should run.
On the other hand, for myself took quite some time before I solved the puzzle which info to insert how&where [for Ginlong]:
:-( the documentation is far from clear .............
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
atwonk
Posts: 1
Joined: Tuesday 29 January 2019 16:49
Target OS: Linux
Domoticz version: 4.9701
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by atwonk »

Hello all - found this topic while trying to pull data for my Solis (Ginlong) inverter.
It looks like there is a new ginlong monitoring website http://m.ginlong.com which is much nicer than the old www.ginlongmonitoring.com The new website provides JSON feeds of data, which is great for scraping and pushing to Domoticz / influx. There's also a mobile app called "Ginlong Home" which is quite nice too.

I had to re-register for the new website - there is an option to bring user accounts across, but it didnt work for me. Once I'd re-registered I had to add the serial number for my wifi stick (I did this through the mobile app, but may be possible through the website). About half an hour after i'd done that data from the old website had transferred over to the new website.

I'm not particularly familiar with python, so havent attempted to modify the code in this thread, but I have posted an example node-red flow that pulls the data:

https://flows.nodered.org/flow/1a1e2bac ... 930fe788f0

Effectively, the flow submits a POST to

Code: Select all

http://m.ginlong.com/cpro/login/validateLogin.json
including a few fields such as "userName"="yourusername", "password"="yourpassword", "lan"=2, "domain"="m.ginglong.com", "userType"="C"

This logs us in, and provides a session cookie which we need to pass on further calls

Next, POST to

Code: Select all

http://m.ginlong.com/cpro/epc/plantview/view/doPlantList.json
to retrieve a list of Plants -

Then, from the returned PlantData we use the plantID in the querystring to GET

Code: Select all

http://m.ginlong.com/cpro/epc/plantDevice/inverterListAjax.json?orderBy=updateDate&orderType=2&pageIndex=1&plantId=***PLANTID***&sequenceNum=9&showAddFlg=1
which returns a list of inverters - and from that we can POST to

Code: Select all

http://m.ginlong.com/cpro/device/inverter/goDetailAjax.json
including a form field of "deviceId" = ***our inverter ID***

Which will bring back a large set of data. I haven't explored this in detail, but there are readings for each input string, providing volts, amps and power - along with current output power, daily output power, monthly etc.

Hope this is helpful or useful to someone.
Thanks,
Andy
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by Toulon7559 »

Sure a new entry to Ginlong ready for exploration!

:-( Unfortunately myself not (yet) able to shift from portal1.0 to portal2.0
When trying the ' account-shift-function' at the new URL,then get the report
Sorry,system is too busy to get your account information
on the platform 2.0 in time,
please click "retry" to try again
or call our customer service directly
Platform 2.0 account information not obtained
Trying an alternative rout to Login or to Register (for a new account), the response for the Username is either 'Invalid Account' or ' Wrong username / password', dependent on the info inserted.
Also see stories that proper & fast response on the new portal is dependent on the applied browser.
Apparently the Portal2.0-software is far from foolproof ........

;-( No Ginlong Helpdesk, and the telephonenumber in China is not a real help:
not really Customer Support.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests