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.19

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.19
File Size Uploaded
moat_ems_inv-0.2.19.tar.gz 58.5 kB Details

Built distribution (wheel)

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

Total release size: 87.7 kB

Release files / moat_ems_inv-0.2.19.tar.gz

Download URL moat_ems_inv-0.2.19.tar.gz
Size 58.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9710b4090b81ac2eec71e7b29c595299a488437f8e51d886808b957094724f11
BLAKE2b-256 checksum
How to use checksums
a82dd1d0b6bd7eea2efe2fde890994b49aea514a79e254f32a57d81e7a9227ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

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

Download URL moat_ems_inv-0.2.19-py3-none-any.whl
Size 29.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3cebc77aa8ff17071d24e0abc3365dc4d23a41e7cd5a48576fb5dea141423fe
BLAKE2b-256 checksum
How to use checksums
8133ba2358c47821fca70dab5c3ad284a5dc933b036b18b93c3ed69c67fbb8d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

0.2.19 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