Better Understanding of Automations- Venus OS

Afternoon all,

I have recently built my own battery storage system, I have solar pv on the roof and a home energy monitoring system (emontx). I am using s Victron Colour control GX running Venus OS to monitor and control my battery system.

I have added the modbus tcp to config ymal and I tested it by addressing some of the registers and all works well. I can tell it to stop invertering and charge and vice versa.

To gain absolute control over the battery system I will need to run whats called ‘external control’ This is where the user (me) implement his own control loop in the Energy Storage System app. Mode 3 is external control of your inverter/charger. I am looking to do this. The understanding is simple but im unsure how to write the code for this. Basically when I am generating solar from my pv say 1000W and my house load is 200w. This would mean I would be exporting 800W to grid. I would like to write a analog script/ control loop that mathmatically calculates how much to charge/discharge.

I have a CT on my incoming cable to my house that is all calibrated so I know exactly how much i am importing/exporting. and is updated every 10secs. I can you this as a input to drive the output adressess via modbus.

What would you say is the best code/ example to do this. Modbus register 37 is ESS power setpoint phase 1 and has a scaling factor of -32668 to 32668.

As the example above if I was exporting 800W the modbus my input would be -800 so I would need to write +800 to this address to tell it to charge. Victron use this formula below.

Power to/from AC-input = Power to/from battery + Power to/from AC-output

Any help would be much apprecicated.

Thanks

Gareth

Hey i wish i could help but i assume you managed to find a solution, im integrating my multiplus into HA and you mentioned you managed to write to the modbus and switch inveter from inverter/charger only, Could you tell me how you setup the switch ?

Hi Robin,

With switching the to inverter/charger only, you sound like you are wanting to run your mutliplus in mode 2?

To set up two switches one for enabling/disabling charger and another for enabling/disabling the inverter your code will need to look like this in your config yaml.

modbus:
name: victron
type: tcp
host: IP ADDRESS OF YOUR VENUS DEVICE
port: 502
switches:
- name: enable_inverter
slave: 100
address: 2704
command_on: 100
command_off: 0
- name: enable_charger
slave: 100
address: 2705
command_on: 20
command_off: 0

Command_on for modbus regiser 2705 is your max charge current. My multiplus is set to 20A. You will need to set this to what you want it to be. WARNING- if this need to be lower then decrease this otherwise you could damage you batteries/system.

Hope this helps :slight_smile:

Cheers

Gareth

Thanks Gareth re the current limits do you know how you could create a slider instead of a binary switch ?

That code will generate them like this.

image

cheers

Gareth