Create entity with daily- and monthly cost

Hi,
I would like to create two different entities based on my fixed electric price I have for another year.

  • daily entity accumulates my electric usage x the cost I have and resets every night
  • monthly entity accumulates my electric usage x the cost I have and resets first day of every month

Can someone please help pointing me in the right direction to start this?

Thanks!

1 Like

I have a helper text input that defines my fixed price per kWh.

I have a sensor that tracks my total kWh.

Then I create a template sensor that multiplies the two above.

After that I created utility meters for daily, weekly, monthly price based on the template sensor value.

Ok thanks. Never done templating, mind sharing the code?

This is what I use:

    estimated_energy_cost_total:
      friendly_name: Estimated energy cost total
      icon_template: mdi:cash
      unit_of_measurement: "SEK"
      value_template: "{{ (states('input_text.electricity_price_per_kwh')|float) * (states('sensor.home_energy')|float) }}"

input_text.electricity_price_per_kwh is a helper where I define my fixed cost per kWh (in my case the value is “2.02”) (thank you Swedish government for increasing it with about 100% lately lol)

sensor.home_energy is a Powercalc group sensor that accumulates all my home energy consumption in total.

What I do then is that I create Utility meters as helpers for tracking it periodically:

image

Ok thanks for sharing the code dear countrymen! :wink:
Might need some more help to get this going:

  1. First I create a helper called input_text.electricity_price_per_kwh
    What type is that helper?

  2. then I create a template using your code above

  3. What is a power calc group? another template?

Swedish: Kör EON nu pĂ„ 0.54 öre 1 Ă„r till
blir tibber sedan! :wink:

1 Like
  1. Under Settings > Devices & Services you can add a Helper under the Helpers tab.
    In this case I have used the Text helper:

Then I have set the value:

image

  1. Corret

  2. Powercalc is an addon that you can find in HACS: GitHub - bramstroker/homeassistant-powercalc: Custom component to calculate estimated power consumption of lights and other appliances

Swedish: Jag hade EON 0.60 öre fram till 1 nov. Nu har jag Fortum 120 öre 3 Är framÄt. TÀnk pÄ att du ska rÀkna med energiskatten och nÀtavgiften med för att du ska fÄ fram ditt totala pris. I mitt fall Àr 2.01 SEK/kWh alltsÄ 120 öre + skatt och avgifter frÄn EON.

1 Like

I am using my sensors to show me the value like this:

With Powercalc you can create groups of energy/power sensors to get better understanding of your usage:

1 Like

Thanks - trying to configure it now. Will get back to let you know!

Swedish: Har 0.52 SEK i grundpris / kWh och har lagt till skatt o skit sÄ har fyllt i 1.25 SEK i kostnad. Tror det Àr ganska rÀtt. :slight_smile:

1 Like

Hi again, not sure I got things correct


  1. created a helper (see image below)

  2. Installed powercalc and configured the needed devices:
    image

  3. added the template in configuration.yaml:

  - platform: template
    sensors:
      - billaddning_power:
          friendly_name: "Billaddning"
          unit_of_measurement: "W"
          device_class: "power"
          value_template: "{{ ((states('sensor.easee_power')) | float * 1000) | round }}"
      - estimated_energy_cost_total:
          friendly_name: Elkostnad
          icon_template: mdi:cash
          unit_of_measurement: "SEK"
          value_template: "{{ (states('input_text.electricity_price_per_kwh')|float) * (states('sensor.home_energy')|float) }}"

Would like to have an entity that shows the cost today in SEK (and resets every night) and one entity showing the cost of the month (and resets every month).

You are halfway there!

Next you need to create utility meters. That is done in the Helpers section under Settings as well. See my previous post where I explained that step.

You will need to create a utility meter per period you wish to track.
For example one for monthly, one for weekly and one for daily.

Use your template sensor “estimated_energy_cost_total” as the input sensor.

Got it now, I had a typo in the helper as well.

Have only added a few of my sensors now, but looks good.

Thanks for your help!

1 Like

Great! Please mark my reply as answer if you wish :slight_smile:

Lycka till!

its possible to calculate the cost with variable rate cost of energy? (daily, peak , night) for a specific item?

Hi Guys. I might be a little off topic.
Has anyone managed to create entity which adds daily charge in to the total used energy?
I have 2 tariffs meter which I know how to automate it so they calculate peak and off peak separately. I am trying to figure out how to add daily charge in to daily usage. Basically my bill is made of 3 charges.
Peak time usage (ÂŁ/kWh) plus off peak usage (ÂŁ/kWh) and daily charge (ÂŁ/day).
Can anyone help please? :pray:t3::pray:t3::pray:t3::pray:t3: