
Updated on August 17, 2026
Tracking your electricity cost in Home Assistant can help you understand when you are paying the most for energy and, more importantly, decide when it makes sense to move flexible consumption to cheaper periods.
If your electricity provider uses Time-of-Use (TOU) rates, you do not necessarily need a custom integration or an external pricing API. Home Assistant’s built-in Number, Schedule, and Template helpers can create a simple local system that always exposes your current electricity rate.
In this guide, we’ll build that price sensor, connect it to the Home Assistant Energy Dashboard, and use the same schedules in practical automations.
Important: This guide creates the price side of the system. Home Assistant still needs a valid energy consumption sensor from your electricity meter, energy monitor, smart meter integration, or another compatible source. A price sensor on its own cannot calculate energy costs.
Also keep in mind that the Energy Dashboard provides a useful consumption-based cost estimate. Your final utility bill can still include taxes, fixed charges, demand charges, discounts, or other fees that are not represented by the per-kWh rate used here.
Why Use Home Assistant’s Built-in Helpers for TOU Rates?
Some electricity providers have dedicated Home Assistant integrations, while others don’t. If your rates follow a predictable schedule, built-in helpers offer a simple alternative:
- Local and predictable: Your rate schedule is stored in Home Assistant and does not depend on an external pricing API.
- Works with many TOU plans: You can define peak, off-peak, mid-peak, weekend, or other scheduled periods.
- Mostly UI-based setup: The helpers can be created directly from the Home Assistant interface. The only code we need is a small Jinja template inside the Template helper.
- Energy Dashboard integration: The resulting sensor can be used as the current electricity price for your grid consumption.
- Useful for automations: The same Schedule helpers can be used to shift suitable loads into cheaper periods.
Setting Up Your Home Assistant Time-of-Use Price Sensor Step-by-Step
Let’s create a sensor that reports the electricity price that applies right now.
Step 1: Create Number Helpers for Your Rates
First, we need somewhere to store the different electricity prices.
Go to Settings > Devices & Services > Helpers, select Create helper, and create a Number helper for each rate in your electricity plan.

For example:
input_number.peak_rate=0.28input_number.off_peak_rate=0.12
Enter the rate as a number only. Do not enter $0.28 into the helper. The currency and energy unit will be assigned to the final Template Sensor.
If your electricity provider uses more decimal places, configure an appropriate step such as 0.001 or 0.0001 so you do not lose pricing precision.
Step 2: Define Your Rate Schedules
Now we need to tell Home Assistant when each rate applies.
Go back to Helpers, create a Schedule helper, and add the periods during which your peak rate is active.
For example, you could create schedule.peak_hours for Monday through Friday from 4 PM to 9 PM.

With a simple two-rate plan, we only need to define the peak schedule because every period outside it can be treated as off-peak.
If your plan has three or more rates, create the additional Schedule helpers you need. Try to avoid overlapping rate schedules unless that overlap is intentional, because the order of the conditions in your template will determine which rate wins.
Step 3: Create a Template Sensor for the Current Price
Now we’ll create the sensor that combines the schedules and rate helpers.
Go to Settings > Devices & Services > Helpers, select Create helper, choose Template, and create a Template Sensor.
For a simple peak/off-peak plan, use this State template:
{% if is_state('schedule.peak_hours', 'on') %}
{{ states('input_number.peak_rate') | float(none) }}
{% else %}
{{ states('input_number.off_peak_rate') | float(none) }}
{% endif %}The | float(none) part is important. Because this sensor has a unit of measurement, Home Assistant expects its state to be numeric. Explicitly converting the helper value prevents the sensor from returning a text value that Home Assistant cannot use as a numeric price.
Give the sensor a name such as Current Electricity Rate.
Then configure it as follows:
- Unit of measurement: use your Home Assistant currency followed by the energy unit, for example
USD/kWhorEUR/kWh. - Device class: leave it unset / None.
- State class: select Measurement.
Do not use the Monetary device class for this sensor. A monetary sensor represents an amount of money in a currency, while this entity represents a price per unit of energy.
After creating it, open the new entity and confirm that its state is a real number such as 0.28 or 0.12, not unknown, unavailable, or text containing a currency symbol.
Example with Three Different Rates
If your plan has peak, mid-peak, and off-peak periods, the same idea can be extended:
{% if is_state('schedule.peak_hours', 'on') %}
{{ states('input_number.peak_rate') | float(none) }}
{% elif is_state('schedule.mid_peak_hours', 'on') %}
{{ states('input_number.mid_peak_rate') | float(none) }}
{% else %}
{{ states('input_number.off_peak_rate') | float(none) }}
{% endif %}Here, off-peak acts as the fallback whenever neither of the other schedules is active.
Adding Your Rate Sensor to the Energy Dashboard
Once you already have your grid energy consumption configured in Home Assistant, you can use the new Template Sensor as its current price.
- Go to Settings > Dashboards > Energy.
- Open the Energy configuration for your electricity grid consumption.
- In the cost or price section, choose Use an entity with current price.
- Select your new sensor, for example
sensor.current_electricity_rate. - Save the configuration.

Home Assistant can now combine your recorded energy consumption with the price that was active at that time and provide cost information in the Energy Dashboard.
Whenever possible, use a price unit that matches the currency configured in Home Assistant and the energy unit expected by your Energy configuration, such as USD/kWh for consumption measured in kWh.
Your Home Assistant Energy Dashboard can now provide much more useful context by showing consumption together with estimated energy cost.
Smart Automations: Shift Flexible Loads to Cheaper Hours
The Schedule helpers are also useful outside the Energy Dashboard. You can use them in automations to run suitable appliances during cheaper periods.
Not every load should simply be switched on and off with a generic smart plug. High-power equipment such as water heaters and EV chargers must be controlled using hardware that is correctly rated for the load and appropriate for that appliance.
Example 1: Follow the Off-Peak Schedule with a Water Heater
If your water heater is already controlled by a properly rated switch, relay, contactor, or supported controller exposed to Home Assistant, you could make it follow the off-peak schedule:
alias: "Water Heater - Follow Off-Peak Schedule"
description: "Turns the water heater on during off-peak and off when the period ends"
triggers:
- trigger: state
entity_id: schedule.off_peak_hours
to: "on"
id: "start"
- trigger: state
entity_id: schedule.off_peak_hours
to: "off"
id: "stop"
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id: "start"
sequence:
- action: switch.turn_on
target:
entity_id: switch.water_heater
- conditions:
- condition: trigger
id: "stop"
sequence:
- action: switch.turn_off
target:
entity_id: switch.water_heater
mode: singleThis example handles both sides of the schedule: it turns the load on when off-peak begins and turns it back off when the cheap period ends.
Safety note: Do not control a high-current water heater with an ordinary smart plug unless that device and the electrical installation are specifically rated for the load. In many installations, a suitably rated relay or contactor is the correct solution.
Example 2: Charge Your Electric Vehicle During Off-Peak Hours
If your EV charger integration exposes a safe on/off entity and the charger supports being controlled this way, the same principle can be used:
alias: "EV Charger - Follow Off-Peak Schedule"
description: "Enables charging during the cheaper electricity period"
triggers:
- trigger: state
entity_id: schedule.off_peak_hours
to: "on"
id: "start"
- trigger: state
entity_id: schedule.off_peak_hours
to: "off"
id: "stop"
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id: "start"
sequence:
- action: switch.turn_on
target:
entity_id: switch.ev_charger
- conditions:
- condition: trigger
id: "stop"
sequence:
- action: switch.turn_off
target:
entity_id: switch.ev_charger
mode: singleMany EV chargers already provide their own scheduling or smart-charging functions. If yours does, compare those capabilities with a Home Assistant automation before deciding which method makes more sense for your installation.
Frequently Asked Questions (FAQ)
My utility company doesn’t have an official Home Assistant integration. What now?
If your electricity price follows a predictable timetable, this method is designed for exactly that situation. Number helpers store the prices, Schedule helpers define when they apply, and a Template Sensor exposes the rate that is active right now.
If your provider uses prices that change dynamically every hour or every few minutes, a fixed Schedule helper may no longer be the best solution. In that case, an integration or data source that supplies the actual changing market price is usually more appropriate.
My new rate sensor shows “Unknown”, “Unavailable”, or a non-numeric state. What should I check?
Start with the template and the source helpers. A restart should not be your first troubleshooting step.
- Go to Developer Tools > Template and test the State template.
- Confirm that every entity ID in the template exactly matches the helpers you created.
- Check that your Number helpers contain valid numeric values.
- Make sure the template converts the selected helper with
| float(none). - Check the current state of your Schedule helpers and confirm that the expected period is active.
- Open the final Template Sensor and verify that the state itself is a number, for example
0.28.
If a numeric Template Sensor has a unit of measurement or a state class, its template must return a number or none. Returning text such as unknown or unavailable as the template result is not valid for this type of sensor.
What device class and state class should I use for an electricity price sensor?
For a sensor representing a current electricity price such as USD/kWh:
- Device class: None / unset.
- State class: Measurement.
- Unit of measurement: your configured currency per unit of energy, for example
USD/kWhorEUR/kWh.
The Monetary device class is not appropriate here because the state is not simply an amount of money; it is a rate expressed as money per unit of energy.
How do I handle tiered electricity rates, such as the first 500 kWh being cheaper?
Consumption tiers are different from Time-of-Use rates because the active price depends on how much energy you have consumed during the billing period, not simply on the time of day.
The utility_meter helper can be useful for tracking consumption over a billing cycle and can also maintain separate tariff counters. However, it does not automatically decide to change your price simply because you crossed a specific kWh threshold.
For a tiered plan, you would normally:
- Create a Utility Meter that tracks consumption for the billing period.
- Use that accumulated consumption as the input to a Template Sensor or automation.
- Select the appropriate price when the configured consumption thresholds are crossed.
This is more advanced than a normal peak/off-peak schedule because you also need to reproduce your provider’s billing-cycle and tier rules accurately.
Should I use a Utility Meter instead of this Template Sensor?
They solve related but different problems.
The Template Sensor in this guide answers:
“What is my electricity price right now?”
A Utility Meter can answer questions such as:
“How much energy did I consume this month?”
or:
“How much energy did I consume while the peak tariff was selected?”
You can use both approaches together if you want to track consumption separately by tariff as well as provide the Energy Dashboard with the current price.
How can I create a chart showing my price changes?
Add a History graph card to one of your dashboards and select sensor.current_electricity_rate.
Because the sensor uses the Measurement state class, Home Assistant can also retain long-term statistics for it. This makes it easier to see how your electricity price changes over time.
Will the Energy Dashboard match my electricity bill exactly?
Not necessarily.
The price sensor described here can provide a good estimate of the energy component of your bill when the configured rates accurately match your contract. However, an electricity bill may also contain:
- fixed monthly charges,
- taxes,
- network or delivery charges,
- demand charges,
- discounts,
- minimum billing amounts,
- or other utility-specific adjustments.
For that reason, use the Energy Dashboard as a tool for understanding and comparing consumption and cost patterns, rather than assuming it will always reproduce the final utility invoice exactly.
Final Thoughts
For a predictable Time-of-Use electricity plan, this is a relatively simple way to give Home Assistant a current electricity price without depending on a custom integration.
The important part is keeping each piece clear:
- Number helpers store the rates.
- Schedule helpers decide when those rates apply.
- The Template Sensor exposes a numeric current price.
- The Energy Dashboard combines that price with your measured energy consumption.
- Automations can use the same schedules to move suitable loads into cheaper periods.
Once those pieces are working correctly, the system is easy to understand, easy to adjust when your electricity contract changes, and useful both for monitoring your costs and making better decisions about when to consume energy.

