Your First Measurement: A Zigbee Outlet, a Shelly Plug, and Ready-Made Helper YAML
Your First Measurement: A Zigbee Outlet, a Shelly Plug, and Ready-Made Helper YAML
Lessons 1 through 3 gave you a mindset, the Energy Dashboard, and the math behind W, kWh, and cost. Now we take a real device and make your first genuine measurement. No theory rehash. Step by step, from a metered outlet to a daily counter, a cost, spotting standby draw, and a safe automation.
This is a hands-on lesson. The premise is simple: you have one energy-metering outlet, plugged into a non-critical device, say a desk, a lamp, chargers, or an audio setup. You connect it to Home Assistant, check power and energy, add it to the Energy Dashboard, calculate a cost, and only after watching it for a while do you consider automatic shutoff.
Plan on about 65 to 75 minutes. Some of that time is physically connecting the hardware and waiting for data. Don't rush it. In the energy module, understanding what you're looking at on the chart matters more than quickly pasting in five automations.
This lesson's core rule
First, watch.
Then, notify.
Only at the end, automate a shutoff.
What to pick for your first measurement
The best first measurement is a device you can safely unplug without causing a household crisis. A desk, a lamp, a test monitor, a spare router, chargers. Don't start with a fridge, an oven, a heat pump, or a server the whole home depends on.
| Criterion | Good for a start | Bad for a start |
|---|---|---|
| Safety if switched off | A desk, a lamp, chargers | A fridge, the main router, a NAS |
| Usage pattern | Something with a clear on state and a standby state | A device that has to run 24/7 |
| Outlet's power rating | Draw stays well within the outlet's rating | A heater, a kettle, an oven that exceeds the rating |
| Goal of the measurement | Find out how much it uses and whether it has standby draw | Save the whole house's energy with one click right away |
Go back to Lesson 1
If you already picked a first device to measure in the Lesson 1 assignment, use that one. This lesson puts that choice into practice.
Don't start with large loads
Don't use a kettle, a space heater, a washing machine, a dishwasher, an oven, a pump, or anything else that generates significant heat for your first test. Even if the outlet's box says it's rated for 15 A, weak contacts, extension cords, or sustained heavy load can still be a problem. Do your first measurement on something calm and non-critical.
A Zigbee outlet with energy metering
A Zigbee outlet with energy metering is a popular first step. It works through a Zigbee coordinator, for example via the ZHA or Zigbee2MQTT integration. Once paired, Home Assistant usually gets a switch entity, a power entity in W, and sometimes an energy entity in kWh. Entity names depend on the manufacturer and integration, so below I use example names you'll swap for your own.
1. Set up a Zigbee coordinator, if you don't already have one.
2. Pair the outlet using the manufacturer's pairing mode.
3. Plug your test device into the outlet and check that power starts climbing.
4. In Developer Tools, States, find the power and energy entities.
Typical entities after pairing look roughly like this: switch.office_outlet, sensor.office_outlet_power, sometimes also sensor.office_outlet_energy. If you only have power, Lesson 3 already showed you how to build energy with Integration. If you have ready-made energy in kWh, use it directly.
Watch the power rating
A theoretical figure printed on the box, like 15 A at 120 V giving roughly 1800 W, doesn't mean every outlet is suited to continuous work at that level. What matters is sustained load, contact quality, the type of load, inrush current, temperature, any extension cord in use, and the manufacturer's own recommendations. Don't treat one universal number as a practical working limit.
Shelly Plug and Shelly Plus Plug
An alternative to Zigbee is the Shelly Plug or Shelly Plus Plug. It's a Wi-Fi outlet with a local Shelly integration in Home Assistant. It usually gives you power, energy, a switch, and tends to update its data reasonably often. For many people, this is the simplest path to a first measurement if they don't already have a Zigbee network.
| Feature | A Zigbee outlet | A Shelly Plug |
|---|---|---|
| Connection | Zigbee, needs a coordinator | Wi-Fi, local Shelly integration |
| Data | Depends on the model and integration | Usually power and energy right away |
| Range and stability | A good Zigbee mesh network | Depends on Wi-Fi |
| Who it suits | You already have Zigbee at home | You want a quick start without Zigbee |
After adding a Shelly through the Shelly integration, check the entities in Developer Tools. You'll often see something like switch.shellyplug_s_office, sensor.shellyplug_s_office_power, and sensor.shellyplug_s_office_energy. The rest of this lesson works the same regardless of brand. What matters is correct entities, not the logo on the box.
How to check power and energy in Home Assistant
Before you build any automations, watch the data by hand for a few days. That's the heart of this lesson. Go into Developer Tools, States, type in the entity name, and look at values at different moments: when the device is running, when it's off, when it's in standby.
Power in W: how much the device draws right now. Useful for spotting an on state and standby.
Energy in kWh: how much was used in total. Useful for the Energy Dashboard, cost, and periodic counters.
History: in Developer Tools, Statistics, or on the entity's chart, see how draw changes over time.
Write down three numbers
After the first day, note: power during normal use, power in standby, and how many kWh the device used over the day. Those three numbers are enough to judge whether further automation makes sense.
Is an outlet's measurement accurate
A metering outlet isn't a certified billing meter. It's usually good enough for household analysis, but don't treat it like lab equipment. A few percent of difference is normal, especially at low draw or with cheap outlets. What mostly matters to us is the trend: whether a device uses a lot, has standby draw, and whether a behavior change shows a visible effect.
Good enough for a decision: comparing devices, spotting standby draw, estimating cost.
Not for billing: it doesn't replace your utility's meter or a measurement taken by an electrician.
How to add the device to the Energy Dashboard
In Lesson 2 you configured the Energy Dashboard. Now you're adding a single device. Go into the energy source configuration, choose the individual devices category, and point it at your energy entity in kWh. The entity needs the correct device class, state class, and unit. If your outlet only gives you power, first build energy with Integration from Lesson 3.
1. Energy Dashboard, source configuration, individual devices.
2. Point it at your energy entity in kWh, cumulative.
3. Save and wait for statistics. A full picture usually shows up after a day or two.
A daily counter and cost: a ready-made YAML package
Below is a complete helper example for an office. It assumes you already have an energy entity in kWh and an energy price from Lesson 3. Swap in your own names. This isn't one giant file to paste in without thinking. It's a template you adapt to your own outlet.
A daily counter and daily cost
utility_meter:
office_energy_daily:
source: sensor.office_outlet_energy
name: "Office Energy Daily"
cycle: daily
template:
- sensor:
- name: "Office Daily Cost"
unique_id: office_daily_cost
unit_of_measurement: "USD"
availability: >
{{ states('sensor.office_energy_daily') not in ['unknown', 'unavailable', 'none']
and states('input_number.energy_price_kwh') not in ['unknown', 'unavailable', 'none'] }}
state: >
{{ (states('sensor.office_energy_daily') | float
* states('input_number.energy_price_kwh') | float) | round(2) }}
The first day can be incomplete
If you add the utility_meter halfway through the day, the first result won't cover a full day. That's normal. Judge it only after the next complete cycle.
If your outlet only has power, swap the utility_meter's source for your Integration energy entity, for example sensor.office_energy_from_power. If the outlet's energy reading resets every day, a monthly utility_meter won't work correctly. In that case, treat the device's daily counter as information, not as the foundation of your whole system.
How to spot standby draw
Standby is when a device is technically on but draws very little power over a long stretch of time. Don't guess a threshold blindly. Watch first. See how many watts the outlet shows when the desk is working normally, and how many when everything's supposedly asleep but the outlet is still switched on.
Only then set a threshold. For many desk setups, a reasonable starting point is around 10 to 20 W sustained over a while, but your threshold might differ. A monitor, chargers, and a router can all raise the draw even on a desk that's technically "off."
A simple standby sensor
template:
- binary_sensor:
- name: "Office Standby"
unique_id: office_standby
icon: mdi:power-sleep
availability: >
{{ states('sensor.office_outlet_power') not in ['unknown', 'unavailable', 'none'] }}
state: >
{{ is_state('switch.office_outlet', 'on')
and states('sensor.office_outlet_power') | float < 15
and states('sensor.office_outlet_power') | float > 0 }}
delay_on: "00:10:00"
delay_off: "00:02:00"
The 15 W threshold is an example
Tune it to your device after a few days of watching it. A charger alone behaves differently than a whole desk with a monitor.
You can later show this binary sensor on a dashboard as a simple standby status. In the shutoff automation we'll use binary_sensor.office_standby itself, so the condition stays consistent with the standby definition (above 0 W and below the threshold), rather than a plain below: 15.
Notify first, don't switch off first
Once you detect standby, don't switch off right away. Send a notification first. That way you'll see whether the automation fires too often, and whether it would switch off something you don't actually want switched off. If you went through the phone module in this course, you already have the notify basics. Here we use them in the context of energy.
A notification for extended standby
automation:
- alias: "Office: standby notification"
description: "Sends an alert when draw stays low for 30 minutes"
mode: single
triggers:
- trigger: numeric_state
entity_id: sensor.office_outlet_power
below: 15
for:
minutes: 30
conditions:
- condition: state
entity_id: switch.office_outlet
state: "on"
actions:
- action: notify.mobile_app_your_phone
data:
title: "Office: standby"
message: >
The outlet has been drawing {{ states('sensor.office_outlet_power') }} W
for 30 minutes. Check if something can be switched off.
Swap the notify target
Instead of notify.mobile_app_your_phone, use your own phone's notify action name from Developer Tools. Every phone has its own suffix.
Watch for a week how often you get this notification. If it arrives daily around the same time and makes sense, that's a good sign standby draw genuinely exists. If it fires every hour from random power fluctuations, raise the threshold or lengthen the for duration.
Automatic shutoff only after observation
Only once you know standby is real and the notifications make sense should you consider an automatic shutoff. And even then, give yourself an override. The simplest way is an input_boolean that's off by default. You decide when to let Home Assistant switch the outlet off without your hand on it.
An override for automatic shutoff
input_boolean:
office_auto_shutoff:
name: "Office: Automatic Standby Shutoff"
icon: mdi:power-plug-off
initial: false
A safe shutoff after extended standby
automation:
- alias: "Office: switch off after extended standby"
description: "Switches off the outlet after two hours of confirmed standby"
mode: restart
triggers:
- trigger: state
entity_id: binary_sensor.office_standby
to: "on"
for:
hours: 2
conditions:
- condition: state
entity_id: input_boolean.office_auto_shutoff
state: "on"
- condition: state
entity_id: switch.office_outlet
state: "on"
- condition: template
value_template: >
{{ states('sensor.office_outlet_power') not in ['unknown', 'unavailable', 'none'] }}
actions:
- action: switch.turn_off
target:
entity_id: switch.office_outlet
- delay:
seconds: 2
- condition: state
entity_id: switch.office_outlet
state: "off"
- action: notify.mobile_app_your_phone
data:
title: "Office switched off"
message: "The outlet was switched off after two hours of standby."
Good for a start: a notification after 30 minutes, a shutoff only after 2 hours, and only with the override enabled.
Bad for a start: switching the outlet off immediately after 5 minutes of low draw, with no observation and no override.
Check the outlet's behavior after a power loss
Unplug the outlet for several seconds and plug it back in. Check whether it stays off, returns to its previous state, or switches on automatically. Don't rely on an unknown post-restart behavior for a device that has to reliably come back online.
Edge case: the override and the for trigger
If draw is already in standby and you only then flip the input_boolean on, the automation won't fire right away, not until the state crosses the threshold again. Restarting Home Assistant mid-countdown on a for trigger restarts that countdown from zero. Give the household convenient options too: switch off now, remind me later, don't switch off today.
Safety and common sense
Measuring one device is safe only if you treat it like a small lab experiment, not a way to shut down the whole house. A metering outlet doesn't replace your utility meter. A shutoff automation doesn't replace good judgment. Before you switch anything off automatically, work out whether the saving makes sense against the price of the outlet and the household's comfort.
Don't exceed the outlet's rating: check the manufacturer's amp and watt limits.
Don't switch off critical devices: the main router, a server, a fridge, an alarm system.
Work out the saving first: 5 W of standby over a year doesn't always justify another outlet and an automation.
Common mistakes
You switch off immediately instead of watching: you don't know if low draw is standby or the device's normal working state.
The wrong watt threshold: you set 5 W for a whole desk with a monitor and get false alarms or no alarms at all.
You mix up power and energy: you add a power sensor to the Energy Dashboard instead of kWh.
utility_meter on the wrong source: the device's counter resets daily, and you're trying to build a monthly analysis from it.
No override on auto-shutoff: Home Assistant switches off something you didn't want switched off.
Overloading the outlet: you plug a device that draws too much power into a weak metering outlet.
Notification spam: every brief dip in power sends an alert to your phone.
You trust a single day of data: a device behaves differently on a Saturday than on a workday, so watch it for several days.
You're metering a power strip with multiple devices: you don't know which device is actually causing the draw, so your conclusion could be wrong.
Assignment: your first real device measurement
To do
☐ Connect a Zigbee outlet or a Shelly Plug to a non-critical device.
☐ Check the power and energy entities in Developer Tools, States.
☐ Add the device to the Energy Dashboard, if you have correct kWh.
☐ Build a daily counter and a simple daily cost.
☐ Write down power while running, power in standby, and usage over a full day.
☐ Set up a standby notification, but don't enable auto-shutoff yet.
☐ After a few days, judge whether automatic shutoff even makes sense.
☐ If you do enable auto-shutoff, do it through an input_boolean that's off by default.
Key takeaways
Your first measurement should be safe: a non-critical device, a sensible limit on the outlet's power rating.
Zigbee and Shelly are both good paths: what matters is correct entities, not the brand.
Watch the data first: power, energy, daily cost, standby.
Notify before you switch off: you're teaching the system before you give it authority.
Auto-shutoff needs an override: an input_boolean off by default is a safe starting point.
You have to work out the saving: a measurement without a decision is just a chart.
What's next
In Lesson 5 we'll go from a single outlet to measuring the whole home: a Shelly 3EM, DIN rail meters, current transformers, and safety when working near your breaker panel. That's a completely different scale from a desk on a Zigbee outlet, but it's built on the same foundation: correct data, understanding flows, and common sense over speed.
If you finish this lesson with one working device measurement, a daily counter, and at least one sensible standby notification, you've taken your first real step in the energy module. The foundation from Lessons 1 through 3 just got a body.