Skip to content

arrow1800/Victron-VirtualBattery

Repository files navigation

Victron virtual battery

this is a dbus service for the Victron venus OS. It is a virtual battery that doesn't do anything besides being available as a real battery in the venus OS. The rest of the logic is implemented with node-red and therefor easily changeable. This is the only way to make sure that Venus OS and all its connected devices will honor the settings and information that this battery produces.

The idea behind this is that when you have a virtual battery available in Venus OS it can be configured as the default battery. after that you are able to write any combination of data to it from any device (multiplusses, one or more BMS'es, smartshunts, etc.). When the information is stored in the virtual battery Venus OS will take care of the rest (making sure all chargers/devices receive the correct information and behave accordingly)

You can write data to the virtual battery using node-red with the Venus OS Large image.

screenshot of virtual battery in venus os screenshot of virtual battery in venus os

Node-red

node-red gives you the option to read/extract information from all kinds of devices available on the dbus or from anywhere else. That information can be transformed/aggregated in any form and can be used to execute several actions (such as writing the right information to the virtual battery). A few ideas:

  • Use cell voltages read from one or more specific BMS'es that you are using
  • Use SOC readings from a victron smartshunt (higher accuracy)
  • Use Amps reading from the multiplus itself, a specific BMS or a smartshunt
  • Any of the above in a combined way

This way you have full control over how and which information flows through the system. You are also able to create your own logic rules with node-red, such as;

  • When one cell voltage is to high, lower max charge current
  • When one cell voltage is to low, lower discharge current
  • When temp is to high or to low, disable ...
  • When SOC is between 80 a 90%, set charge current to..
  • When season is winter; maintain a specific SOC, when season is summer don't.
  • Change max charge voltage to a higher value when SOC is above 95% for a fixed amount of time
  • Etc.

Example flow

see file exampleflow.json you can copy the contents to node-red and import it all at once.

important! -> node-red uses this addons for the exampleflow. you can install them yourself through the node-red menu -> manage palette -> install

  • node-red-contrib-modbus
  • node-red-contrib-pid

screenshot of node-red flow

How to - CerboGX

Installation:

  • create /data/dbus-virtual-battery directory
  • copy files to this folder
  • chmod a+x /data/dbus-virtual-battery/install.sh
  • ./data/dbus-virtual-battery/install.sh

The service now starts automatically after a start/restart of the Venus OS

Architecture

virtual battery architecture

Reading data

Reading data is done from within node-red. the most easiest way is using the default blue victron module nodes.

Sending data

As can be seen in the architecture image. The virtual battery driver subsribes to the MQTT virtualbattery topic, any data that it receives on that topic will be processed. Node-red polls all the devices (smartshunt, bmsés, etc) and creates a dictionary that is being published to the same MQTT topic.

Changing data

All properties (soc, voltage, etc) are stored in flow variables and used later on to construct a dictionary that is is published on the MQTT topic.

setting other max discharge values for example can be done by changing the current function blocks that are connected to the 'every second trigger' or just add new ones. make sure the result always ends up in one of the following flow variable names:

'Soc'
'Current'
'Voltage'
'Power'
'MinCellTemperature' -> not fully implemented yet, still needs work in node-red
'MaxCellTemperature' -> not fully implemented yet, still needs work in node-red
'MaxChargeCurrent'
'MaxDischargeCurrent'
'MaxChargeVoltage'
'MaxCellVoltage'
'MinCellVoltage'

Defaults

All default values can be changed from within the node-red ui.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published