Skip to main content

Victron Scripts

% start synopsis % start main

This repository attempts to establish a modern framework for talking to Victron Energy products, mainly via Dbus.

% end synopsis

Also included:

  • a modular program to control the charger/inverter.

  • a status monitor that emits a single line with the salient facts, every second.

  • a couple of patches that this author thinks are particularly helpful.

  • Integration with the twe_meter project, which adds support for several types of energy meter that Venus doesn't support out of the box.

  • Integration with the MoaT BMS, which (currently) uses diyBMS cell monitors, with a Rp2040 running MicroPython acting as the controller.

Rationale

The original Victron code uses synchronous Python and manages its tasks et al. with GLib. Its documentation warns in multiple places that GLib likes to swallow errors and might leave the system in an inconsistent state; it even includes a helper that, on error, directly kills the program, circumventing the SystemExit exception Python normally uses for this.

This is way beyond ugly, in this author's opinion. To be sure, there were no good alternatives at the time it was written, but that's no excuse to keep doing it.

This library thus replaces the whole thing with an async library based on anyio and asyncdbus. Usage is a bit different, of course, but there are several advantages:

  • no more swallowing of errors. Ever.

  • you can write fallback code, or leave-the-system-in-a-safe-state-when-you-die code, that actually has a chance of running when conditions warrant.

  • you can write multi-step control loops with timeouts and whatnot which don't depend on timer callbacks and related unsafe nonsense, yet can be cleanly switched off and replaced without terminating your controller.

  • etc.

% end main

Modules

The modules victron.dbus and victron.dbus.monitor are suitably modified, if not rewritten, copies of /opt/victronenergy/dbus-systemcalc-py/ext/velib-python.

Battery Management

A submodule of this archive implements a Battery Management System ("BMS").

Random stuff

Notes

Critical Settings

  • com.victronenergy.settings /Settings/CGwacs/OvervoltageFeedIn

needs to be zero. This can happen when you play with your settings, as some combination of changes appears to set this value but doesn't bother to clear it.

The idea of this parameter is that an external program will increase feed-out when the battery is at its charge limit, thus reducing solar input is not necessary.

Unfortunately there is no safeguard if that feed-out should ever not work (too much sun, AC inverter overheated, grid offline, …).

The result of this being set is that DVCC always sets solar power to max and won't reduce it even if the battery becomes overloaded. This is obviously a very bad idea.

Confing file examples

The files named '24 are used on a small test system (24V, 10Ah, Multiplus 24/500), with 80 Wp solar input.

The others are in use on a "production" 48V, 280Ah, 3-phase Multiplus II 5000 system with 11 kWp of solar arrays.

The BMS code in bus/python controls both sets of batteries.

Metadata

Release files for moat-ems-inv 0.2.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moat-ems-inv 0.2.20
File Size Uploaded
moat_ems_inv-0.2.20.tar.gz 58.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for moat-ems-inv 0.2.20
File Interpreter ABI Platform
moat_ems_inv-0.2.20-py3-none-any.whl Python 3 none any Details

Total release size: 87.8 kB

Release files / moat_ems_inv-0.2.20.tar.gz

Download URL moat_ems_inv-0.2.20.tar.gz
Size 58.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9bd5a6ad121c7dac2603c86b7cc7ec481c8f4fdb4e1ebf586d00186fd57402c2
BLAKE2b-256 checksum
How to use checksums
78cf3c68ddb6b7fdf6c5bc325fa82cc48d475c42ee596ed24fd6267d8b91dabb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / moat_ems_inv-0.2.20-py3-none-any.whl

Download URL moat_ems_inv-0.2.20-py3-none-any.whl
Size 29.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f1910969c76f6665c59ea0f8c6439c0c30678e2e059b017aa2d0740f3f45cf5
BLAKE2b-256 checksum
How to use checksums
1b69417169dc416e4deebb6636356ea8e5a1c21de03b6850af87e7da67162445
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release history Release notifications | RSS feed

This release

0.2.20 This release

2 release files

0.2.15

2 release files

0.2.13

2 release files

0.2.11

2 release files

0.2.10

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page