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

Python and python framework

Moderator: leecollings

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 »

galadril wrote:Hmm lijkt erop dat de api url niet meer werkt voor Omnik Solar..
Do you think you get this working again??
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
underscore4
Posts: 20
Joined: Sunday 19 March 2017 22:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by underscore4 »

nwessels wrote:Hi,

@underscore4 or someone else: did you solved your problem? I have the same problem. like to hear your solution.

Grtz Niels
I let it working with setup:

#!/usr/bin/python

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


#config
username = 'username'' #your portal username
password = 'mypassword' #your portal password
baseURL = 'http://www.ginlongmonitoring.com' #base url
stationid = '1' #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 = '127.0.0.1'
domoticz_port = '8080'
domoticz_url = 'json.htm'
domoticz_ActualPower = 'Id on domoticz' #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)
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 »

mmm Will give this a try ...
Do i need crontab?
Just change the ip port
Replace the url:port? or where do you use the port? [ not in the example..
Station id part i do not understand..

Hope for your support
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
underscore4
Posts: 20
Joined: Sunday 19 March 2017 22:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by underscore4 »

here my answare:
Yes, please set crontab, i have every 5 minutes
It work with no port, probably it open directly and automatic.
station id, it's just in device, after description of harware of domoticz or you could use script (code shoud be on first page).
Let me know.
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 »

Sweet ;-) :D Let me try it as well.

Code: Select all

Getting Info...
TodayIncome: 6.918
ActualPower: 872.00
etoday: 30.08
etotal: 14534.0
etotal 1000: 14534000.0
Well if we are this far with the python script it should be possible to get it working as an official hardware plugin in domoticz right? :D
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.
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 »

Code: Select all

linaro@odroidxu4:~/domoticz/scripts/python$ ./SofarSolar.py
Traceback (most recent call last):
  File "./SofarSolar.py", line 34, 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 210, in open
    return self.open_unknown(fullurl, data)
  File "/usr/lib/python2.7/urllib.py", line 222, in open_unknown
    raise IOError, ('url error', 'unknown url type', type)
IOError: [Errno url error] unknown url type: 'www.solarmanpv.com'
linaro@odroidxu4:~/domoticz/scripts/python$

Still got errors....

Where do i go wrong.?
Did try this in the cli with manual activate.
Copy paste all script.
And change my locals..
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
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 »

Derik wrote:

Code: Select all

linaro@odroidxu4:~/domoticz/scripts/python$ ./SofarSolar.py
Traceback (most recent call last):
  File "./SofarSolar.py", line 34, 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 210, in open
    return self.open_unknown(fullurl, data)
  File "/usr/lib/python2.7/urllib.py", line 222, in open_unknown
    raise IOError, ('url error', 'unknown url type', type)
IOError: [Errno url error] unknown url type: 'www.solarmanpv.com'
linaro@odroidxu4:~/domoticz/scripts/python$

Still got errors....

Where do i go wrong.?
Did try this in the cli with manual activate.
Copy paste all script.
And change my locals..
Please post your full file please.
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.
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 »

Spoiler: show

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 = 'Changed' #your portal password
baseURL = 'www.solarmanpv.com/' #base url
stationid = '17608' #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 = '192.168.5.70'
domoticz_port = '8080'
domoticz_url = 'json.htm'
domoticz_ActualPower = '3905' #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)
Changed something... :-)

Ps:
Do i need to install some packages?
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
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 »

Mmm what happens if you change:

baseURL = 'www.solarmanpv.com/' #base url
to:
baseURL = 'http://www.solarmanpv.com' #base url
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.
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 »

I wanted to have the script working with python 3 so
Here we go: Stationid.py
Spoiler: show

Code: Select all

#!/usr/bin/python

import urllib, hashlib
from urllib.request import urlopen

from xml.etree import ElementTree as ET

#config
username          = '' #your portal username
password          = '' #your portal password
baseURL          = 'http://www.omnikportal.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.encode('utf-8'))

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

#login call
root = ET.parse(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(urlopen(infoURL)).getroot()
for elem in infoRoot.findall('power'):
    print ("StationID: "+elem.find('stationID').text)
And the other one:

Here we go: Omnik.py
Spoiler: show

Code: Select all

#!/usr/bin/python

import urllib, hashlib
from urllib.request import urlopen
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 = '127.0.0.1'
domoticz_port = '8080'
domoticz_url = 'json.htm'
domoticz_ActualPower = 'Id on domoticz' #idx of new device

m = hashlib.md5()
m.update(password.encode('utf-8'))
#building url
requestURL = baseURL+'/serverapi/?method=Login&username='+username+'&password='+m.hexdigest()+'&key=apitest&client=iPhone'

#login call
root = ET.parse(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(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=" + $
urlopen(url)
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.
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 »

sincze wrote:Mmm what happens if you change:

baseURL = 'www.solarmanpv.com/' #base url
to:
baseURL = 'http://www.solarmanpv.com' #base url

Thanks..
Looks this do the job: [ pvo has a problem on this moment ]
baseURL = 'http://www.solarmanpv.com:10000' #base url


What is the output in the log??
Is there a option to change this somewhere?
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
User avatar
galadril
Posts: 824
Joined: Monday 07 September 2015 10:32
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by galadril »

Should I change the script on the op?

Verstuurd vanaf mijn SM-T713 met Tapatalk
Solar panels of Ginlong, Omnik-Solar, Transenergy or Solarman?? Try my Android app:
https://play.google.com/store/apps/deta ... ongmonitor
underscore4
Posts: 20
Joined: Sunday 19 March 2017 22:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by underscore4 »

sincze wrote:
Derik wrote:

Code: Select all

linaro@odroidxu4:~/domoticz/scripts/python$ ./SofarSolar.py
Traceback (most recent call last):
  File "./SofarSolar.py", line 34, 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 210, in open
    return self.open_unknown(fullurl, data)
  File "/usr/lib/python2.7/urllib.py", line 222, in open_unknown
    raise IOError, ('url error', 'unknown url type', type)
IOError: [Errno url error] unknown url type: 'www.solarmanpv.com'
linaro@odroidxu4:~/domoticz/scripts/python$

Still got errors....

Where do i go wrong.?
Did try this in the cli with manual activate.
Copy paste all script.
And change my locals..
Please post your full file please.
I tried to look up about your error and i believe i have found the problem.
Well, system try to connect to the Ginlong or other manufactur cloud and download the data. I have tried to change the DNS using my internet provider default and after 2 days i got this error. Using back Google DNS or Open DNS i solved soon the problem again. Would you please try to take a look?
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 »

If you open:http://www.solarmanpv.com:10000/
Do you get:
solar.JPG
solar.JPG (31.96 KiB) Viewed 5903 times
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.
underscore4
Posts: 20
Joined: Sunday 19 March 2017 22:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by underscore4 »

Remove port 10000, you don't need to writ it.
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 »

devros wrote:hello, any chance to support this portal
im using invertor with limiter and USB-PLUG (witch is registred to this page)
http://www.shinemonitor.com/main.html
looks similar to omnik
tried restfull page http://www.shinemonitor.com:10000/
but number is propablly diferent.... any idea how to find right number?
thanks
Currently working on the Shinemonitor and able to retrieve the following data from their API.
Shinemonitor.JPG
Shinemonitor.JPG (68.95 KiB) Viewed 5699 times
I was able to retrieve the data using PHP and Python3.
Why Python3. well I'm trying to figure out how to build a native-domoticz plugin :D and that one seems to require Python3.
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.
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 »

wow you made my day :) thanks a lot
thats perfect news..., i did my own python sihinemonitor scraper, but is really buggy and works only for current watt. Can you share script that you already have? Im quite curios how did you managed to get json data.
Native domoticz plugin is not so important but would be also great.

BTW: Did you noticed, that shinemonitor.com have quite often conection problems (error 502) ?
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 »

devros wrote:wow you made my day :) thanks a lot
:D That was the idea.
devros wrote:thats perfect news..., i did my own python sihinemonitor scraper, but is really buggy and works only for current watt. Can you share script that you already have? Im quite curios how did you managed to get json data.
Native domoticz plugin is not so important but would be also great.
Well at the moment my script is in as-is fase meaning you need to enter a lot of values or login to the shinemonitor website to retrieve a few. The guy on the other side of the world is implementing http://api.shinemonitor.com, but he speaks Chineese.

Code: Select all

usr=''				#your username
pwd=''			#your password
companykey=''		#your companykey

# needed to retrieve data, can be obtained from portal
pn=''				#your plant id
sn=''				#your serial number
devros wrote: BTW: Did you noticed, that shinemonitor.com have quite often conection problems (error 502) ?
O yes I did, first I thought that it was me, but they are experiencing some problems and are working on it.
And now the piece you have been waiting for.
Spoiler: show

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))

#config
usr=''				#your username
pwd=''				#your password
companykey=''		#your companykey

# needed to retrieve data, can be obtained from portal
pn=''				#your plant id
sn=''				#your serial number
baseURL = '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
domoticz_host = '127.0.0.1'		#or the official IP adres
domoticz_port = '8080'			#domoticz port defaul 8080
domoticz_url = 'json.htm'
domoticz_ActualPower = '' 		#idx of virtual domoticz device 
domoticz_DCVoltage1 = '' 		#idx of virtual domoticz device 
domoticz_DCcurrent1 = '' 		#idx of virtual domoticz device 
domoticz_gridvoltageA = '' 		#idx of virtual domoticz device 
domoticz_gridcurrentA = '' 		#idx of virtual domoticz device 

#building url
salt=salt()						#we need a salt
action= '&action=auth&usr=' + usr + '&company-key=' + companykey
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+'/public/?sign='+ sign + '&salt=' + str(salt) + action

# Process results to variables
r = requests.get(solarurl)
#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=684&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= baseURL+'/public/?sign='+ sign + '&salt=' + str(salt) + '&token=' + token + '&action=queryDeviceLastData&i18n=en_US&pn=' + pn + '&devcode=684&devaddr=1&sn=' + sn


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

# pprint(r.json()) 							#Uncomment to see a nice output

ratepower= r.json()['dat'][9]['val']
ratevoltage= r.json()['dat'][10]['val']
todayenergy= r.json()['dat'][13]['val']
totalenergy= r.json()['dat'][14]['val']
activepower= r.json()['dat'][15]['val']
DCvoltage1= r.json()['dat'][16]['val']
DCvoltage2= r.json()['dat'][17]['val']
DCcurrent1= r.json()['dat'][18]['val']
DCcurrent2= r.json()['dat'][19]['val']
gridvoltageA= r.json()['dat'][20]['val']
gridcurrentA= r.json()['dat'][21]['val']
gridfrequency= r.json()['dat'][22]['val']
powerfactor= r.json()['dat'][23]['val']

multiply= 1000.1
etotalstr = str(float(totalenergy)*float(multiply))

#uploading values to domoticz
url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_ActualPower+ "&nvalue=0&svalue=" + activepower+ ";" + etotalstr)
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_DCcurrent1+ "&nvalue=0&svalue=" + DCcurrent1)
urlopen(url)
url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_gridvoltageA+ "&nvalue=0&svalue=" + gridvoltageA)
urlopen(url)
url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_gridcurrentA+ "&nvalue=0&svalue=" + gridcurrentA)
urlopen(url)

Let me know what you think. This code will not win 12 points in a contest however it can retrieve data :D .
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.
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 »

thanks all looks good but im litte lost where to find company number....
tried to fetch some json from my login page but cant, find that number

thanks
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 »

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.
Spoiler: show

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 time as time_             #make sure we don't override time

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

usr=''            		#your username
pwd=''           		#your password

# needed to retrieve data, can be obtained from portal
pn=''            		#your plant id 
sn=''            		#your serial number 
devcode=''			#your devcode, can be obtained from json string

baseURL = 'http://www.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
domoticz = 0						#set to 1 after IDx have been defined!
domoticz_host = '192.168.*.*'      	#or the official IP adres
domoticz_port = '8080'         		#domoticz port defaul 8080
domoticz_url = 'json.htm'
domoticz_ActualPower = ''       	#idx of virtual domoticz device 
domoticz_DCVoltage1 = ''       	#idx of virtual domoticz device 
domoticz_DCcurrent1 = ''       	#idx of virtual domoticz device 
domoticz_gridvoltageA = ''       	#idx of virtual domoticz device 
domoticz_gridcurrentA = ''       	#idx of virtual domoticz device 

#building url
salt=salt()                  		#we need a salt
print ('SALT:' + (str(salt)))
print ('SHA1:' + (str(passwd.hexdigest())))
action= '&action=authV2&user='+usr
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())
print ('CONECTION OK')
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.

action= '&action=queryDeviceLastData&i18n=en_US&pn=' + pn + '&devcode='+ devcode + '&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=' + devcode + '&devaddr=1&sn=' + sn
print (requrl)

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

pprint(r.json())                      #Uncomment to see a nice output

ratepower= r.json()['dat'][9]['val']
ratevoltage= r.json()['dat'][10]['val']
todayenergy= r.json()['dat'][13]['val']
totalenergy= r.json()['dat'][14]['val']
activepower= r.json()['dat'][15]['val']
DCvoltage1= r.json()['dat'][16]['val']
DCvoltage2= r.json()['dat'][17]['val']
DCcurrent1= r.json()['dat'][18]['val']
DCcurrent2= r.json()['dat'][19]['val']
gridvoltageA= r.json()['dat'][20]['val']
gridcurrentA= r.json()['dat'][21]['val']
gridfrequency= r.json()['dat'][22]['val']
powerfactor= r.json()['dat'][23]['val']

multiply= 1000.1
etotalstr = str(float(totalenergy)*float(multiply))

if domoticz == 1:
	print ('domoticz output')
	url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_ActualPower+ "&nvalue=0&svalue=" + activepower+ ";" + etotalstr)
	urlopen(url)
	print (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_DCcurrent1+ "&nvalue=0&svalue=" + DCcurrent1)
	urlopen(url)
	url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_gridvoltageA+ "&nvalue=0&svalue=" + gridvoltageA)
	urlopen(url)
	url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_gridcurrentA+ "&nvalue=0&svalue=" + gridcurrentA)
	urlopen(url)


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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest