Guide

Non-Intrusive Load Monitoring for Home Assistant

Estimate appliance usage from a single mains power sensor.

Use NILM to train appliance models from Home Assistant history, preview historical disaggregation, and publish live estimated entities for dashboards and automations without installing a dedicated meter on every device.

Best for

Users who already have a mains power sensor and want appliance-level visibility with less hardware.

Keep in mind

NILM provides useful estimation, not direct appliance measurement.

Requirements

Before you begin

Check these items before you install or train anything.

What you need

  • A working Home Assistant OS or Home Assistant Container installation.
  • A mains power sensor already available in Home Assistant.
  • Recorder history for the time range you want to use for training.
  • At least 4 GB of RAM for Home Assistant and the NILM apps.
Memory usage

RAM usage depends strongly on the interval you use for training. Shorter intervals are lighter and are the best choice for a first training run.

Proxmox VM CPU type

If Home Assistant OS runs in a Proxmox VM and NILM Training Server immediately switches to Error with blank add-on logs, shut down the VM, set Proxmox VM > Hardware > Processor > Type to host, reboot the VM, and start the training server again. The default kvm64 CPU type can hide CPU instructions required by TensorFlow. If the host CPU does not support the required instructions, run the Training Server on another compatible machine and configure NILM with a custom external training server URL.

Sensor frequency

For better NILM performance, the mains sensor should update at intervals in the order of seconds. Update intervals such as 1 s, 3 s, 5 s, or 10 s usually work well.

What to expect

NILM is estimation

NILM estimates appliance behavior from one aggregate mains power signal. It does not directly measure each appliance.

Some appliances are easier

Appliances with clearer and more distinctive power signatures are usually easier to model well.

Training data matters

Results depend strongly on signal quality and on how representative your training interval is.

Important

Use NILM when you want useful appliance-level visibility with limited hardware. Do not treat it as legal-grade or meter-grade measurement.

Concepts

How NILM works

This section explains the basic idea of NILM and the algorithm reference used in this project.

Direct metering and NILM

Direct metering

Direct metering uses hardware such as smart plugs, clamp meters, or submeters to measure appliances individually. It is easier to trust, but hardware cost and installation effort increase with every additional appliance.

NILM

NILM reuses one aggregate mains signal and a trained appliance model to estimate appliance power and ON/OFF state. It is cheaper and easier to scale, but the result is an inference rather than a direct reading.

Why this matters

For many Home Assistant users, full submetering is too expensive or too invasive. NILM can provide useful appliance-level visibility without requiring a dedicated meter for every device.

Implemented algorithm reference

The implemented algorithm is based on RefQuery from the paper "Lightweight and Scalable Transfer Learning Framework for Load Disaggregation" (arXiv:2603.04998): https://arxiv.org/abs/2603.04998

Keep this in mind

NILM is best understood as useful estimation. It is often good enough for visibility, experimentation, and automation, but it is not the same thing as direct hardware measurement.

Step 1

Installation and first setup

Choose the setup that matches your Home Assistant installation, then configure NILM Dashboard and the Training Interface.

Home Assistant OS quick start

  1. Open Home Assistant.
  2. Go to Settings, then Apps, then Install App.
  3. Add this repository: https://github.com/lgarciamarrero92/ha-nilm
  4. Install the NILM app.
  5. Choose a training server option: install the NILM Training Server app, or run the ha-nilm-trainer Docker container on a reachable Docker host.
  6. Start the training server first.
  7. Start NILM.
  8. Open the NILM interface.
  9. Select and save your mains power sensor.

Training server selection

  1. Open the Training interface.
  2. Use the autodetected internal training server if you installed the Home Assistant OS Training Server app.
  3. Choose Custom External Server if the trainer runs outside Home Assistant.
  4. For an external trainer, save the URL in this form: http://<host-or-ip>:<port>/train
  5. Confirm the training server is ready before preparing a job.

Home Assistant Container quick start

  1. Create a long-lived access token from your Home Assistant user profile under Security.
  2. Create a folder for the NILM Docker Compose stack.
  3. Add the .env file and docker-compose.yml shown below.
  4. Start the stack with docker compose up -d.
  5. Open http://<docker-host>:8099/
  6. Select and save your mains power sensor in NILM Dashboard.
  7. Open the Training interface, choose Custom External Server, and save http://nilm-trainer:8080/train

.env for Home Assistant Container

HA_TOKEN=replace_with_your_home_assistant_long_lived_access_token
HA_REST_API_URL=http://YOUR_HOME_ASSISTANT_HOST_IP:8123/api
HA_WS_URL=ws://YOUR_HOME_ASSISTANT_HOST_IP:8123/api/websocket

docker-compose.yml

services:
  nilm-trainer:
    image: ghcr.io/lgarciamarrero92/ha-nilm-trainer:latest
    container_name: nilm-trainer
    restart: unless-stopped
    ports:
      - "8024:8080"
    networks:
      - nilm

  nilm-edge:
    image: ghcr.io/lgarciamarrero92/ha-nilm-edge:latest
    container_name: nilm-edge
    restart: unless-stopped
    ports:
      - "8099:8099"
    volumes:
      - nilm_data:/data
    environment:
      SUPERVISOR_TOKEN: "${HA_TOKEN}"
      HA_REST_API_URL: "${HA_REST_API_URL}"
      HA_WS_URL: "${HA_WS_URL}"
    networks:
      - nilm

volumes:
  nilm_data:

networks:
  nilm:
    driver: bridge
Container token name

SUPERVISOR_TOKEN is set from HA_TOKEN because the NILM container uses that environment variable name for Home Assistant API authentication.

Next

Once setup is complete, train your first appliance model.

Architecture

How the two services work together

NILM is split into a live inference service and a training service so daily operation stays lightweight.

Service roles

NILM

Monitors one mains power sensor, runs live inference, publishes estimated entities, and provides the setup, preview, and training preparation UI.

NILM Training Server

Receives prepared training jobs, runs model training in the background, then returns trained embeddings and learned thresholds to NILM.

After training

Once models are trained and enabled in NILM, the training service is only needed again when you want to train or retrain models.

External trainer

When the training server runs as a Docker container, NILM connects to it through the training URL you save in the Training page.

Supervisor manager role on Home Assistant OS

NILM requests the Supervisor manager role so it can query installed add-ons, detect whether NILM Training Server is installed and started, read its internal hostname, and build the internal training server URL automatically.

Step 2

Train your first appliance model

Open the Training Interface, choose the training server, then prepare a labeled job for the Training Server.

Confirm the training server

  1. Use the internal Home Assistant OS training server if it was autodetected.
  2. Use Custom External Server for Docker-based trainers and save the trainer URL.
  3. Confirm the training server is ready before selecting data or sending a job.

Choose an annotation method and the appliance name

Manual interval annotation

Use this when you do not have a dedicated appliance sensor. You manually mark ON intervals for the appliance in the selected mains range.

Sensor annotation

Use this when a real appliance power sensor already exists in Home Assistant. The sensor history should cover the full selected mains range.

Choose the mains interval

  1. Load the mains history range that will be used for training.
  2. Select a range you can annotate completely, not partially.
  3. The training range is limited to the previous 7 days to avoid very large training datasets.
Interval quality drives accuracy

Pick a mains interval you can label completely. For manual annotation, mark all ON intervals in that range. For sensor annotation, you need an appliance sensor data for the full range.

Define labels

  1. Manual interval annotation: draw ON intervals for the appliance in the selected mains range.
  2. Sensor annotation: select the appliance power sensor used as ground truth.

Prepare and send

  1. First review the Training Overview section and confirm appliance name, supervision mode, labels, and mains range.
  2. Click the button: Prepare and Send to Training Server.
  3. NILM validates the configuration, prepares the package, creates the local job, and sends it to NILM Training Server.
  4. Follow progress in the Training Jobs table until the model is done.
What success looks like

After training completes, the model is stored inside NILM and becomes available as a model card in NILM Dashboard.

Next

Preview and validate the model in NILM Dashboard.

Step 3

Validate your model in NILM Dashboard

NILM Dashboard is where you inspect historical mains data and preview models output.

Main dashboard elements

Mains chart

This is the main reference chart for the selected range. Predictions are drawn on top of it so you can compare the estimate against the aggregate mains signal.

Model cards

Each trained appliance appears as a model card with its name, publishing state, and a Disaggregate action.

Prediction layer

Predictions are added directly to the mains chart. You can display more than one prediction at the same time and remove them individually.

What the dashboard is good for

  • Saving the mains power sensor used by NILM.
  • Inspecting the historical mains signal.
  • Running offline disaggregation for one appliance or for all available models.
  • Debugging predicted power, ON/OFF state.

Appliance share diagram

  • NILM also plots an appliance share diagram to help you understand how energy is distributed across the currently plotted predictions.
  • The diagram uses only the predictions that are currently visible on the chart.
  • A dedicated Base Load share is also shown; it represents the estimated background portion of mains consumption.
  • Other is the remaining mains portion not explained by the visible appliance predictions plus Base Load.
  • The diagram updates automatically whenever predictions are added or removed.
Best first validation

Preview the disaggregation result on an interval you already understand well. That makes it much easier to judge whether the prediction is useful.

Step 4

Publish live entities in Home Assistant

When live publishing is enabled, NILM creates Home Assistant entities based on the trained model. These are live model outputs derived from mains power, not direct measurements. The live entities are updated approximately every 8 seconds.

Live entities

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

What they mean

  • The power sensor is the estimated appliance power at runtime.
  • The energy consumed sensor is the cumulative estimated appliance energy for dashboards and energy workflows.
  • The binary sensor is the estimated appliance ON/OFF state at runtime.
When to enable live publishing

Enable live publishing for appliances you want to monitor in real time and use in dashboards or automations.

What success looks like

The NILM entities appear in Home Assistant and update as the model runs live against the mains signal.

Important

Limitations

NILM is useful, but it is not equally strong for all appliance types. Knowing the limits helps you choose better targets and interpret results correctly.

Appliance types that are usually harder

  • Very low-power appliances such as lighting, phone chargers, and small standby loads.
  • Appliances that stay ON for long periods with flat consumption, such as some TVs or computers.
  • Very short-cycle appliances or events that are brief and easy to hide inside aggregate mains noise.
  • Multiple similar appliances running at the same time, which can produce overlapping signatures.

Where this method is usually stronger

  • The current method was trained with representative, but not exhaustive, appliance types such as fridge, dishwasher, washing machine, kettle, and microwave.
  • Because of that training exposure, performance is often better for appliance signatures similar to those categories.
What this means in practice

The method can still work well for other appliances when their signatures are identifiable from mains. The more distinctive and repeatable the signature, the better the expected results.

Interpretation guidance

Use NILM as an estimation tool. For difficult appliance types, expect higher uncertainty and validate with known intervals before relying on live behavior for automations.