Energy Tariff calculation

Greetings folks,

Im new to HA, and hopefully I won’t be such an idiot to understand what you will say.

I’m currently waiting on this to arrive in couple days, but I took the time waiting for it trying to set up the tariffs and such.

I made an input_number helper and a fake sensor reading to simulate the reading from the clamps.

But i cant find a way to setup the tariff :

tariff range price/kWh
tariff 1 0-50 0.58
tariff 2 51-100 0.68
tariff 3 0-200 0.83
tariff 4 201-350 1.25
tariff 5 351-650 1.4
tariff 6 0-999 1.5
tariff 7 0-1000 1.65

How can i setup HA to calculate this?
Im open to any suggestion, or 3rd party add-on

thanks a lot in advance.

Hi, I suggest that you first have a look at the Utility Meter integration for an overview of how this typically works:

You probably need to create a Utility Meter with a monthly cycle, you will also need to create an automation that changes the tariff at the relevant changeover times and the documentation provides an example of how to do this with 2 tariffs (peak and off-peak).

You can then create an energy dashboard (Settings - Dashboards) to visual the data and see the energy used and cost for each of the tariffs. The following provides an overview of how to do this:

thank you for helping out, Energy meter tariffs with peak/offpeak are out there and easier to setup, but in my case its useless. as my tariffs are based on kWh.

I couldn’t find a way to do it in the Energy dashboard, so I made an input_number helper for each tariff, and a sensor with the following:

template:
  sensor:
    - name: kwh_cost
      unit_of_measurement: "EGP"
      state_class: total_increasing
      device_class: energy
      state: >-
        {% set kwh = states('input_number.read')| float(3) %}
        {% set t1 = states('input_number.t1')| float(3) %}
        {% set t2 = states('input_number.t2')| float(3) %}
        {% set t3 = states('input_number.t3')| float(3) %}
        {% set t4 = states('input_number.t4')| float(3) %}
        {% set t5 = states('input_number.t5')| float(3) %}
        {% set t6 = states('input_number.t6')| float(3) %}


          {% if kwh <= 50  %} {{kwh * t1}}
          {% elif kwh <= 100  %} {{((kwh - 50) * t2) + 50 * t1}}
          {% elif 100 < kwh <= 200  %} {{kwh * t3}}
          {% elif 200 < kwh <= 350  %} {{(kwh - 200) * t4 + 200 * t3}}
          {% elif 350 < kwh <= 650  %} {{(kwh - 350) * t5 + 150 * t4 + 200 * t3}}
          {% elif kwh <= 900  %} {{kwh * t6}}
          {% else %} false {% endif %}

Currently, for testing purposes, its source is manual input_number helper, till the CT Clamps arrive.

Is there any cleaner way to accomplish same result ?