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

Python and python framework

Moderator: leecollings

Storic
Posts: 5
Joined: Friday 26 April 2019 9:23
Target OS: Windows
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by Storic »

Hi,

Have been using this script for a while, but suddenly it has stopped working.

Code: Select all

File "C:\inverter\solarmanpv.pyw", line 38
    print 'Logged In: '+username
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Logged In: '+username)?
Anyone have any idea what can be the problem? I'm not so familiar using scripts.
Storic
Posts: 5
Joined: Friday 26 April 2019 9:23
Target OS: Windows
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by Storic »

Seams it was a problem with upgrading to python 3.7
Have now downgraded again, but now I get this error:

Code: Select all

C:\Users\John Martin>c:\python27\python.exe "C:\Program Files (x86)\scripts\solarmanpv.pyw"
Traceback (most recent call last):
  File "C:\Program Files (x86)\scripts\solarmanpv.pyw", line 35, in <module>
    root = ET.parse(urllib.urlopen(requestURL)).getroot()
  File "c:\python27\lib\urllib.py", line 87, in urlopen
    return opener.open(url)
  File "c:\python27\lib\urllib.py", line 215, in open
    return getattr(self, name)(url)
  File "c:\python27\lib\urllib.py", line 352, in open_http
    h.endheaders(data)
  File "c:\python27\lib\httplib.py", line 1065, in endheaders
    self._send_output(message_body)
  File "c:\python27\lib\httplib.py", line 892, in _send_output
    self.send(msg)
  File "c:\python27\lib\httplib.py", line 854, in send
    self.connect()
  File "c:\python27\lib\httplib.py", line 831, in connect
    self.timeout, self.source_address)
  File "c:\python27\lib\socket.py", line 575, in create_connection
    raise err
IOError: [Errno socket error] [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Anyone know what the fault can be?
Any help is very mush appreciated! :)
RoyT
Posts: 16
Joined: Wednesday 02 December 2015 19:30
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by RoyT »

After some failed attempts to get data sent to "Server B" on my Ginlong inverter, I've resorted to a very simple PHP script that runs on a Raspberry Pi (same one as Domoticz runs on). It's executed via cron every minute. It takes data from the local status page on the logger, and sends that to a dummy kWh Meter I created in Domoticz. This adds the current power, and today's total.

So far, it's works very well. Only downside is that Domoticz shows e.g. 9W at night, because that was the last known value before the device shut off. It's easy though to add some code that sends 0 values between sunset and sunrise, as PHP can calculate those times based on geolocation. Right now, I'm not too bothered by it (the totals are still fine, because I've set the device to use "Energy read: from device").

The script uses a built-in PHP function to do an HTTP GET, so there are no dependencies on CURL or any other library besides the default PHP installation.

Code: Select all

<?php

// Fetch HTML source of the status page on the logger stick (replace `username:password` and `ip`)
$html = @file_get_contents('http://admin:[email protected]/status.html');

// Only continue if there was a response (e.g. not at night when the device shuts itself off)
if ($html)
{
  // Use a regular expression to find the needed data on the page
  preg_match_all('/var (.*) = "(.*)"/', $html, $matches, PREG_PATTERN_ORDER);

  // Build an array of all found data, where keys are the variables used on the status page
  $data = [];

  foreach ($matches[1] AS $key => $value)
  {
    $data[$value] = $matches[2][$key];
  }

  // Check if current W (`webdata_now_p`) and today's total (`webdata_today_e`) are set
  // Also check if `webdata_now_p` is a numerical value greater than 1 (I've seen the status page return a blank value once or twice a day)
  if (isset($data['webdata_now_p']) && isset($data['webdata_today_e']) && is_numeric($data['webdata_now_p']) && $data['webdata_now_p'] > 0)
  {
    // Make a request to Domoticz to add to the graph (replace `ip:port` and `idx`)
    // Multiply toay's total by 1000, because Domoticz expects Wh instead of kWh
    file_get_contents('http://10.0.0.12:8080/json.htm?type=command&param=udevice&idx=282&nvalue=0&svalue='.$data['webdata_now_p'].';'.$data['webdata_today_e']*1000);
  }
}

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

Maybe create a plug-in for that by using the OMNIK plug-in as template??
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.
flexx
Posts: 6
Joined: Tuesday 21 April 2020 17:13
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by flexx »

RoyT wrote: Thursday 02 April 2020 7:48 After some failed attempts to get data sent to "Server B" on my Ginlong inverter, I've resorted to a very simple PHP script that runs on a Raspberry Pi (same one as Domoticz runs on). It's executed via cron every minute. It takes data from the local status page on the logger, and sends that to a dummy kWh Meter I created in Domoticz. This adds the current power, and today's total.
I'm struggling with receiving data from my Ginlong Solis as well and this seems to be a very straightforwarded approach.
However, I want to run this from a synology NAS. I'm completly new to PHP but I assume I need to install some PHP version on the NAS. Currenlty it has PHP 5.6 as package installed. PHP 7 / 7.2 and 7.3 are also available. Do you now which version your script requires?

What type of sensor do you used:usage(electric) or electric(Instant+Counter), other?

Furthermore, I'm not into PHP scripting but is it possible to set the value to 0 when the first check if the device is powered on failes?
The check is already there and is stead of not proceeding with the script if the device is turned of (= no sun) it shoud be easy to output a steady value to domoticz in stead of the scraped web value. Maybe this is an easy adjustment?
vosjxvos
Posts: 1
Joined: Wednesday 29 April 2020 10:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by vosjxvos »

devros wrote: Monday 03 September 2018 21:57
sabiwa wrote: Thursday 30 August 2018 22:23
devros wrote: Thursday 17 August 2017 8:45

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 ?

hello, afaik they changed something in url here is my latest dirty working code :)
Thanks @devros for this old example code. I am now able to fetch 5 minute data from shinemonitor.com for my 3 Deye micro inverters and feed into Domoticz!

Anybody succeeded to fetch the inverter data locally from the RS485 modbus of a Deye ECD?
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 »

Really wondering why apparently for a Ginlong inverter nobody is able to activate&apply the interface towards Server_B.
True, or missing something?
Last edited by Toulon7559 on Monday 17 August 2020 14:29, 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.
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 »

I've build an Android/iOS app for getting Ginlong, Trannergy and Solarman data

Apple:
https://apps.apple.com/nl/app/solar-ene ... 1517272630

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

Any ideas?
Solar panels of Ginlong, Omnik-Solar, Transenergy or Solarman?? Try my Android app:
https://play.google.com/store/apps/deta ... ongmonitor
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 »

At this moment the local logging for my Ginlong Solis700_4G inverter is still limited to basis info for power & energy as grasped from their monitoring website by a script from this thread.
However, for fully feeding a related registration at PVOutput and/or locally, it would be nice to have some more inverter-internal info such as VPV and Invertertemp from the datastream running between the inverter and Server_B_option: earlier trial :( without success .....
Update (of June 2020) of the used reading program for Server_B found at https://github.com/graham0/ginlong-wifi
[the User Instructions are now much clearer, but in the scripts most changes seem editorial only related to print-lines & comment-lines]
Instructions for setup are clear
#Configuring the inverter Log onto your inverter and click on 'Advanced' Now click 'Remote server' Enter a new ip address for 'Server B' (your computer) enter a port number (default 9999) select 'TCP' Click the 'Test' button and a tick should appear. Click 'Save' and and when prompted 'Restart'
Although slightly ambiguous that TCP is a selection hidden under menu-item Solarman-Customer, and (probably?) not menu-item Transparant Protocol.

;-) That invites to retry .......
To start easy, my Ginlong Inverter and the related Raspberry/Server_B are in same IP-range 192.168.0.x
At the Inverter-side set Server_B at 192.168.0.185, no Domain, port 9999 and TCP (with other choices at unchanged 'default')
Loaded the script from github and ran unchanged, teststarting from Putty's CLI (let the script do the IP-search).
Result: nothing but steady cursor
Then minimally changed the python script to point to IP-address '192.168.0.185'.
Result: same as above.

In both cases at the inverterside Server_B is indicated as pingable.
That seems sign that connection made, but no further progress .......

Graham in the introductory text is clear in indicating that error reporting is not included, which means that headscratching is still my part .....

Any hints appreciated to enable starting the data stream.

Addition August 26:
Running the (only renamed) script from Putty's CLI with sudo python3 generates a reaction!

Code: Select all

  File "/home/pi/domoticz/scripts/python/Ginlong_Reader00_RPI3B.py", line 88
    temp = str(float(int(hexdata[inverter_temp*2:inverter_temp*2+4],16))/10)   # temperature                                                                   # extract dc input values and convert to decimal
                                                                                                                                                            ^
TabError: inconsistent use of tabs and spaces in indentation
;-) At least signs of life seeming to indicate that communication is running and now the dissect is next hurdle ....

After the experiment today, in Graham's script after line 80 stripped all empty lines, and the spaces and commentlines at the end of the scriptlines, but no luck/ progress: still same results whether run with sudo python or with sudo python3 .....

Apparently some more editing required: if only knowing what ........
Last edited by Toulon7559 on Tuesday 21 September 2021 12:34, edited 11 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.
nwessels
Posts: 2
Joined: Wednesday 07 June 2017 21:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by nwessels »

RoyT wrote: Thursday 02 April 2020 7:48 After some failed attempts to get data sent to "Server B" on my Ginlong inverter, I've resorted to a very simple PHP script that runs on a Raspberry Pi (same one as Domoticz runs on). It's executed via cron every minute. It takes data from the local status page on the logger, and sends that to a dummy kWh Meter I created in Domoticz. This adds the current power, and today's total.

So far, it's works very well. Only downside is that Domoticz shows e.g. 9W at night, because that was the last known value before the device shut off. It's easy though to add some code that sends 0 values between sunset and sunrise, as PHP can calculate those times based on geolocation. Right now, I'm not too bothered by it (the totals are still fine, because I've set the device to use "Energy read: from device").

The script uses a built-in PHP function to do an HTTP GET, so there are no dependencies on CURL or any other library besides the default PHP installation.

Code: Select all

<?php

// Fetch HTML source of the status page on the logger stick (replace `username:password` and `ip`)
$html = @file_get_contents('http://admin:[email protected]/status.html');

// Only continue if there was a response (e.g. not at night when the device shuts itself off)
if ($html)
{
  // Use a regular expression to find the needed data on the page
  preg_match_all('/var (.*) = "(.*)"/', $html, $matches, PREG_PATTERN_ORDER);

  // Build an array of all found data, where keys are the variables used on the status page
  $data = [];

  foreach ($matches[1] AS $key => $value)
  {
    $data[$value] = $matches[2][$key];
  }

  // Check if current W (`webdata_now_p`) and today's total (`webdata_today_e`) are set
  // Also check if `webdata_now_p` is a numerical value greater than 1 (I've seen the status page return a blank value once or twice a day)
  if (isset($data['webdata_now_p']) && isset($data['webdata_today_e']) && is_numeric($data['webdata_now_p']) && $data['webdata_now_p'] > 0)
  {
    // Make a request to Domoticz to add to the graph (replace `ip:port` and `idx`)
    // Multiply toay's total by 1000, because Domoticz expects Wh instead of kWh
    file_get_contents('http://10.0.0.12:8080/json.htm?type=command&param=udevice&idx=282&nvalue=0&svalue='.$data['webdata_now_p'].';'.$data['webdata_today_e']*1000);
  }
}

?>
Hi all,

i get a cron error:(CRON) info (No MTA installed, discarding output)

any idees?

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

Just received, let's update the thread to see how this goes.

Notification of Omnik platform closure

Dear Users,

As Omnik has been in the liquidation procedure and is not able to pay for the maintenance fees for servers, we are sorry to inform you that this platform will be closed at the end of April. All services including Open API, APP and data forwarding will not be available after the platform is closed. All data saved on current servers will be deleted after the shutdown.

If you wish to continue the monitoring service, you could switch to SOLARMAN platform based on new servers. Data at Omnik platform will be migrated to SOLARMAN servers from 9 a.m. on 19th April, 2021 (UTC+8). Please notice that any operation on Omnik platform from that time will not be synchronized to SOLARMAN platform.

The overall migration process will take about 72 hours. In order to ensure the data integrity and accuracy, please DO NOT modify any data on Omnik platform during this period. If you need to register new accounts during the migration, please log in to SOLARMAN platform (For end-users, please log in https://home.solarmanpv.com; for installers and distributors, please log in https://pro.solarmanpv.com).

You could log in SOLARMAN platform using your current account and password. SOLARMAN will provide three-month free trial for your Omnik devices. During this period, you will be able to use all functions.

SOLARMAN Smart (https://home.solarmanpv.com) is designed for end-users. With new visual experience, user-friendly data display, and well-established monitoring function, SOLARMAN Smart makes smart energy management easier for everyone.

Sorry for the inconvenience and we are looking forward to providing better service for you in the future.

Please feel free to contact us for any questions via [email protected]. For more information and FAQs, please click the 'Service' button on the right side of the following page: https://www.solarman.cn/enservice.html

If you do not wish to migrate your data to the new servers, please contact us for account cancellation.
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
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by waltervl »

I have seen this message a year ago too and at that time it kept working...
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
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 »

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.
I used this script for a while now and it worked perfectly until a week or so. It seems that the www.shinemonitor.com/ws part is not working anymore. I have tried to find out how to work with the api but I get stuck on the company-key so no avail there. Would love your insights to see how I can get it working again.

Thanks Sabi
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 it seems my unit is now part of Solarman.
Solarman.png
Solarman.png (158.1 KiB) Viewed 5489 times
The old environment is also supplying me data so not dead yet.
old-sit.jpg
old-sit.jpg (95.92 KiB) Viewed 5489 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
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by waltervl »

I still have a working omnik portal website. I get my data directly from the Omnik inverter so no need for a web portal. But it would be nice if it keeps working... :-)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
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 »

waltervl wrote: Wednesday 21 April 2021 20:02 I still have a working omnik portal website. I get my data directly from the Omnik inverter so no need for a web portal. But it would be nice if it keeps working... :-)
Yes I've the same (local read-out), however if you monitor for other people that don't have Domoticz ;-) it will become a different ball game in the near future.
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.
jotheman
Posts: 4
Joined: Sunday 23 May 2021 22:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ginlong, Omnik Solar, Solarman and Trannergy Inverters

Post by jotheman »

Okay, I have recently gotten solar panels as well and have been wrestling with the read-outs. It's a Solis inverter (Ginlong) with a LAN-interface that automatically uploads its statistics to the portal page at m.ginlong.com. I use the mobile app called "Solis Home", so if you use that as well, there's a good chance you can use my read-out method in a similar way.

I have been searching a lot on how to get the statistics in Domoticz. I've seen a lot of information and topics of people approaching this in various ways, some with success, others without any. This is how I approached it, hopefully some of you can use this. I am deliberately crossposting to make sure people that need this or are looking for it find it somewhere.

The approach:
- Make sure you can log in to m.ginglong.com and have the/a username and password available
- In Domoticz, create Dummy hardware with 2 sensors attached to it: 1 for the usage (in watts), which will show how many watts your PV is producing, 1 switch, which will show the status of your PV (on or off). For me, this looks like this:
Image
- Next, put the Python-script below (called ginlong.py in my case) on your Domoticz-device and make sure Python is available on the system.
Make sure you update the parameters under #config and #domoticz settings:

Code: Select all

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

#config
username 			= '[email protected]'				#your username to log on to m.ginlong.com
password 			= 'P@ssw0rd!'				#your password to log on to m.ginlong.com
domain 				= 'm.ginlong.com' 			#webportal to read
plantId 			= '965529' 					#plant id (can be found on m.ginlong.com page information)
lan 				= '2' 						#language (2 = English)

#domoticz settings
domoticz_host      		= 'domoticzuser:[email protected]'				#Username/password and IP of Domoticz
domoticz_port      		= '8080'				#Port to connect to Domoticz
domoticz_url       		= 'json.htm'			#URL to post stats to Domoticz, does not require changes normally
domoticz_device_idx    		= '486'			#IDX of Watt meter in Domoticz
domoticz_device_onoff_idx   	= '485'			#IDX of on/off switch (to see whether its on or off for PV)

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

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

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

# Get plant details
url = 'http://m.ginlong.com/cpro/epc/plantview/view/doPlantList.json'

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

# Uncomment lines below to write the exported json-file to the location noted
#out_file = open("/usr/local/bin/ZPExport.json", "w")
#json.dump(resultJson, out_file, indent = 6)
#out_file.close()

ActualPower = resultJson['result']['pagination']['data'][0].get('curPower')
ActualPowerNoSep = str(ActualPower).split(".")[0]
etoday = resultJson['result']['pagination']['data'][0].get('energyToday')
multiply='1000.0'
etotal1000 = float(etoday) * float(multiply)
etotalstr=str(etotal1000)
etotalstrNoSep = str(etotalstr).split(".")[0]
OnOrOff = resultJson['result']['pagination']['data'][0].get('status')

#logging values
print 'ActualPower: ' + str(ActualPowerNoSep)
print 'etoday: ' + str(etotalstrNoSep)
print 'Status: ' + str(OnOrOff)

#uploading values to domoticz
url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_device_idx+ "&nvalue=0&svalue=" + str(ActualPowerNoSep))
urlonoff = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_device_onoff_idx+ "&nvalue=" + str(OnOrOff))
urllib.urlopen(url)
urllib.urlopen(urlonoff)
- Make the script executable using command

Code: Select all

sudo chmod +x ginlong.py
while you are in the directory that contains the script. Due to a lack of knowledge I always do a

Code: Select all

[sudo chmod 777 ginlong.py/code] as well to make sure all users can use it. I'm sure it's not needed or a security-thing, but let's just say ignorance is bliss ;)
- Run the script once on the device and make you see output on the commandline.
I start the script using command:
[code]sudo /usr/bin/python /usr/local/bin/ginlong.py
Getting output? Great! Most likely you first values are also visible on your newly created Domoticz-devices as well, yay! Treat yourself to a beer at this point!
- Next, create anóther switch in Domoticz (by simply creating one using the Manual option, with random settings). Edit the switch and make it a "Push On" button. In the "On action" and "Off action", put the script location so it is started whenever the button is triggered. For me, this looks like this:
Image
When using the configuration above (so: "script://ginlong.sh"), you are assuming that the script is located in the scripts folder under the Domoticz installation folder. If that's not the case, change the path (google or search the forum on how to incorporate the path)
- Press the update-knop (so the device you just created) and make sure the values are updated
- And here comes the clue: Running the script once every X-minutes. Note that I am no Linux-Raspbian expert and I couldn't get it to work using a crontab-job (just as well though, as I now have everything in Domoticz, which I prefer). Putting a timer on the switch did not allow running the task (pressing the button) often enough and I was wrestling errors in Domoticz whilst trying to get it up and running, eventuelly I ended up using a dzVents script. The script looks like this (basically saying, press the button every 5 minutes):

Code: Select all

 return {
        
    on = { timer = {"every 5 minutes"} },
    
	execute = function(domoticz, _)
		local myDevice = domoticz.devices("Zonnepanelen Update")
		if myDevice.state == "On" then
			myDevice.switchOn()
		else
			myDevice.switchOn()
		end
	end		
}
I'm sure that there's a better way to do this but again: for me ignorance is bliss and I adhere to "if it ain't broken don't fix it" (lazy, jep!) ;)
That ought to do it!

Disclaimers and more detailed info:
- I am no programmer, developer or whatever, just a hobbyist. Had to "learn" a bit (more) Python and JSON but I am no expert. So: No warranties, and I'm sure it lacks efficiency etc. Knock yourself out on improvements :)
- I am only reading the current usage/production and the status. The status can have various values I found (0 = off, 1 = on, 2 something else?), but the switch only understands 0 and 1, when it's 2 it shows "Dimmed". Not sure what other statusses other than 0 and 1 mean, enlighten me if you figured it out :)
- In the JSON I am retrieving there's more values that might be interesting and that can be used for calculations. I couldn't figure it out quickly and had accomplished my goal so this is it for me. Feel free to venture onward!
- This is it for me, I've accomplished the goal I wanted to achieve, so I won't be updating and advancing the functionality. Knock yourself out doing so :)
- Credits for large parts of the scripting go to the people that had already created this before me, I just modded a bit!

Hopefully this helps the people that were running into the same questions/issues I was. I'm happy about it (and kind of proud as well, gotta be honest ;)). The end result looks like this:
Image
And now I'm done typing. My fingers are sore... ;)
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 »

It seems Omnik is officially down now. (no data from the webportal anymore, of course local reading of your inverter still possible)

The data is available in Solarman https://home.solarmanpv.com/login.
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.
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 »

Many of the previous messages tell stories about (non-working) webportals and the limitation of data available at the webportals.

It retriggers interest for the Ginlong/Solis-inverter for the puzzle to set & get communication with 'own' Server_B for local data-extraction of the whole & much longer dataset (as mentioned in a few messages in this thread).
If reading this message, it could be that not all firmware-versions well support that Server_B-function, explaining the lack of success to connect to Server_B.
The quoted message describes a work-around directly interacting with the inverter-datastream.
In combination with solutions already found in this forum, it must be possible to get a working solution which directly extracts the whole dataset from the datastream, and ;) suitable for dummies.

:) Might be interesting to investigate now the evenings get longer, in preparation for next PV-season ......
Still First step: what is simplest way for compatible settting of a Server_B, to get working interface between inverter and Server_B, and as finish how to extract the data for Domoticz?
Backup Second step (if 'First step' completely fails): how to translate the quoted message into a Domoticz-application?

Addition September21, 2021:
Tried the work-around mentioned above, but no luck, because

Code: Select all

<LAN Stick IP>/config_hide.html
(with inverter-ip included) as Firefox-result just has an error report telling that the interface has been re-initiated.
Last edited by Toulon7559 on Tuesday 21 September 2021 11:16, edited 6 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.
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 »

Tried earlier to activate traffic through Ginlong's Server_B-function:
see first attempt and second attempt.

The demise of Omnik's server just one more reason to retry the First Step from previous message getting an 'own' operational interface from my Ginlong/Solis-inverter to a Server_B.

Plan of attack

Further effort aimed in 2 directions:
1) which port of the inverter&DLS is providing an useful output-file for local application at the LAN?
2) how to match an extraction script?

In the description below try to describe as much as possible the relevant aspects:
some may seem trivial, but have learned the hard way that sometimes 'small thing' are important (especially :x is wrongly applied)

At my LAN, both inverter and Server-Raspberry are within same ip-range 192.168.0.x
According to messages&instructions the Python-script in the first spoiler should run for TCP and port set at 9999 in inverter and in the script, and then produce files covering the complete list of uploaded inverter-values, but no luck for me:
at Putty's CLI the script still throwing blanks or errors .....
[Did not yet try the bash-variant of that script]

:idea: Would FTP-interface better work?
At the inverter-setuppage for the destination-ip set the port to 21 => interface for Server_B becoming Pingable for all protocols looks positive.
Now next question: where at destination-ip to find & get the incoming files?
[Server_B/Destination-ip is a Raspberry running Raspian-Buster & beta-Domoticz & VSFTPD]

And subsequent question: how to link to the script in the spoiler?
Spoiler: show
#!/usr/bin/python

###################################################################################################
#
# Copyright 2015 Graham Whiteside, Manchester, UK. Version 0.4 Jun 2020.
#
# read-ginlong is free software: you can redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# read-ginlong is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You can browse the GNU license here: <http://www.gnu.org/licenses/>.
#
###################################################################################################

###################################################################################################
#
# Python program to read data sent from a single Ginlong/Solis 2G inverter equipped with a
# Wi-Fi 'stick'.
#
# Requires setting up the inverter stick to send data to the computer running the read-ginlong
# script. Settings located in the advanced settings, then remote server. Add a new 'remote
# server' with the ip address of your computer and port 9999. The inverter will send data every
# five minutes.
#
# Output file format (space separated):-
# Date Time Watts_now Day_kWh Total_kWh
#
# Output of webserver file, format (space separated) file overwritten each update:-
# Date Time Watts_now Day_kWh Total_kWh DC_volts_1 DC_amps_1 DC_volts_2 DC_amps_2 AC_volts AC_amps AC_freq kwh_yesterday kwh_month kwh_last_month
#
# The read-ginlong.py program is deliberately left simple without error reporting. It is intended
# as a 'starting point' and proof of concept. It could easily be modified to provide more
# information from the inverter. Furthermore the output log file can be further processed or
# loaded into other software such as LibreOffice Calc.
#
###################################################################################################
# Line 41
import socket, binascii, time

# Line 44
# change these values to suit your requirements:-
HOST = '' # Hostname or ip address of interface, leave ''/blank for all
PORT = 9999 # listening on port 9999
logfile = 'ginlong.log' # location of output log file
webfile = 'ginlong.status' # location of web file

# Line 51
# inverter values found (so far) all big endian 16 bit unsigned:-
header = '685951b0' # hex stream header
data_size = 206 # hex stream size
inverter_temp = 31 # offset 31 & 32 temperature (/10)
inverter_vdc1 = 33 # offset 33 & 34 DC volts chain 1 (/10)
inverter_vdc2 = 35 # offset 35 & 36 DC volts chain 2 (/10)
inverter_adc1 = 39 # offset 39 & 40 DC amps chain 1 (/10)
inverter_adc2 = 41 # offset 41 & 42 DC amps chain 2 (/10)
inverter_aac = 45 # offset 45 & 46 AC output amps (/10)
inverter_vac = 51 # offset 51 & 52 AC output volts (/10)
inverter_freq = 57 # offset 57 & 58 AC frequency (/100)
inverter_now = 59 # offset 59 & 60 currant generation Watts
inverter_yes = 67 # offset 67 & 68 yesterday kwh (/100)
inverter_day = 69 # offset 69 & 70 daily kWh (/100)
inverter_tot = 71 # offset 71 & 72 & 73 & 74 total kWh (/10)
inverter_mth = 87 # offset 87 & 88 total kWh for month
inverter_lmth = 91 # offset 91 & 92 total kWh for last month

# Line 70
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # create socket on required port
sock.bind((HOST, PORT))

# Line 74
while True: # loop forever
sock.listen(1) # listen on port
conn, addr = sock.accept() # wait for inverter connection
rawdata = conn.recv(1000) # read incoming data
hexdata = binascii.hexlify(rawdata) # convert data to hex

if(hexdata[0:8] == header and len(hexdata) == data_size): # check for valid data

# extract main values and convert to decimal
watt_now = str(int(hexdata[inverter_now*2:inverter_now*2+4],16)) # generating power in watts
kwh_day = str(float(int(hexdata[inverter_day*2:inverter_day*2+4],16))/100) # running total kwh for day
kwh_total = str(int(hexdata[inverter_tot*2:inverter_tot*2+8],16)/10) # running total kwh from installation

temp = str(float(int(hexdata[inverter_temp*2:inverter_temp*2+4],16))/10) # temperature # extract dc input values and convert to decimal
dc_volts1= str(float(int(hexdata[inverter_vdc1*2:inverter_vdc1*2+4],16))/10) # input dc volts from chain 1
dc_volts2= str(float(int(hexdata[inverter_vdc2*2:inverter_vdc2*2+4],16))/10) # input dc volts from chain 2
dc_amps1 = str(float(int(hexdata[inverter_adc1*2:inverter_adc1*2+4],16))/10) # input dc amps from chain 1
dc_amps2 = str(float(int(hexdata[inverter_adc2*2:inverter_adc2*2+4],16))/10) # input dc amps from chain 2

# extract other ac values and convert to decimal
ac_volts = str(float(int(hexdata[inverter_vac*2:inverter_vac*2+4],16))/10) # output ac volts
ac_amps = str(float(int(hexdata[inverter_aac*2:inverter_aac*2+4],16))/10) # output ac amps
ac_freq = str(float(int(hexdata[inverter_freq*2:inverter_freq*2+4],16))/100) # output ac frequency hertz

# extract other historical values and convert to decimal
kwh_yesterday = str(float(int(hexdata[inverter_yes*2:inverter_yes*2+4],16))/100) # yesterday's kwh
kwh_month = str(int(hexdata[inverter_mth*2:inverter_mth*2+4],16)) # running total kwh for month
kwh_lastmonth = str(int(hexdata[inverter_lmth*2:inverter_lmth*2+4],16)) # running total kwh for last month


timestamp = (time.strftime("%F %H:%M")) # get date time

log = open(logfile,'a') # write data to logfile, main values only
log.write(timestamp + ' ' + watt_now + ' ' + kwh_day + ' ' + kwh_total + '\n')
log.close()

web = open(webfile,'w') # output all values, possibly for webpage
web.write(timestamp + ' ' + watt_now + ' ' + kwh_day + ' ' + kwh_total + ' ' + dc_volts1 + ' ' + dc_amps1 + ' ' + dc_volts2 + ' ' + dc_amps2 + ' ' + ac_volts + ' ' + ac_amps + ' ' + ac_freq + ' ' + kwh_yesterday + ' ' + kwh_month + ' ' + kwh_lastmonth + ' ' + temp + '\n')
web.close()

conn.close()
If only changing in scriptline 47 the port to 21, then error reports as shown in the spoiler below ( :( very familiar from second attempt),
for running at Server_B from Putty's CLI respectively with python2.7 or with python3.x
Spoiler: show
pi@Domoticz2:~ $ sudo python3 /home/pi/domoticz/scripts/python/Ginlong_Reader0021_RPI3B.py
File "/home/pi/domoticz/scripts/python/Ginlong_Reader0021_RPI3B.py", line 88
temp = str(float(int(hexdata[inverter_temp*2:inverter_temp*2+4],16))/10) # temperature # extract dc input values and convert to decimal
^
TabError: inconsistent use of tabs and spaces in indentation

pi@Domoticz2:~ $ sudo python /home/pi/domoticz/scripts/python/Ginlong_Reader0021_RPI3B.py
Traceback (most recent call last):
File "/home/pi/domoticz/scripts/python/Ginlong_Reader0021_RPI3B.py", line 72, in <module>
sock.bind((HOST, PORT))
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use
IP & Port-scanning

Computer performing the scanning is in same ip-range as the DLS, but connected to other ethernet-switch.
Advanced IP-Scanner only shows the http-port of the DLS' ip-address.
Ran netcat at Server_B scanning the inverter-ports:
looking at result apparently inverter's port 8899 is open, not port 9999 as set in the inverter_menu for Server_B.
Next at Server_B ran

Code: Select all

nc -l localhost 8899  > log.txt                                
but only an empty line at Putty's CLI, and nowhere a file named log.txt
Wireshark-'fiddling' yet without results.
Puzzles ......

Also ran at Server_B the script set for port 8899 with command-layout for python2.7:
like for port=9999, no error reports on the CLI, but also no other responses ......

Conclusion/Result

:( It almost looks as if my DLS's firmware ME-121001-V1.0.6(201704012008), at webpage showing Ver1.0.1,
has none of the functions supporting Server_B and neither the reported inverter's hidden config_menu at http://<ip_address>/config_hide.html.....
Remote Upgrade of the firmware is failing.

Help requested/appreciated:
a) Anybody with experience with application of the bash-variant of the script?

[How to position&run this bash-file for test and for 'normal' use?]
b) Where to find any files expected to arrive at Server_B through port 9999 (or 21, or ....)?
[Which folders to monitor?]
c) (For the 'spoiler-script') how to get rid at Server_B's CLI of the blank lines and/or the reported errors?
d) Any other 'unknown' urls which might work at the Ginlong_DLS's <ip_address>?
[To retrieve any hidden info]
Last edited by Toulon7559 on Friday 24 September 2021 11:10, edited 7 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest