It depends on how you want to track things. For me I just use a sensor template to calculate my tariffs and am happy with getting just a total, but if you want your energy dash to show all the use for different tariffs you might have to create multiple sensors. What I like about this way of doing this is that as energy companies get more “creative” with tariffs I can adjust easily.
From there I just tell my energy dash to use this sensor for the tariff.
sensor:
- name: "Current Energy Tariff"
unique_id: e3eb0f96-c83a-41d3-8a01-a6df38895301
icon: mdi:currency-usd
unit_of_measurement: "USD/kWh"
state: >-
{% set tariff = { "OFFPEAK": 0.11, "MIDPEAK": 0.19, "ONPEAK": 0.27 } %}
{% set dow = now().strftime('%A') %}
{% if dow == "Saturday" or dow == "Sunday" %}
{{ tariff.OFFPEAK }}
{% else %}
{% if (now().hour >= 15) and (now().hour <= 19) %}
{{ tariff.ONPEAK }}
{% elif (now().hour >= 13) and (now().hour <= 15) %}
{{ tariff.MIDPEAK }}
{% else %}
{{ tariff.OFFPEAK }}
{% endif %}
{% endif %}