Building a network monitoring dashboard in Home Assistant
I run a full UniFi stack at home, a Cloud Gateway Fiber Gateway (UCG), five different switches, and five access points spread across the house. The UniFi integration for Home Assistant gives you device status and connected client counts, but it doesn't expose bandwidth data as sensors. I wanted to see real-time throughput on my HA dashboard. This post documents how I built that.
Why SNMP
My first instinct was to look for a purpose-built integration, but nothing reliable existed for per-AP bandwidth at the time. The UniFi switches (USW Flex 2.5G) don't support SNMP at all, which ruled out the obvious approach of polling switchport counters. The gateway and access points do support SNMP though, which turned out to be enough.
SNMP is the right approach as every UniFi device keeps internal byte counters per interface. By polling those counters periodically, you can calculate throughput as a delta over time. The performance impact is negligible, a few hundred bytes per query over UDP, even at 10-second intervals.
Setting up SNMP
SNMP is disabled by default on the UCG. Enable it under Settings > System > SNMP in the UniFi console, set version to SNMP v2c, and note your community string.
Before adding any sensors to Home Assistant, I used snmpwalk from my Mac to identify the right interface:
snmpwalk -v2c -c homelab 192.168.1.1 1.3.6.1.2.1.2.2.1.2
This returns all interfaces the device knows about. For my UCG, the WAN uplink is eth6.701. VLAN 701 is what my ISP uses. The interface index was 21.
The sensor pipeline
Getting from raw SNMP data to a Mbit/s reading in Home Assistant takes three layers:
1. SNMP sensors — raw cumulative byte counters, tagged state_class: total_increasing so HA handles resets correctly.
2. Derivative sensors — calculate the rate of change in octets per second. A time_window of 30 seconds smooths out polling jitter without introducing too much lag.
3. Template sensors — convert octets/s to Mbit/s (octets × 8 / 1,000,000). A | max with 0 prevents negative spikes when the derivative briefly dips below zero.
I went through a few failed approaches before landing on this pipeline. My first attempt used template sensors that stored the previous value as an attribute and calculated the delta themselves. This fails because HA evaluates current and previous_value in the same render cycle, so the delta is always zero. The derivative platform solves this cleanly by doing the math in HA's core rather than in a template.
The dashboard
For the WAN graph I used mini-graph-card. It's cleaner than apexcharts for simple time-series and doesn't need a formatter function to display units.

Data usage tracking
Once the SNMP sensors were in place, adding daily and monthly data counters was straightforward using utility_meter. I added template sensors on top to convert octets to GB for display, since raw octet values in the billions are not useful on a dashboard card.
A note on entity IDs
One thing that caused me grief: when migrating from the legacy platform: template syntax to the modern template: block syntax (required since HA 2026.6), entity IDs change. The fix: always set unique_id on every sensor. HA uses the unique_id as the stable internal identifier, so renaming via the UI won't break references.