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

Python and python framework

Moderator: leecollings

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 »

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.
Brammetje
Posts: 6
Joined: Tuesday 17 October 2017 10:07
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post 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 4678 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.
Brammetje
Posts: 6
Joined: Tuesday 17 October 2017 10:07
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by Brammetje »

Oh maybe it's handy to know that i'm running domoticz v3.8153 from Jadalh on a synology DS1515+.
User avatar
sincze
Posts: 1300
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 »

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

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.
Gizmo2000
Posts: 10
Joined: Sunday 16 April 2017 11:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: NL
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post 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
Brammetje
Posts: 6
Joined: Tuesday 17 October 2017 10:07
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by Brammetje »

Did it stop with the both off you at around 13:00?
Gizmo2000
Posts: 10
Joined: Sunday 16 April 2017 11:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: NL
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by Gizmo2000 »

Around 13:00

But at this moment it's working again ;)
User avatar
sincze
Posts: 1300
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 »

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 4635 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.
User avatar
hansonexperience
Posts: 12
Joined: Thursday 19 October 2017 14:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: the Netherlands
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post 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?
Solar: pvoutput, solarman, JFY inverter, enelogic, slimmemeterportal, Greenchoice
Weather: Davis VUE ISS, meteobridge wunderground, Asus WL -330N3G, leuven template
Website: http://www.hansonexperience.com / http://www.mooiweerboxtel.nl
User avatar
sincze
Posts: 1300
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 »

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..
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
hansonexperience
Posts: 12
Joined: Thursday 19 October 2017 14:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: the Netherlands
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post 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?
Solar: pvoutput, solarman, JFY inverter, enelogic, slimmemeterportal, Greenchoice
Weather: Davis VUE ISS, meteobridge wunderground, Asus WL -330N3G, leuven template
Website: http://www.hansonexperience.com / http://www.mooiweerboxtel.nl
User avatar
sincze
Posts: 1300
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 »

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.
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
hansonexperience
Posts: 12
Joined: Thursday 19 October 2017 14:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: the Netherlands
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by hansonexperience »

Oké. Thx! How do the scripts know which version to use?
Solar: pvoutput, solarman, JFY inverter, enelogic, slimmemeterportal, Greenchoice
Weather: Davis VUE ISS, meteobridge wunderground, Asus WL -330N3G, leuven template
Website: http://www.hansonexperience.com / http://www.mooiweerboxtel.nl
User avatar
sincze
Posts: 1300
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 »

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>
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.
Brammetje
Posts: 6
Joined: Tuesday 17 October 2017 10:07
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post 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
User avatar
sincze
Posts: 1300
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 I still have data and yesterday as well until 18.30 (when it was dark)

Sent from my SM-G925F using Tapatalk

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
hansonexperience
Posts: 12
Joined: Thursday 19 October 2017 14:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: the Netherlands
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post 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.
Solar: pvoutput, solarman, JFY inverter, enelogic, slimmemeterportal, Greenchoice
Weather: Davis VUE ISS, meteobridge wunderground, Asus WL -330N3G, leuven template
Website: http://www.hansonexperience.com / http://www.mooiweerboxtel.nl
User avatar
sincze
Posts: 1300
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 »

no output? I don't have solarman myself . so can not confirm.
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.
chamsters
Posts: 4
Joined: Monday 13 November 2017 13:00
Target OS: Windows
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post 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?
blup
Posts: 1
Joined: Saturday 06 January 2018 13:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

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

Who is online

Users browsing this forum: No registered users and 1 guest