PLEASE NOTE: If you had an account with the previous forum, it has been ported to the new Genetry website!
You will need to reset the password to access the new forum. Click Log In → Forgot Password → enter your username or forum email address → click Email Reset Link.

Notifications
Clear all

Victron GX Integration

24 Posts
6 Users
0 Likes
702 Views
(@notmario)
Reputable Member
Joined: 3 years ago
Posts: 314
Topic starter  

I wrote a module to create a GenetrySolar Inverter device on Victron's GX units.

image.png.2bd516075f4bcfdb37a9784813b925e0.png

As it is, the product has infrastructure to do modbus, so i've used that for now.
As the GS doesn't have modbus support yet, this means that a proxy is needed to map the status.js to the modbus space.

The genetrysolar.py file goes in /opt/victronenergy/dbus-modbus-client
You have to add an import clause for it [after the one for smappee] in the dbus-modbus-client.py file in that same directory. (Unfortunately, they didn't make it pick it up automatically)

The gsproxy.py can run anywhere. But you have to point your GX unit to it as a Modbus TCP device. It is invoked as: ./gsproxy.py <port> <fakeserial>
Important to note that the proxy is only a simulator right now. I am not able to use my unit to test out the actual mapping from a real inverter. The code is trivial, so someone here could probably modify it before i get my equipment in order.

Naturally, the ideal case would be for the GS to support Modbus natively - or for Victron to make infrastructure for JSON devices.
I wasn't going to try and write that infrastructure for Victron. I wouldn't want the additional UI work so you could add a "json device".


   
Quote
(@sid-genetry-solar)
Member Admin
Joined: 4 years ago
Posts: 2883
 

By "supporting MODBUS natively", I presume you are referring to MODBUS TCP?  Or are you referring to a hardwired MODBUS serial connection?


   
ReplyQuote
(@notmario)
Reputable Member
Joined: 3 years ago
Posts: 314
Topic starter  

Yes - though i believe the only difference is how the data is transceived.

Though there's no reason it couldn't also be done with rs232. Just that you already have Wifi support, might as well use it for SCADA.


   
ReplyQuote
(@notmario)
Reputable Member
Joined: 3 years ago
Posts: 314
Topic starter  

Might i get a stats.json file from a running inverter? Ideally with a few descriptors thrown in.

I can get all the mapping done in the proxy ahead of time.


   
ReplyQuote
(@sid-genetry-solar)
Member Admin
Joined: 4 years ago
Posts: 2883
 

A "stats.json" is attached here, from a test bench inverter running 1.2r0.  No loads, no thermistors, but most of the info should be pretty easy to determine from the tagnames.


   
ReplyQuote
(@notmario)
Reputable Member
Joined: 3 years ago
Posts: 314
Topic starter  

A working version of the proxy is attached...

Invoked as:
# ./gsproxy.py <bindip> <port> <stats.json url>
EG...
# ./gsproxy.py 0.0.0.0 5021 http://192.168.1.101/stats.json

There's a pretty good chance the polarity of some fields might be backwards. We'll find out later and i'll update it so.
Anyone else got a Victron GX, or am i the only one that cares? lol


   
ReplyQuote
(@notmario)
Reputable Member
Joined: 3 years ago
Posts: 314
Topic starter  

Alright... so here's a much cleaner version that doesn't rely on their modbus infrastructure, which incidentally also makes exposing temperatures and fan values a lot easier.

Exposes AC-Input/Output Information
Exposes DC Information, however, it calculates the DC amps assuming 100% efficiency - DC Amps are not exposed in JSON file.
Exposes highest probe temperature. Exposing all of them is probably too much...
Allows changing charge modes, though i've explicitly disabled turning inverter mode off.

Invoked as so:
# /opt/gs/gsdevice.py http://<inverterip>

It must be run on the GX device itself. This requires a rooted GX. Install it, and create an @reboot crontab for it.

 


   
ReplyQuote
(@notmario)
Reputable Member
Joined: 3 years ago
Posts: 314
Topic starter  

Went ahead and added alarm support and a few other fixes...

Cleaned up some mode switching... Off, On, and Charge-Only are all passthru modes - No Charge, Float Charge, and Bulk Charge, respectively. Inverter-Only is actual inverter mode. Victron's modes aren't exactly 1:1 with the GS, and the UI isn't versatile enough to enable me to customize the options without modifying the UI code.

If Sid adds grid-tie or "power-assist" functionality, that will be what "On" sets the inverter to.


   
ReplyQuote
(@notmario)
Reputable Member
Joined: 3 years ago
Posts: 314
Topic starter  

... And a version that utilizes atomic DBUS updates... Mainly to reduce spamming the bus...

Some small updates that pave the way for additional functionality.


   
ReplyQuote
(@inphase)
Estimable Member
Joined: 4 years ago
Posts: 159
 

I'm following but I don't have any equipment yet. I figured I'd just use some Victron ET112 meters to monitor the inverter output on the Cerbo. Is there an advantage to writing the module like you did?


   
ReplyQuote
(@notmario)
Reputable Member
Joined: 3 years ago
Posts: 314
Topic starter  

Less equipment, plus direct control of the GS.

My first attempt at this actually used the GS data to mimic 2 Meter devices. (sort of the programmatic version of what you intend to do) The UI didn't really work properly with both an input and output meter. Plus it doesn't work very well with a distinct DC system. ("Has DC system" config option) Victron's smart shunts have an Inverter DC Load option, but it doesn't play well with the UI. (The feature is still kinda incomplete)
It might work better with the meters if you don't have the "Has DC System" option turned on. But i have a distinct DC system, so i must have it on to monitor my DC equipment.

IMO, Victron's GX system leaves much to be desired. If you're not working with hardware they specifically support, it doesn't really work quite right. So, this module adds explicit support for the GS.

The big negative to this approach is that it's custom code that requires root access - fortunately, this is hardly the first example of this, and is directly supported by their community.


   
ReplyQuote
(@inphase)
Estimable Member
Joined: 4 years ago
Posts: 159
 

Since I posted about the ET112, I learned that it won't work anyway. For one, the meters would only read 240 or 120 volts, but not 120/240 split phase. Besides that, they are intended to be used in conjunction with a Victron inverter. So your module will be the way to go. I really like the look of the GX interface. There's nothing else on the market that I have found that is as clean and configurable.


   
ReplyQuote
(@notmario)
Reputable Member
Joined: 3 years ago
Posts: 314
Topic starter  

Yeah, they really have a bit of a monopoly on a decent consumer-grade monitoring system.

Here's the GX's Node-Red feature set up to programatically control the GS. Charges when batt gets very low or close to freezing. Will switch to inverter mode when enough solar to take the full load demand, and back to passthrough when the sun goes down. Sky's the limit.

<fileStore.core_Attachment>/monthly_2022_10/Screenshot_2022-10-26_02-32-30.png.803ebf328f07459be2e8c2a496549b3e.png


   
ReplyQuote
(@inphase)
Estimable Member
Joined: 4 years ago
Posts: 159
 

Since I don't yet have the equipment, I'll ask you is it possible use it with more than one battery? My intended use case is two batteries feeding two inverters each. Basically two independent systems. Can the single Cerbo GX monitor them both? I think it can, but that's far from conclusive.


   
ReplyQuote
(@notmario)
Reputable Member
Joined: 3 years ago
Posts: 314
Topic starter  

Officially, no. One GX per independent system.

Unofficially... you can add as many Shunts as the physical hardware will let you. They will be visible in the Menu screen.
However, the pretty graphical system will only display one of them.

This particular module i made for this page would need a slight modification to be run more than once (once for each inverter). That's a trivial change, just haven't done it yet


   
ReplyQuote
Page 1 / 2