Page 4 of 12

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Thursday 17 August 2017 8:45
by devros
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.

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Tuesday 17 October 2017 10:23
by Brammetje
Hello,

I have used this script for over 2 months now for to locations i want to monitor.
But it suddenly stopped working with the following error.
Screen Shot 2017-10-17 at 10.21.01.png
Screen Shot 2017-10-17 at 10.21.01.png (180.1 KiB) Viewed 4681 times
Traceback (most recent call last):
File "/volume1/public/OmnikAmerongen.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 364, in open_http
return self.http_error(url, fp, errcode, errmsg, headers)
File "/usr/lib/python2.7/urllib.py", line 377, in http_error
result = method(url, fp, errcode, errmsg, headers)
File "/usr/lib/python2.7/urllib.py", line 642, in http_error_302
headers, data)
File "/usr/lib/python2.7/urllib.py", line 669, in redirect_internal
return self.open(newurl)
File "/usr/lib/python2.7/urllib.py", line 213, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 350, in open_http
h.endheaders(data)
File "/usr/lib/python2.7/httplib.py", line 1100, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 931, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 893, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 870, in connect
self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py", line 575, in create_connection
raise err
IOError: [Errno socket error] [Errno 110] Connection timed out
Did something changed in de omnik api?

This is my file (without the login).
#!/usr/bin/python

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


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

#domoticz settings
domoticz_host = '192.168.170.5'
domoticz_port = '8084'
domoticz_url = 'json.htm'
domoticz_ActualPower = '148' #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)

url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=153&nvalue=0&svalue=" + etoday)
urllib.urlopen(url)
I hope if somebody can help me out repairing this and let it be awesome again.

Many thanks.

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Tuesday 17 October 2017 10:29
by Brammetje
Oh maybe it's handy to know that i'm running domoticz v3.8153 from Jadalh on a synology DS1515+.

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Tuesday 17 October 2017 20:07
by sincze
Brammetje wrote:Oh maybe it's handy to know that i'm running domoticz v3.8153 from Jadalh on a synology DS1515+.
Same issue here with 3 Omnik inverters.

Same domoticz version on my raspberry. (don't think that is the problem) I will have to look into it as well. Not home at the moment. Iogged in to omnik portal today and my data is available over there. Fingers crossed we fix the problem.

Sent from my SM-G925F using Tapatalk


Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Tuesday 17 October 2017 21:04
by Gizmo2000
sincze wrote: Tuesday 17 October 2017 20:07
Brammetje wrote:Oh maybe it's handy to know that i'm running domoticz v3.8153 from Jadalh on a synology DS1515+.
Same issue here with 3 Omnik inverters.

Same domoticz version on my raspberry. (don't think that is the problem) I will have to look into it as well. Not home at the moment. Iogged in to omnik portal today and my data is available over there. Fingers crossed we fix the problem.

Sent from my SM-G925F using Tapatalk
Same problem here.
Stopped working 14-10

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Wednesday 18 October 2017 20:26
by Brammetje
Did it stop with the both off you at around 13:00?

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Thursday 19 October 2017 10:33
by Gizmo2000
Around 13:00

But at this moment it's working again ;)

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Thursday 19 October 2017 13:50
by sincze
Gizmo2000 wrote: Thursday 19 October 2017 10:33 Around 13:00

But at this moment it's working again ;)
Indeed ;-) it is working again. :D :lol:
Service Restored
Service Restored
Omnik.JPG (33.54 KiB) Viewed 4638 times

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Thursday 19 October 2017 14:29
by hansonexperience
Installed the scripts, but got errors on both files.
I use solarmanportal

stationid.py gives this error:

Code: Select all

File "/home/pi/domoticz/scripts/stationid.py", line 4, in <module>
    from urllib.request import urlopen
ImportError: No module named request
Solarman.py gives:

Code: Select all

File "/home/pi/domoticz/scripts/solarman.py", line 34, in <module>
    root = ET.parse(urllib.urlopen(requestURL)).getroot()
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1182, in parse
    tree.parse(source, parser)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 657, in parse
    self._root = parser.close()
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1654, in close
    self._raiseerror(v)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: no element found: line 1, column 0
Please can someone help me out?

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Thursday 19 October 2017 19:17
by sincze
hansonexperience wrote: Thursday 19 October 2017 14:29 Installed the scripts, but got errors on both files.
I use solarmanportal

stationid.py gives this error:

Code: Select all

File "/home/pi/domoticz/scripts/stationid.py", line 4, in <module>
    from urllib.request import urlopen
ImportError: No module named request
Solarman.py gives:

Code: Select all

File "/home/pi/domoticz/scripts/solarman.py", line 34, in <module>
    root = ET.parse(urllib.urlopen(requestURL)).getroot()
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1182, in parse
    tree.parse(source, parser)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 657, in parse
    self._root = parser.close()
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1654, in close
    self._raiseerror(v)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: no element found: line 1, column 0
Please can someone help me out?
Mmm "Installed the scripts", the scripts for python2 or python3.
I guess python3 and you are using python2 to execute them.
Why .. well as the python2 script for stationid. says:

Code: Select all

import urllib, urllib2, hashlib
from xml.etree import ElementTree as ET
and not (this is python3 code):

Code: Select all

import urllib, hashlib
from urllib.request import urlopen
from xml.etree import ElementTree as ET
Where your error seems to come from and which will result into an error when executed with python2.7

Code: Select all

Traceback (most recent call last):
  File "test_stationid3.py", line 4, in <module>
    from urllib.request import urlopen
ImportError: No module named request
So I would say install python3 :D to solve your issue..

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Thursday 19 October 2017 19:45
by hansonexperience
sincze wrote: Thursday 19 October 2017 19:17
hansonexperience wrote: Thursday 19 October 2017 14:29 Installed the scripts, but got errors on both files.
I use solarmanportal

stationid.py gives this error:

Code: Select all

File "/home/pi/domoticz/scripts/stationid.py", line 4, in <module>
 from urllib.request import urlopen
ImportError: No module named request
Solarman.py gives:

Code: Select all

File "/home/pi/domoticz/scripts/solarman.py", line 34, in <module>
 root = ET.parse(urllib.urlopen(requestURL)).getroot()
 File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1182, in parse
 tree.parse(source, parser)
 File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 657, in parse
 self._root = parser.close()
 File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1654, in close
 self._raiseerror(v)
 File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror
 raise err
xml.etree.ElementTree.ParseError: no element found: line 1, column 0
Please can someone help me out?
Mmm "Installed the scripts", the scripts for python2 or python3.
I guess python3 and you are using python2 to execute them.
Why .. well as the python2 script for stationid. says:

Code: Select all

import urllib, urllib2, hashlib
from xml.etree import ElementTree as ET
and not (this is python3 code):

Code: Select all

import urllib, hashlib
from urllib.request import urlopen
from xml.etree import ElementTree as ET
Where your error seems to come from and which will result into an error when executed with python2.7

Code: Select all

Traceback (most recent call last):
 File "test_stationid3.py", line 4, in <module>
 from urllib.request import urlopen
ImportError: No module named request
So I would say install python3 :D to solve your issue..
Thx. I am a newbie to python. I am using domoticz for my energycounters.
I do not know if python 3 would do any harm so I am a bit worried in installing version 3.
But how will these 2 scripts look like when written for python 2?

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Thursday 19 October 2017 21:55
by sincze
No worries python3 and 2.7 can run side by side (because they each have their own directory).
I know because I wrote python3 scripts and have 2.7 installed as well.

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Friday 20 October 2017 8:38
by hansonexperience
Oké. Thx! How do the scripts know which version to use?

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Friday 20 October 2017 10:55
by sincze
well actually the scripts don't know.
you have to know.

call a v2.7 python script with: python27 <script.name>
and a v3 python script with: python3 <script.name>

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Wednesday 25 October 2017 7:26
by Brammetje
Gizmo2000 wrote: Thursday 19 October 2017 10:33 Around 13:00

But at this moment it's working again ;)
It was happely working again until yesterday 13:55

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Wednesday 25 October 2017 8:11
by sincze
Mmm I still have data and yesterday as well until 18.30 (when it was dark)

Sent from my SM-G925F using Tapatalk


Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Thursday 26 October 2017 18:10
by hansonexperience
sincze wrote: Friday 20 October 2017 10:55 well actually the scripts don't know.
you have to know.

call a v2.7 python script with: python27 <script.name>
and a v3 python script with: python3 <script.name>
I installed python 3 but the scripts do not work for solarman.

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Thursday 26 October 2017 22:22
by sincze
no output? I don't have solarman myself . so can not confirm.

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Tuesday 28 November 2017 15:12
by chamsters
Erwinvos72 wrote: Friday 30 September 2016 10:46 Is there already a possibility to read the values from a Solax-X inverter in Domoticz? I have tried it with the base settings in the stationid.py but i receive errors when i run the script about http.
Hey - did you have any luck with solax?

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Posted: Wednesday 10 January 2018 16:11
by blup
What type of virtual sensor do I need to create? Because the energy sensor type in the example in the first post is not present when I add a virtual sensor. I have now added a virtual sensor of type "General KWH" (Electric instant + counter) and I do get data in this sensor