Dual Battery Automation in Home Assistant (Part 2) - du.nkel.dev
du.nkel.dev
Marstek Venus E v2.0 vs v3.0
UI-managed Parameters
Wear-Leveling Role Switch
Season Profiles
Multi-Battery Automation
1. Reducing Oscillation
2. Sunrise Projection
3. Waterfall 2.0
4. "Wake-Up Kick" Requirement
Dashboard Upgrade
Energy Dashboard
100% Autarky?
Grafana Charts
1. Charging Phase
2. Night Discharge, Waterfall
3. Morning Transition
Configuration Files
Conclusion
Dual Battery Automation in Home Assistant (Part 2)
Published: 2026-08-15<br>Revised: 2026-08-15
TL;DR
This is part two of my Mastek Battery Automation project with Home Assistant. I added a second battery, improved parameter handling in the Home Assistant GUI and overhauled the automation & balancing script for (almost) zero grid export. It works better than ever. I wish I could continue working on this project, but there really is not much more to do, because it is perfect! I used a header picture of an open pit coal mine I took in 2008 near my home town. Here is still hope that this centralized and polluting period of humanity will come to an end soon.
Motivation<br>This was the most fun endeavor I had in my homelab since its start in 2019: The Battery Automation with Home Assistant. How it finally turned out was quite different to my expectations. First, I thought creating the automation logic would be much more simple (but less interesting). I realized there are a lot more edges to it. Individual context, PV solar size, home energy consumption patterns (etc.), all of these parameters affect automation design. But then, addressing these was straightforward and not complicated at all! No external Python scripts, just plain YAML-Jinja script that runs directly in HASS. The tricky part was organizing it systematically, adding all the sensors with a reproducible and documented naming scheme, integrating Grafana-Reporting, or InfluxDB long-term data storage, and reducing verbose activity logs.
I purchased the first battery at the start of 2026 (about 1100€), a Marstek Venus E v2. In April, the v3 was available at 850€. From an economic perspective, a second battery was not strictly necessary. My first battery already brought me 80% through the night and had an astronomical estimation of 278 cycles per year (extrapolated from 6 months of use). But it feels so fulfilling to not buy any electricity from the grid provider! When batteries are so cheap, this was a no-brainer. The payback period for a single Venus E at this price is about 4 years. A second battery would just increase this to 5 years.
The only thing left to do was update my 1-battery-automation script to two batteries. You may ask: Why custom automate batteries at all? Shouldn't we trust corporate algorithms that are much better than any custom, homemade Home Assistant automation? Trust me, this is not the case. And (likely) never will be. Every household is different. If you have a massive 30kWp solar array but only 5kWh of storage, your charging strategy looks different than someone with a 5kWp array and a 20kWh battery. Manufacturers provide a single, generic (often "black box") algorithm that is optimized for average use cases. There will never be a perfectly matching default algorithm for your specific heating, server rack base-load, or roof orientation.
This was the outset for my battery automation in HASS. Part two introduces a dual-battery automation script. I will keep this blog post a little bit more high-level, by describing the underlying arguments for my parameter decisions or algorithm details, rather than the raw-technical implementation. I consider this now as a tailored HEMS that can be easily adapted to individual needs. Whether I add a third Marstek Battery Venus E Max (10 kWh) or replace one of my existing two, after 10 years, with another vendor's AC battery, I expect this script to survive the next decade.
Language Disclaimer
This post contains a mixture of German and English because I am too lazy to translate languages back and forth. I wanted my other family members to read my Home Assistant dashboards in their native language (German). Home Assistant has a peculiarity that if you give entities a name, it will ignore the entity id and generate a slug from the name, which is used from then on as a reference in scripts (etc.). It is not straightforward to clean these naming IDs without introducing subtle bugs, so I left this mixture as is. Feel free to adapt to your needs.
Marstek Venus E v2.0 vs v3.0#
While physically similar, the internal architecture changed significantly. The primary difference is that no more RS485-to-Ethernet bridge (like the Waveshare I used for v2.0) is needed. The v3.0 has a native LAN port. The v3.0 also uses completely new Modbus registers. For example, SOC is no longer 32104, but 37005. Find the mappings in my git repository links at the end.
32104 and 37005 return the same value<br>During testing, I discovered that the old 32104...