Smart Home Energy Management System (EMS)

November 12, 2025 | 7 min read

Background

The Home Energy Management System (HEMS or Home EMS) is a component of my custom-built home automation project. It acts as a living testbed for smart energy control, real-time analytics, and adaptive device management.
The core objective is to maximize self-consumption of solar energy while minimizing grid import — without compromising comfort or system reliability.

This Home EMS is a part of my own build home automation project, details about the home automation platform can be found here.

Let’s take a closer look at the EMS and how it works.


System Setup

The EMS runs on Linux and is entirely developed in Python, using MQTT as the central communication bus.
It integrates:

  • 20 kWp PV array
  • 11.4 kWh LiFePO₄ battery
  • 300 L heat-pump boiler with both on/off control and a 0–100 % controllable electric heater
  • Per-phase power monitoring and control
  • Controlled devices such as car charger, house heating, pool heating, pool filtration, etc.

All measurements are collected and processed in real time. The system continuously evaluates generation, consumption, and battery levels to determine the optimal operating mode.


Energy router

The core module of the home EMS is the energy router. It has the following tasks:

  • Calculate how much energy all active devices will need today in total to perform their job.
  • Set the today’s energy mode based on the power forecast (no sun, low sun, normal, or overcapacity).
  • Prioritise the devices, based on rules.

These global calculations run every two minutes, using the updated forecast and the remaining solar energy expected for the rest of the day.


The controlled devices

Controlled devices are all appliances within the EMS that can be actively managed, whether through switching, modulation, or power adjustment. They form the core of the energy control strategy, as they provide the flexibility to absorb solar surplus, avoid peak loads, and optimise battery charging. Each device requires its own control approach: some respond directly to power set-points, others rely on simple on/off logic, and many have internal constraints the EMS must respect. Managing these differences carefully allows the EMS to steer energy flows effectively. At the same time, it demands reliable measurements, clear priorities, and robust fail-safe rules, because any unexpected device behaviour can quickly disrupt the energy plan.


Device Power Allocation

The controllable devices are ordered by priority and receive power from the energy router accordingly. Each device reports its actual power consumption, allowing any unused power to be passed to the next device in the list. Every controllable device has its own characteristics: some can smooth or average incoming power, while others react almost instantly. Their response speed also varies; for example, a car charger requires slow, stable adjustments, whereas the boiler’s heating element can respond nearly immediately. Because of this, the car charger intentionally operates with a small buffer below its maximum possible power, preventing sudden battery drain when conditions fluctuate. The remaining power can then be redirected to faster-responding devices that can absorb these quick variations more effectively.


Managed devices

Battery

The battery functions as a dynamic daily buffer. Without active management, it would quickly charge to 100% on sunny days. Frequent charging and discharging around full capacity should be avoided to extend battery life. To manage this, a Target SOC curve is used to limit charging: the energy router stops sending power to the battery once its state of charge exceeds the curve.

The battery is generally intended to be fully charged by the end of the day, or earlier if high energy prices or other conditions make it advantageous. During the night, the battery is used to minimise grid consumption.

Benefits include:

  • Increased self-consumption of locally generated energy
  • Reduced interaction with the grid
  • Optimized charge and discharge cycles for longer battery lifespan

Battery SoC curve

Boiler heating

By default, the boiler is heated by the heat pump. It starts based on the available power from the energy router and the energy prices during the heating window. Once the heat pump is running, it continues until the boiler reaches 52 °C.

On days with excess energy, the boiler is heated using the electric heating element only, allowing it to reach its maximum temperature of 75–90 °C. In addition, the system periodically heats the boiler to 62 °C to prevent the growth of Legionella bacteria.

House heating

House heating is controlled based on room temperatures and the available power from the energy router. Heating the floors is a slow process, so frequent switching on and off should be avoided.

On days with sufficient solar energy, the house can also act as a thermal battery, allowing the floors to be heated slightly beyond the immediate comfort requirement.

Nibe heating pump control panel

Feed-in

Although feed-in it is not a controllable device in the traditional sense, it can be prioritised to feed excess power into the grid when the energy price exceeds a set threshold.

Car charger

The car charger is a controllable device that enables flexible charging of an electric vehicle (EV) based on the available power from the energy router. Its power can be regulated from 0% to 100%, while always leaving some capacity for other devices and to accommodate fluctuating conditions. Tesla Charger control panel

Under variable conditions—such as cloudy weather or unpredictable household loads that are not controlled by the EMS—the charger reduces its power output to limit battery and grid peaks. Faster-responding devices can then make use of this temporarily available energy.

Fast charging can also be enabled to give this device a higher priority. In practice, the car charger may receive more power than the home battery. This is useful if you want to leave the house with a fully charged EV during the day, allowing the home battery to recharge itself afterwards.

The car charger also respects user-defined settings, including maximum charge limits and pre-set charging schedules, ensuring both safety and convenience.

Pool filtration

The pool filtration switches on based on the available power from the energy router, but has a fairly high priority to ensure the water quality and hygiene. On days with no or low sun, it will be switched on time based on the hourly energy price.

Pool heater

The pool heater maintains the water at a comfortable temperature. It can be powered based on the available power from the energy router. The heater is controlled by a custom made LoRa receiver in combination with three Solid State Relays (SSR).

Winteresed pool

House usage

House Usage is not a physical device, but represents the power consumed by appliances that are not controlled by the Home EMS, such as the dishwasher, washing machine, or dryer.

It is also used to provide a rough prediction of overall energy consumption, taking into account factors like solar power forecasts, energy prices, and typical household behavior. This allows the EMS to plan more effectively, balancing controllable loads with the baseline household consumption.

Bitcoin miner

The Bitcoin miner is used on days with energy overcapacity and low prices. It can start operating as soon as surplus solar power is available, helping to consume excess energy that would otherwise go unused. The miner’s power can be continuously regulated from 0–100%, allowing the EMS to balance household energy needs while maximising efficiency. In return, the system generates Bitcoin from otherwise cheap or surplus solar energy, effectively turning excess electricity into a digital asset.


Phase balancing

This Home EMS also incorporates phase balancing. While the car charger cannot be controlled per phase, my custom-built boiler and the pool heating system are able to draw power first from the phase with the lowest-loaded phase, then from the medium-loaded phase, and so on.

Phase balancing serves two main purposes:

  1. Regulatory Compliance: In the Czech Republic, feeding power into the grid with unbalanced phases is not allowed. Without balancing, the inverter would compensate by drawing power from the grid to equalise the phases.
  2. Inverter lifetime: During a power outage, balanced phases reduce stress on the inverter, helping to extend its lifetime.


User interface and monitoring

As said before, the home EMS logic is written in Python and all system data is published to MQTT topics. Home Assistant is used as the user interface, receiving the data from MQTT. The Home Assistant dashboard provides:

  • Real-time per-phase and per device power values and graphs
  • Battery SOC and trends
  • For all EMS devices all the data is shown like: current power, temperatures, etc.
  • Debug dashboard to show the device priority list, needed energy for that day and current power assignments

Debug dashboard-power routing


Results and Insights

This Home EMS is performing exceptionally well. After several iterations, I arrived at the current design and continue to refine the system. Because each module is designed and tuned in-house, I can precisely evaluate system performance and rapidly test new control strategies.

This approach delivers both technical depth and practical reliability — essential for intelligent home energy systems that must respond to changing real-world conditions.

While I would gladly elaborate on the technical details of this EMS, I have kept the text concise to ensure readability. Thank you for your interest!