Appliance-level energy insight from one mains power sensor (Non-Intrusive Load Monitoring)

Hi everyone,

I’d like to share a project I’ve been working on: NILM for Home Assistant.

GitHub repository: GitHub - lgarciamarrero92/ha-nilm: Non-Intrusive Load Monitoring For Home Assistant · GitHub

NILM stands for Non-Intrusive Load Monitoring.

The goal is to estimate what individual appliances are doing by looking at a single aggregate mains power sensor, instead of installing a dedicated smart plug, clamp meter, or submeter on every appliance.

This is useful for Home Assistant users who want more appliance-level energy visibility, especially when direct metering is expensive, difficult, or simply not practical.

For example:

  • Hardwired appliances
  • High-current appliances where smart plugs are not suitable
  • Appliances inside electrical panels or difficult-to-access places
  • Large loads that would require an electrician to meter directly
  • Devices where individual metering hardware is too expensive
  • Homes where you want to reduce the number of sensors and still get useful insight

Why training is necessary

One important idea behind this project is that appliance detection is very dependent on the real home.

A washing machine, dishwasher, fridge, oven, kettle, heat pump, or water heater can behave differently depending on:

  • Brand and model
  • Power profile
  • Installation
  • Voltage and local electrical conditions
  • Sensor update rate
  • Background household consumption
  • Other appliances running at the same time
  • How the appliance is actually used in that home

Because of that, it is very hard to build one universal NILM model that generalizes perfectly to every home, every country, every sensor, and every appliance brand.

Instead, this project lets you train appliance models using your own Home Assistant history. The idea is to adapt the detection to your home, your mains sensor, and your appliances.

At the same time, the approach is designed to be computationally efficient so it can run on edge devices like a Raspberry Pi, and to require as little labeled data as possible for training. This is achieved using a state-of-the-art deep learning technique known as transfer learning, where a pretrained model is fine-tuned for the target domain using a relatively small amount of labeled data.

What can this be useful for?

Some possible Home Assistant use cases:

  • Detect when the washing machine has finished without using a smart plug
  • Track when a dishwasher, dryer, oven, kettle, microwave, or fridge is running
  • Estimate activity from appliances that are difficult to meter directly
  • Monitor high-consuming loads
  • Alert when a high-consuming appliance runs during peak electricity prices
  • Decide whether an appliance is worth metering directly later

This is especially interesting for high-consuming appliances. These are often the devices people most want to monitor, but they are also the ones where direct metering can be the hardest or most expensive.

Two apps, two roles

The project includes two Home Assistant apps:

1. NILM
This is the main app. It monitors the mains power sensor, runs trained appliance models, and can publish live estimated entities into Home Assistant.

2. NILM Training Server
This app handles the heavier machine-learning training workload. It receives training jobs from the NILM app, trains the appliance model, and returns the trained result.

The split is intentional:

  • NILM stays lightweight for daily live inference.
  • NILM Training Server handles the expensive training process.
  • After training, the training server can be stopped.
  • Only the main NILM app needs to keep running for live predictions.

Two supervision modes

The project supports two ways to train an appliance model.

1. Sensor annotation

This mode is useful when you already have a real appliance power sensor in Home Assistant.

For example, maybe you already have a smart plug on your washing machine or dishwasher. NILM can use that sensor history as ground truth while training.

This is usually the better option when you want more accurate power estimation, because the model sees both:

  • The aggregate mains signal
  • The real appliance power signal

This can be useful if you want to train a model using a temporary smart plug, then later remove the plug and let NILM estimate the appliance from the mains sensor.

2. Manual interval annotation

This mode is useful when you do not have a dedicated appliance sensor, but you still need to know when the appliance was ON during the selected training interval. This can be done by manually inspecting the mains power signal and identifying characteristic patterns, by relying on your own knowledge of when the appliance was used, or by correlating with other signals or events in Home Assistant.

This is especially useful for appliances where installing a sensor is not possible, expensive, or unsafe, such as hardwired devices, high-current loads, or equipment located in electrical panels or difficult-to-access areas.

The advantage is that you can train a model without having direct appliance metering.

The tradeoff is that this mode may lose some accuracy compared with sensor annotation, especially for exact power estimation. Since you are only marking when the appliance was ON, the model has less detailed ground truth than it would have with a real appliance power sensor.

So, in practice:

  • Sensor annotation is better when you already have a real appliance sensor and want stronger training data.
  • Manual interval annotation is useful when direct metering is not available, especially for high-consuming or hardwired appliances, but results may need more validation.

Live entities in Home Assistant

Once a model is trained and live publishing is enabled, NILM can create entities such as:

  • sensor.nilm_<appliance>_power
  • binary_sensor.nilm_<appliance>_on

These are live model outputs derived from the mains signal, acting like virtual sensors that update approximately every 8 seconds.

The entities can be used in dashboards, automations, notifications, and energy workflows.

Validation is important

Because NILM is an estimation, results will not always be perfectly accurate and should be interpreted with care.

Predictions can vary depending on the appliance type, the quality of the mains signal, and how clearly the appliance stands out from other loads in the home.

The algorithm has been trained with a limited set of devices, appliance types, countries, and electrical conditions. Real homes can vary a lot, so it is up to you to verify when the estimation is working well for your specific appliance and setup.

Some appliances are much easier to detect than others. NILM usually works better when the appliance has a clear, repeatable, and distinctive power signature. Typical examples include appliances such as washing machines, dishwashers, kettles, microwaves, and some fridges.

It is usually harder for:

  • Very low-power devices
  • Small standby loads
  • Lighting
  • Phone chargers
  • Appliances with flat, long-running consumption
  • Very short events
  • Multiple similar appliances running at the same time

For these more difficult cases, results may be less reliable, so it is especially important to validate the model on known periods before using it for automations.

Why I built this

Many Home Assistant users already have a mains power sensor, but appliance-level monitoring usually requires installing more and more hardware.

That works well for some devices, but it does not scale nicely to every appliance. It can become expensive, messy, or impossible for hardwired and high-current loads.

This project explores a middle ground:

  • Use the mains sensor you already have
  • Train models for your own appliances
  • Publish estimated appliance entities
  • Use those entities in Home Assistant
  • Avoid installing dedicated sensors everywhere

If you try it, please check the documentation, open issues, share suggestions, or contribute ideas on GitHub.

2 Likes

I'm not in a position to try this yet but it has taken a high place on my "probably" list!

So glad to see it uses machine learning (tensorflow), which seems appropriate starting point, and not an LLM. Have you used tensorflow before?

Hope it goes well.

Yes, it is using custom machine learning models for Non-Intrusive Load Monitoring, based on TensorFlow for training and TensorFlow Lite for inference.

I hope it is useful to you!

1 Like

This looks like a great project! Thanks for working on it and sharing. Quick question: can the training be done on another machine other than the one HA is running on? I run HA on a RPi but would like to perform the training on my Mac.

1 Like

Right now, training is only possible on the same machine where Home Assistant is running. Training on other machines is something we plan to include in future app releases.

That said, the algorithm is designed to be lightweight enough to run well even on a Raspberry Pi. The training time depends on how much data you use. I recommend starting with 1 day of data and increasing the training interval gradually until you notice the device becoming too stressed.

We currently limit training to 7 days to avoid excessive load on edge devices. For some appliances, even 1 day of data is enough to get decent results.

1 Like

In the new version of the nilm_edge app, training can now be performed on a machine other than the one running Home Assistant