Custom Energy Management in Home Assistant using Huawei EMMA, Zendure Hyper and SQL Forecasts


Custom Energy Management in Home Assistant using Huawei EMMA, Zendure Hyper and SQL Forecasts

Hello everyone,

Over the last few months, I have been developing a custom energy management system in Home Assistant for my own photovoltaic installation.

The system combines a Huawei EMMA energy management system with three Zendure Hyper 2000 battery systems, a Shelly Pro 3EM for fast power measurements, and several independent PV forecast sources.

The goal was not simply to automate battery charging and discharging, but to build a stable control system that continuously adapts to changing conditions while keeping grid import and export as close to zero as possible.

Some of the implemented features include:

  • Dynamic power sharing between Huawei EMMA and Zendure Hyper
  • Automatic battery state-of-charge balancing
  • Fast power correction using a Shelly Pro 3EM
  • SQL-based PV production forecasts using historical production data
  • Self-learning correction factors for weather forecasts
  • Dynamic charging strategies based on PV forecasts, battery state of charge and electricity prices
  • Separate operating strategies for summer and winter
  • Automatic protection functions for different battery conditions
  • Comprehensive dashboards for monitoring, diagnostics and system analysis

One aspect that makes this project particularly interesting is that almost everything has been implemented using native Home Assistant features, including Template Sensors, Trigger-based Template Sensors, Automations, SQL Sensors and Dashboards.

ChatGPT was used as a development assistant throughout the project. It helped with Jinja templates, SQL queries, troubleshooting and evaluating different implementation ideas. However, every control algorithm was tested, validated and refined under real operating conditions before becoming part of the final system.

After many iterations and extensive real-world testing, the system now responds reliably to load changes within a few seconds while maintaining grid import and export at a very low level during normal operation.

If there is enough interest, I would be happy to share more details about the system architecture, the control logic, the SQL forecasting methods and selected Home Assistant templates used in the project.

I hope this project provides useful ideas and inspiration for others who are building advanced energy management solutions with Home Assistant.