Energy per device with costs

I have been trying for some time to measure devices for which I have an energy plug in Home Assistant and to map out the costs.
So far I haven’t really been able to do that.
I was a Homey user for years and there is an app called Power by the hour that measures everything for you without too much hassle.
I have been working on the utility meter in Home Assistant and I think it is possible to get a picture of the consumption measurements, but the costs are a different story.
Maybe someone can help me with one of my devices so that I can then do it myself with the rest of my devices.
I have a smart plug on my air conditioning called Daikin Emura and I have 2 tarifs for day and night electricity. On weekdays the night tarif of € 0.22422 starts at 23:00 and the day tarif of € 0.22664 starts at 07:00. There is also a night tarif on weekends.
How can I get an overview of the daily, monthly and annual consumption and what the costs are based on the two tarifs?

Thank you in advance.

Doing it using template sensors, with or without utilitymeters is doable but hard.
However, I don’t use it myself, but this custom integration looks like it can do wht you need:

I just raw dogged it with templates and input helpers. Been trying to brainstorm an idea on keeping historical bill data (estimated from Hass and actual usage input from paper bill).


Here’s the template for the “Estimated Due (Current)”, can see its a bit involved.

{%- set last_read = states("input_number.water_meter_bill_last_read") | float %}
{% set total_used = (states("sensor.watermeter_meter_should_read") | float - last_read) -%}
{% set more_than_10 = (total_used / 10 >= 1.0)%}
{%- if more_than_10 is true -%}
{% set first_10 = 10 -%}
{% set after_10 = total_used - 10 -%}
{% else -%}
{% set first_10 = total_used -%}
{% set after_10 = 0 -%}
{% endif %}
{%- set cost_first_10 = (states("sensor.water_first_10_m3_cost")) | float -%}
{% set total_first_10 = (first_10 * cost_first_10) %}
{%- set cost_after_10 = (states("sensor.water_after_10_m3_cost")) | float -%}
{% set total_after_10 = (after_10 * cost_after_10) %}
{%- set total_usage = ( (total_first_10 + total_after_10)) %}
{%- set tot_serv = (( states("sensor.water_service_charge") | float) + (states("sensor.water_fire_protection_cost") | float)) %}
{% set usage_total = (total_usage / 100) + tot_serv %}
{%- set sani_cost = (states("sensor.water_sanitary_service_cost") | float) %}
{%- set storm_charge = (states("sensor.water_storm_water_charge_per_month") | float) %}
{%- set wastewater_cost = (states("sensor.water_waste_water_per_m3") | float) %}
{%- set sanitation_cost = ((wastewater_cost / 100) * total_used) %}
{%- set sani_total = sani_cost + storm_charge + sanitation_cost %}
{%- set wastewater_treat_cost = states("sensor.water_waste_treatment_cost_per_m3") | float * total_used  %}
{%- set treat_total = (wastewater_treat_cost / 100) + (states("sensor.water_waste_water_treatment_service_charge") | float) %}
{% set water_total = usage_total + sani_total + treat_total %}
{%- set garbage_cost = (states("sensor.water_garbage_cost") | float) %}
{% set abs_total = (water_total + garbage_cost) %}
{{ abs_total | round(2) }}

Here is a post I made a few years ago that I think explains the calculations pretty well. There is a lot of detail there, but if you just focus on the the way I calculate costs for the devices I grouped, it should essentially be the same process. Starts in section “Simplifying the energy calculations.”

Here’s some of the addition information from the post about adjusting for different rates.

Hope it helps.

1 Like

Thanks for the responses.
For now I will stop trying addons like Dynamic energy cost and powercalc because it does not give me what Power by the hour does in Homey.

For now I abuse the Energy dashboard of Home Assistant to add my devices there with the electricity price and then it shows exactly the same as what I see in Power by the hour.

I say abuse because the Energy dashboard is not really meant for that but in the part where it is meant to add external devices I only see the consumption per device but not the costs.

I hope that this functionality of adding external devices to be able to see electricity consumption and costs will come to Home Assistant.
And also that you can use this in multiple ways and read it out or send it somewhere with a notification. That is not yet possible from the Energy dashboard.