HomeLab Power Monitoring with Home Assistant, Tasmota, and InfluxDB: Track Electricity Costs and Optimize Your Servers

HomeLab tutorial - IT technology blog
HomeLab tutorial - IT technology blog

Why Power Monitoring Should Be Your Next HomeLab Project

Running a HomeLab is rewarding — until the electricity bill arrives. My wake-up call came when my monthly bill jumped €35 after adding a NAS, a small Proxmox cluster, and three always-on Raspberry Pis. I had no idea which device was the culprit. That’s when I stopped guessing and started measuring.

Knowing your consumption in real time changes how you think about your setup. Which servers should run a sleep schedule? Is that old desktop really worth keeping on 24/7? How much is your HomeLab actually costing per month? Once you have the numbers, every hardware decision gets sharper — and the power bill stops being a mystery.

Approach Comparison: Three Ways to Monitor Power

Three main approaches exist for HomeLab power monitoring. They look similar on the surface, but behave very differently once you’re actually living with them.

Option 1: Commercial Smart Plugs with Cloud Apps

Plugs like TP-Link Kasa or Meross report power data through their vendor cloud apps. Setup takes minutes and the apps are polished. The catch: your data lives on someone else’s server, you’re locked into their ecosystem, and local polling requires reverse-engineering or third-party integrations. Anyone who’s spent time building a self-hosted setup usually bails on this route fast.

Option 2: UPS with SNMP Monitoring

Already have an APC or CyberPower UPS? SNMP gives you aggregate power draw for everything on the circuit. Tools like NUT (Network UPS Tools) integrate cleanly with Home Assistant and Grafana. The downside is granularity — you get one number for the entire rack. Whether it’s your NAS, your old gaming PC, or the network switch eating power, you can’t tell.

Option 3: Tasmota Smart Plugs + Local MQTT + Home Assistant

This is the stack I settled on. Tasmota-flashed plugs — Sonoff S31, BlitzWolf BW-SHP6, or Athom plugs that ship pre-flashed — report voltage, current, and wattage every few seconds over local MQTT. No cloud, no subscription. Home Assistant ingests the data, and InfluxDB stores the time-series history for Grafana dashboards or long-term cost analysis.

Pros and Cons of the Tasmota + Home Assistant + InfluxDB Stack

Advantages

  • Fully local: No data leaves your network. MQTT broker runs on your server.
  • Per-device granularity: One plug per device means you know exactly what’s consuming what.
  • Cost: Tasmota-compatible plugs run $5–$15 each. No subscription fees.
  • Automation hooks: Home Assistant can react to power events — shut down a server when draw spikes, send an alert when a device goes unexpectedly idle.
  • Long-term history: InfluxDB handles time-series data efficiently. Query consumption by day, week, or month without performance issues.

Disadvantages

  • Initial setup effort: Flashing Tasmota, configuring MQTT, wiring up the InfluxDB integration — budget a few hours the first time through.
  • Per-plug limit: Each plug handles one device. A full rack needs multiple plugs.
  • Accuracy: Consumer-grade plugs have ±1–2% accuracy, fine for cost tracking but not lab-grade measurement.
  • Calibration sometimes needed: Some Tasmota plugs read a few percent off out of the box and need a one-time calibration against a reference meter.

Recommended Setup

Here’s the stack running in my HomeLab right now:

  • Smart plugs: Athom Tasmota Pre-Flashed plugs (skips the flashing step) or Sonoff S31 (flash via serial or OTA)
  • MQTT Broker: Mosquitto, running as a Docker container or Home Assistant add-on
  • Home Assistant: Automation hub, dashboards, and integration point
  • InfluxDB 2.x: Time-series database for historical data storage
  • Grafana (optional): Richer dashboards if you want to go beyond HA’s built-in charts

Already running the TIG stack (Telegraf/InfluxDB/Grafana)? Just point the HA integration at your existing InfluxDB instance and skip the install.

Implementation Guide

Step 1: Configure Tasmota on Your Smart Plug

If your plug didn’t come pre-flashed, flash Tasmota via serial once, then configure it over WiFi. Open the Tasmota web UI at http://<plug-ip>/ and set up MQTT:

Configuration → Configure MQTT
  Host: <your-mosquitto-ip>
  Port: 1883
  Topic: tasmota_%06X   ← unique per device
  Full Topic: homelab/%prefix%/%topic%/

Drop the telemetry interval from the default 300 seconds. I use 30 seconds for near real-time data:

# In Tasmota console:
Teleperiod 30

The plug will now publish to homelab/tele/<device>/SENSOR every 30 seconds. The JSON payload looks like this:

{
  "Time": "2026-05-22T14:30:00",
  "ENERGY": {
    "Voltage": 230,
    "Current": 0.854,
    "Power": 196,
    "ApparentPower": 196,
    "ReactivePower": 0,
    "Factor": 1.00,
    "Today": 1.234,
    "Yesterday": 2.891,
    "Total": 45.123
  }
}

Step 2: Add Tasmota Devices to Home Assistant

HA’s MQTT integration auto-discovers Tasmota devices if you enable discovery — use SetOption19 1 for legacy Tasmota builds, or the built-in Tasmota integration in newer HA versions. Manual config in configuration.yaml also works and gives you more control:

mqtt:
  sensor:
    - name: "Proxmox Node Power"
      state_topic: "homelab/tele/proxmox_plug/SENSOR"
      value_template: "{{ value_json.ENERGY.Power }}"
      unit_of_measurement: "W"
      device_class: power

    - name: "Proxmox Node Energy Today"
      state_topic: "homelab/tele/proxmox_plug/SENSOR"
      value_template: "{{ value_json.ENERGY.Today }}"
      unit_of_measurement: "kWh"
      device_class: energy
      state_class: total_increasing

Copy this block for each plug, updating the topic and name. Reload the YAML config and the sensors show up in HA immediately.

Step 3: Store History in InfluxDB

Spin up InfluxDB 2.x as a Docker container or install it via the Home Assistant add-on:

docker run -d \
  --name influxdb \
  -p 8086:8086 \
  -v influxdb-data:/var/lib/influxdb2 \
  influxdb:2

Create a bucket named homeassistant via the InfluxDB UI at http://<server>:8086. Then wire up the HA integration in configuration.yaml:

influxdb:
  api_version: 2
  ssl: false
  host: <influxdb-ip>
  port: 8086
  token: <your-influxdb-token>
  organization: <your-org>
  bucket: homeassistant
  include:
    entity_globs:
      - sensor.*_power
      - sensor.*_energy*

Filtering to power-related sensors keeps storage lean. My instance has been running for 8 months on a 10 GB volume without hitting limits.

Step 4: Calculate Monthly Electricity Cost

With energy data in InfluxDB, query monthly cost using Flux. Swap 0.15 for your local rate per kWh:

from(bucket: "homeassistant")
  |> range(start: -30d)
  |> filter(fn: (r) => r["entity_id"] =~ /energy_today/)
  |> sum(column: "_value")
  |> map(fn: (r) => ({ r with cost_usd: r._value * 0.15 }))

I use this as a Grafana panel variable so every dashboard shows current-month cost in my local currency automatically. My HomeLab runs about €22/month — the Proxmox cluster accounts for most of it.

Step 5: Set Up Power Consumption Alerts

This is where the setup starts paying for itself. The automation below fires when a device draws high power for more than 5 minutes — handy for catching a server stuck in a compute loop:

automation:
  - alias: "Alert: Proxmox High Power Draw"
    trigger:
      - platform: numeric_state
        entity_id: sensor.proxmox_node_power
        above: 350
        for:
          minutes: 5
    action:
      - service: notify.mobile_app
        data:
          title: "HomeLab Power Alert"
          message: >-
            Proxmox is drawing {{ states('sensor.proxmox_node_power') }}W
            for over 5 minutes. Check for runaway workloads.

A second automation shuts down non-critical VMs during off-peak hours when total load exceeds a threshold. That one alone trimmed about €8/month off my bill.

Step 6: Calibrate Your Plugs

Fresh out of the box, some Tasmota plugs read 5–10% off. Grab a reference meter — a $15 plug-in unit from any hardware store works fine — and calibrate via the Tasmota console:

# With a known resistive load (e.g., a 100W incandescent bulb):
PowerSet 100.0    # Tell Tasmota the actual wattage
VoltageSet 230    # Set actual measured voltage
CurrentSet 0.435  # Set actual measured current

Post-calibration, my plugs read within 1% of the reference meter. Close enough for cost tracking.

Tips From Running This in Production

  • Label your plugs in Tasmota using FriendlyName1 Proxmox Node — it carries through to HA auto-discovery and saves confusion when you have eight plugs all named “Tasmota_XXXXXX”.
  • Monitor standby power: Lots of devices draw 5–15W doing nothing. Over a month, that’s 3–11 kWh per device. HA’s energy dashboard makes these power vampires visible fast.
  • Use InfluxDB retention policies: Keep raw 30-second data for 7 days, downsample to hourly averages for 1 year. This prevents the database from growing unbounded.
  • Group devices logically in HA’s Energy Dashboard (Settings → Energy) — separate “servers” from “networking” from “storage” to see where your power budget actually goes.
  • Don’t forget networking gear: Switches and routers run 24/7. Mine collectively draw 45W — more than my NAS at idle. Easy to miss until you actually measure it.
Share: