
Updated on January 30, 2026
Tracking your real-time electricity cost in Home Assistant has shifted from a neat trick to a financial necessity for anyone looking to optimize energy consumption and slash their power bill. If you’re tired of complex, unreliable custom integrations that break with every update, you’ve come to the right place. Forget manually editing YAML files or depending on third-party APIs that could disappear tomorrow.
The most robust, stable, and universal way to manage variable electricity costs is by leveraging Home Assistant’s powerful built-in helpers. In this definitive 2026 guide, I’ll walk you through setting up a bulletproof system to track your utility’s Time-of-Use (TOU) rates, integrating it into your Home Assistant Energy Dashboard for pinpoint cost analysis, and most importantly, building smart automations that save you real money while you sleep.
Why Use Home Assistant’s Built-in Helpers for TOU Rates?
While some utility companies have dedicated integrations, many don’t. Relying on custom components can be a headache. The helper-based method, however, offers unmatched advantages:
- Rock-Solid Stability: This method doesn’t rely on external APIs that can change or fail. You set your utility’s schedule once, and it just works, update after update.
- Universal Compatibility: It works with any utility provider in the world, whether you have flat rates, peak/off-peak schedules, or even seasonal price changes. You’re in complete control.
- Easy UI-Based Setup: You can configure everything directly from the Home Assistant interface in minutes—no more fiddling with complex YAML code or restarting your server endlessly.
- Perfect Energy Dashboard Integration: It feeds precise cost data directly into the Energy Dashboard, allowing you to see exactly how much you’re spending in dollars and cents.
Setting Up Your Home Assistant Time of Use Sensor Step-by-Step
The process is incredibly straightforward and is handled entirely within the Home Assistant UI. Let’s build a sensor that always knows your current electricity price.
Step 1: Create Input Number Helpers for Your Rates
First, we need to store your different electricity rates. Go to Settings > Devices & Services > Helpers tab. Click the “+ Create Helper” button and select “Number”. Create one helper for each of your rates (e.g., peak, off-peak, mid-peak).

For example, create `input_number.peak_rate` with a value of `$0.28` and `input_number.off_peak_rate` with a value of `$0.12`.
Step 2: Define Your Rate Schedules
Next, we’ll tell Home Assistant *when* these rates are active. Go back to Helpers and create a “Schedule” helper for each period. For example, create a schedule named “Peak Hours” and add time blocks for when your peak rates apply (e.g., Monday-Friday from 4 PM to 9 PM).

Step 3: Create a Template Sensor for the Current Price
Now, let’s tie it all together. We’ll create a Template Sensor that checks which schedule is active and pulls the correct price from our number helpers. Go to Helpers, create a “Template” helper, and select “Template a sensor.”
Paste the following code into the “State template” box, adjusting the entity IDs to match the helpers you just created:
{% if is_state('schedule.peak_hours', 'on') %}
{{ states('input_number.peak_rate') }}
{% else %}
{{ states('input_number.off_peak_rate') }}
{% endif %}
Give it a name like “Current Electricity Rate,” and most importantly, set the “Unit of measurement” to `USD/kWh`. This is crucial for the Energy Dashboard. Hit “Create,” and you now have a sensor that always reflects your real-time electricity cost!
Adding Your Rate Sensor to the Energy Dashboard
To truly unlock the power of this setup, you need to connect it to the Energy Dashboard. This will show you exactly what you’re spending in real-time.
- Navigate to Settings > Dashboards and select Energy.
- Scroll down to the “Electricity grid” section.
- Under “Price”, select “Use an entity with the current price”.
- In the dropdown, find and select the template sensor you just created, `sensor.current_electricity_rate`.
- Save the configuration.

From now on, your Home Assistant Energy Dashboard will be far more powerful, displaying your costs in dollars alongside your consumption in kWh.
Smart Automations: Let Home Assistant Save You Money
This is where the magic happens. By using the state of your schedule helpers, you can create automations that run your most power-hungry appliances only during the cheapest off-peak hours.
Example 1: Run the Water Heater Only During Off-Peak Hours
Let’s create an automation that turns on your water heater’s smart plug only when electricity is cheap.
alias: 'Water Heater - Turn On During Off-Peak'
description: 'Activates the water heater only during cheap off-peak hours'
trigger:
- platform: state
entity_id: schedule.off_peak_hours
to: 'on'
condition: []
action:
- service: switch.turn_on
target:
entity_id: switch.water_heater_smart_plug
mode: single
For this to work, you’ll need a power-monitoring smart plug controlling your appliance, like a Zigbee-based SONOFF S31 or a Wi-Fi Kasa plug.
Example 2: Charge Your Electric Vehicle Overnight
Similarly, we can ensure your EV charger only activates during the most cost-effective window, typically overnight.
alias: 'EV Charger - Charge During Off-Peak'
description: 'Activates the EV charger during the cheapest period'
trigger:
- platform: state
entity_id: schedule.off_peak_hours
to: 'on'
condition: []
action:
- service: switch.turn_on
target:
entity_id: switch.ev_charger
mode: single
Pro Tip: Remember to create a matching automation to turn these devices *off* when the schedule’s state changes back to ‘off’ to complete the cycle!
Frequently Asked Questions (FAQ)
My utility company doesn’t have an official Home Assistant integration. What now?
You’re in the right place! This guide is designed specifically for that scenario. By using the built-in Number, Schedule, and Template helpers, you can manually configure any TOU plan from any provider, giving you a more stable solution than a cloud-based integration anyway.
My new rate sensor shows up as “Unknown” or “Unavailable”. What did I do wrong?
This is almost always a typo in your template sensor configuration. Follow these steps:
- Go to Developer Tools > Template and paste your template code into the editor. It will show you the rendered output or an error message.
- Double-check that the entity IDs (`schedule.peak_hours`, `input_number.peak_rate`, etc.) in your template exactly match the ones you created. A single typo will break it.
- Ensure you’ve set a valid number in your `input_number` helpers.
- If all else fails, a full reboot of Home Assistant (Settings > System > Restart) can sometimes clear up caching issues after creating new template entities.
How do I handle tiered electricity rates (e.g., the first 500 kWh are cheaper)?
Tiered rates are more complex to track than TOU. The best approach is to use the `utility_meter` helper. You can configure it to track your monthly consumption and define different tariffs that automatically switch over once you cross a certain kWh threshold. This is a more advanced topic but fully achievable within Home Assistant.
How can I create a chart showing my price fluctuations?
Easy! On any of your dashboards, add a “History graph” card. In the card’s configuration, add your `sensor.current_electricity_rate` entity. This will display a simple bar chart showing exactly when your rates change from peak to off-peak, helping you visually plan your energy usage.
