I have a couple of rental units.
Each have a home made power meters that sends data to HA.
I have to let tenants know the consumption every month.
I do this by checking the energy tab in HA, but I then have to go into HA, to Energy, choose per month and then check the value.
I have made a HA link to each unit, which just shows power and accumulating kWh for them to check themselves. But it is not all that intuitive.
What I would like is two numbers, well four, kWh and $ for each of:
Last months consumption, no graph, no selecting dates, just a static number that will be replaced next month.
This month predicted consumption, same here, just a number. Calculation for this would be a simple prediction. kWh until now / hours until now * hours this month.
Thanks you so much!
I could not really figure out how to use yours but I used it to figure it out.
Using helpers, not YAML:
Optional, Helper input number to set the tariff, $/kWh
Helper utility meter with the specific kWh as input, this will create a value of the kWh that resets every month.
Helper template sensor with this as template: {{state_attr(‘sensor id from 1.’, ‘last_period’)}}, this will create a value of last months kWh.
Helper template sensor with this as template: {{states(‘sensor id from 2.’) | float * states(‘input_number from 0 (or just use the actual $/kWh here’) | float }}, this will create a value of last months cost of energy
Prediction of current month was actually not as hard as I expected, it seems to be correct so far. (I am using the newly created utility meter as input so it does not have much history yet, but seems correct.)
Helper template sensor with this as template: {{states(‘sensor id from 1.’) | float / (now().day *24 + now().hour + now().minute/60) * (((now().replace(day=1) + timedelta(days = 32)).replace(day=1) -timedelta(days=1)).day) *24}}, this will take the consumption for the current month until now, divide by hours of this month until now times the number of hours this month, which will equal the predicted consumption.
Helper template sensor with this as template: {{states(‘sensor id from 4.’) | float * states(‘input_number from 0 (or just use the actual $/kWh here’) | float }}, this will create a value of predicted cost of energy for this month