Stuck setting up Peak / Off-Peak Electricity tariff

Struggling with getting Peak / Off-Peak rate set up for Electricity Meter. All topics so far have directed to ‘Utility Meter’, I have gone through the set-up of Utility Meter several times but I can’t see where the enter the rate for each tariff - or the times each are valid.

At the end of setting up Utility Meter, I have three new entities:
select.electricity_meter, sensor.electricity_meter_off_peak & sensor.electricity_meter_peak.

I was expecting to enter the tariff rate and the hours to which it applies, but have not found this.

I can see that there is automation YAML in the Utility Meter help page for defining times for each tariff, I get an error when I try and paste this in as YAML though. Can’t see in any of the documentation where you provide a rate for each tariff.

Any help appreciated.


That’s not how it works.

You change the tariffs using an automation, triggered by time, or in other cases by energy used.

You calculate the cost using template sensors that multiply the utility meter tariff sensors by the rates.

OK, I understand (conceptually) changing tariff by time. I don’'t understand what is meant by ‘template sensors that multiply tariff sensors by rates’. Is there an example of what this may look like or a description of what it is achieving that I can read somewhere?

Many thanks

I’m trying to figure out this out as well, but haven’t yet done it yet successfully.

If I’m following, you create a simple utility meter now via the Helpers UI, but if the sensor source doesn’t provide the tariffs, you’ll have to create the utility sensor via the Config YAML file and indicate that it has two tariff rates. UPDATE - I just realized that it’s not a drop-down list in the Helpers UI for Utility Meter, but rather a field that you enter data and then it adds it as an option.

Then you’ll have to create an automation to switch the utility meter between the tariff rates based on time of day, month, etc.

And then you’ll have to create a template sensor to calculate the actual cost. e.g. here’s an example I found in this other thread that I’ll be using later to set up my sensors.

  - sensor:
      - name: Tariff Price
        unit_of_measurement: AUD/kWh
        state: >
            {% if is_state('utility_meter.daily_energy', 'DE_Peak') %}
                {{ 0.4961 * 0.73 }}
            {% elif is_state('utility_meter.daily_energy', 'DE_Shoulder') %}
                {{ 0.2052 * 0.73 }}
            {% elif is_state('utility_meter.daily_energy', 'DE_OffPeak') %}
                {{ 0.1675 * 0.73 }}
            {% else %}
                {{ 0.1675 * 0.73 }}
            {% endif %}

If I’m understanding, here’s the high-level steps:

  1. Create Utility Meter(s) with tariffs directly in YAML, not via Helpers UI UPDATE per above
  2. Create Automation to switch Utility Meter(s) based on plan details
  3. Create template sensor to calculate the actual charges at the rate for each tariff amount

Can anyone that’s set this up correctly confirm this is correct? And also, share their YAML for all three components or point me to a real example that’s fully configured?

For reference, here is my progress:

As described in first post, the set-up of Utility Meter created 2 meter entities, Peak and Off-Peak.
I then added these to the Energy Dashboard (Settings - Dashboards - Energy) and provided the GBP rate as a fixed rate (I tried to add as a number entity but did not work?).
The Energy Dashboard automatically calculates and sums the cost for each meter.

I also created a Daily Charge Meter that adds a daily charge of 0.21 each day as this is part of the billing. (I fudge this by adding 0.1 Kwh each day to that meter)

The automation to switch between peak and off-peak is based on UTC time as that is how the meters work (they can’t handle DST). It is as follows:

alias: Electricity Tariff
description: ''
  - platform: template
    value_template: '{{ (utcnow().hour | int == 0 ) }}'
      tariff: Off-Peak
  - platform: template
    value_template: '{{ (utcnow().hour | int == 7 ) }}'
      tariff: Peak
condition: []
  - service: select.select_option
      option: '{{ tariff }}'
      entity_id: select.electricity_meter
mode: single

The sensor that I created to calculate the daily charge is in configuration.yaml and is as follows:

  - platform: template
        friendly_name: "Daily Charge from 2022-06-01"
        value_template: "{{ (((as_timestamp(now()) - as_timestamp('2022-06-01')) / 86400) | int ) /10}}"
        unit_of_measurement: "kWh"
        device_class: "energy"
1 Like

I’ve been struggling with setting up peak/off-peak tariffs now for a few days, and now that I am finally starting to understand how it appears to work, I hope I am still missing some pieces and that maybe there is a better way to achieve the switching between peak and off-peak.

It seems that when you create a utility meter helper and add “peak” and “off-peak” in the “Supported tariffs” field, HA will create for you two sensors: one for “peak” and another for “off-peak”

Plus a “selector” which you need to switch with some automation according to whatever schedule you have for peak and off-peak rates.

That means you now have 3 entities required to track the peak and off-peak energy consumption, not to mention requiring a 4th entity to figure out the peak cost and then a 5th entity for the off-peak cost.

Maybe that wouldn’t be so bad if you only cared about calculating the costs for your entire house, but if you want to break the costs down by device, it seems that every device would need 5 entities? :exploding_head:

It’s quite annoying that you need a unique “selector” entity for every utility meter, even when your “supported tariffs” are the same across all of the utility meters (i.e. peak and off-peak). Then you need the automation to switch all of the selectors according to the same schedule :frowning:

And to make matters worse, it does not appear to be possible to configure an existing utility meter with tariffs after it has been created. You can only configure tariffs when you first create the utility meter. :sob:

Maybe it’s uncommon that people have different electrical tariffs, because the way this is implemented really appears like it’s really an edge case scenario, rather than a proper design. Where I live it’s optional to choose a flat rate or peak/off-peak tariffs, but I save about 10-15% on my electrical bill with tariffs rather in comparison to a flat rate.

I was also suffered about setting my two tariffs and the price along with them, and I would also like there to be a simpler solution, but I believe that the team will roll up their sleeves and do it right way and make it possible to do it all using gui or at least using custom component

1 Like