Energy Dashboard: Can I display both peak and non-peak in the graph?

I’m trying to figure out how to show both peak and non-peak electricity usage stacked in the same graph. My thought was to create two separate sensors for each, add them as sources to the dashboard. But I’m struggling to figure out how to do that. Can I use the utility meter integration? I’ve set that up with the two separate tariffs and have been able to use a template to automate cycling of the rate changes but I don’t see how I can call each of the sensors. I have:


Really like the energy dashboard, would be great to get this tweaked to show the two usage components. Thanks.

Well they won’t be stacked in the daily graph if the peak/off-peak is switched on the hour. The resolution is only hourly:

(Dark blue = off-peak, light blue = peak):

The week / month / year graphs will stack though:

Yes you can. Mine:

  source: sensor.metering_total_absorbed
  cycle: daily
    - peak
    - offpeak

Energy dashboard setup:

Screenshot 2021-10-16 at 09-59-44 Configuration - Home Assistant

Then you just need to automate the switching between peak and off-peak utility meter tariffs (you can do more than one at once if needed like I do below):

- id: 841ae395-4646-4c95-8991-14cdd7e9c834
  alias: 'Set Peak or Off-peak Tarrif'
  - platform: state
    entity_id: binary_sensor.peak_rate
  - service: utility_meter.select_tariff
      - utility_meter.energy_upstairs_heat_pump_daily
      - utility_meter.energy_hot_water_daily
      - utility_meter.energy_from_grid_daily
      tariff: >
        {% if is_state('binary_sensor.peak_rate', 'on') %}
        {% else %}
        {% endif %}

The binary sensor will depend on your utility’s schedule and will likely be different than mine:

- name: "Peak Rate"
  icon: "mdi:power-plug"
  state: "{{ (now().weekday() < 5) and ( (6 < now().hour < 10) or (15 < now().hour < 21) ) }}"

(peak rate if a weekday and between 7am and 10am or a weekday between 4pm and 9pm, otherwise off-peak.).

EDIT: This method of changing tariffs is now outdated. Please see the documentation for the new method that uses select entities.


Thank you! Looks like I have it all setup properly now. For some reason I could not get the energy_from_grid sensors to show up for selection in the Energy dashboard before. The rest of my automation logic was ok to switch tariffs. Much appreciated!

Hi, I hope it;s OK to jump on this thread. I am wanting to achieve this but being very new to home assistant and coding I am not sure where to start.

I can understand the binary sensor, but where do I put this code? I couldn’t see anything obvious. I want to record off peak as after 8:30 pm and before 01:30 a.m. how would I do this? I tried to hack the code above but just made a mess.

Also currently in the energy dashboard I am using a feed of annual energy consumption from an external API. Would this automation work with that? or does it need to be an instant report that it uses? I am worried that the update of the consumption will include everything from the last report e.g. at the start of peak the total is 5320kw reported as annual consumption, 20kw is marked to peak consumption, then off peak starts and the off peak sensor receives 5341 so adds 21 kw to the off peak consumption as the last off peak amount was 5320. Or will it not work like that?

If I get this done will it duplicate the current feed? will I need to remove it and lose history and add the off peak /on peak feeds to start from today?

Thanks for any wisdom you can share so that I can get this done. My inner geek is loving this stuff but just doesn’t have the ability yet.

I want to create these sensor based on these values

LESCO Tariff - Electricity Unit Price | LESCO

LESCO Electricity Unit Price

Lesco electricity unit price for domestic users are as follow:

> 1st 100 units price = Rs – 12.90 / unit
> After 100 units price = Rs – 13.54 / unit

For those in Australia NSW on Ausgrid, below is how I coded the peak, shoulder and off-peak times as a template sensor. Hope this can be of help as an example:

Australian Ausgrid NSW Peak-shoulder-offpeak sensor defined
Peak rates:
From 2pm to 8 pm on working weekdays during 1 November and 31 March;
From 5pm to 9pm on working weekdays during 1 June to 31 August
10pm to 7am
sholder: all other times 
{% set output = 'shoulder'%}
{% if ((now().month <= 3 or now().month >=11) 
       and (14 <= now().hour <= 19)) or 
      ((6 <= now().month <= 8 ) 
       and (17 <= now().hour <= 20)) and (now().weekday()<6) %}
    {%set output = 'peak'%}
{%else %}
  {%if now().hour>= 22 or now().hour < 7 %}
    {% set output = 'offpeak' %}
  {%endif %}
{%endif %}
{#if public holiday when peak does not apply #}
{# define public holidays falling on weekdays as a list of lists ['yyyy','mm','dd']#}
{% set holidays = 

{% set today_list = (now()|string)[0:10].split('-') %}
{# of peak rate time but public holiday, then shoulder rates apply #}
{% if output == 'peak' and today_list in holidays %}
  {% set output = 'shoulder' %}