I really struggled with this - it’s actually really simple but there are a couple of gotchas to know about.
When done end up with this:
Overview
- Have a sensor that measures your grid import
- Use the Utility meter integration to set up a Utility Meter helper
- Set up an automation to set the correct rate (Peak/Cheap) at the right times
- Add the two meters set up by the Utility Meter integration to the Energy dashboard
Gotchas
The meters set up by the Utility meter integration will return UNKNOWN until they have ‘seen’ some data from your grid import sensor. We have a battery so this took hours. I went down several rabbit holes trying to sort a non-existent problem.
You can’t add the meters to the Energy Dashboard while they are showing UNKNOWN.
Details
-
Grid Import Sensor
There’s some good info here: https://www.home-assistant.io/docs/energy/electricity-grid/
For me I already have suitable sensor from my Powerwall and Solar integrations so nothing else needed. You want a sensor that just counts up in Wh - counts energy not power. -
Utility Meter setup
Grab the utility meter integration https://www.home-assistant.io/integrations/utility_meter/
Go to Settings - Devices and Services and select Helpers. Create Helper - Utility Meter
Fill in the details. Meter reset cycle should be No cycle. Add two tariffs - Cheap and Peak - names are all that are required for now.
Submit
All being well you should see three new Helpers
- Set up Automation to switch meters at correct time
alias: Peak/Cheap rate select for Utility meter
description: ""
trigger:
- platform: time
at: "01:30:00"
variables:
tariff: Cheap
- platform: time
at: "06:30:00"
variables:
tariff: Peak
action:
- service: select.select_option
target:
entity_id: select.grid_import_octopus_go
data:
option: "{{ tariff }}"
mode: single
You could do this with two automations entirely in the UI (more here) but the Utility Meter Integration docs had this neat method using variables. Change the times to the times that apply to your tariff!
- Add new meters to energy dashboard
First check the state of the two meters is not UNKNOWN - Settings Devices and Services - Entities - click on the meter and select info. If there’s a number showing OK to proceed. If it’s UNKNOWN, just have to wait until you use some electricity!
Add the two new meters into the Electricity grid section of the Energy Dashboard - Setting Dashboards. Select Static price in the popup and enter the rate for meter you are adding.
Job Done!