[No Longer Maintained] Energy Cost Calculator

What is this?
An app for calculating energy costs. The app leverages the new table method provided by Bruce to give a nice graphical display of costs per device and totals. The cost value for each device, along with the total, can be mapped to a hub variable. The hub variables can be used to display the cost in a dashboard tile or have a connector device created for sharing via Maker API.

The energy consumption and cost values are updated anytime there is an energy update from any device, when the app page is loaded, or when the "Refresh Table" button is clicked.

Additional Screenshots




How to Set A Static Rate:
  1. Go to the rate page:
  2. Ensure the toggle is disabled.
  3. Enter your rate per kWh information.
    Note: Numbers only. The input field will clear anything extra automatically. More than one decimal in the input will result in grave peril.
  4. Optionally set the currency symbol for dashboard displays/variables.
  5. Click Next

Repeat these steps to update the rate information as needed.

How to Set A Rate Schedule
  1. Go to the rate page:
  2. Ensure the toggle is enabled.
  3. Click the "Add rate schedule" button
  4. Give the schedule a name.
  5. Select "Days of Week", "Start Time", "Months", and "Rate Cost".
  6. Optionally set the currency symbol for dashboard displays/variables.
  7. Click Next
  8. If ever needed, the "Manual Override" box can be used to immediately change the rate cost.

Limitations
  • Rates - The app, at present, can not accommodate ad-hoc rate settings (like critical rate periods that are called whenever the power company deems necessary).
  • Data - This app is only capable of tracking usage from the time that a device is added. If a device is added, removed, and added again, all values will be reset to 0.
Drivers/Historical Data
  • There are scheduled jobs to grab the required data for the historical tracking.
  • At 12:01 am, the app will grab the current energy value for each device. As energy for the device is updated throughout the day, the value at the start of the day is subtracted from the current value to determine that day's usage. If the device driver does something unexpected with the energy value after the 12:01 run, then the data could be skewed (or if the energy value is manually reset).
  • Weekly usage is reset on Sunday at 12:00:40 a.m.. This is done by copying the "usage this week" over to "usage last week" and then resetting "usage this week".
  • Monthly usage is reset on the first day of the month at 12:00:45 a.m. and uses the same process as the weekly usage.
  • "Energy Use Last Month" and "Energy Use Last Week" are static values after the above jobs have ran. That means the values for the "Totals" will not update, even if a device is added/removed.

Probably others that I've yet to discover/think of.

INSTALLATION

Can be installed using HPM; just search for "Energy Calculator Plus"

Manual installation requires just the app. All code can be found in my GitHub repo .

My Other Apps

[No Longer Maintained] Sensor Groups+
[No Longer Maintained] Window Tracker
[No Longer Maintained] IoTaWatt+ [BETA]

16 Likes

Known Issues

  • None.

To-do List

  • Update the first post (holy buckets a lot has changed).
  • Discard abnormally high energy reports.
  • Add rate scheduling.
  • Incorporate rate adjustments into cost calculation.
  • Handle holidays in rate scheduling.
  • Add option to use a virtual switch temporarily set a new rate cost (like critical rate periods).
  • Add user verification when rate value is above 1 unit (e.g. $10, €10, etc.)
  • Move advanced features to their own page.
    • Day of month selection for monthly reset
    • Reset options for the table (e.g. reset by device for day/week/month, reset all)

Feature Requests (Not Guaranteed)

2 Likes

Very nice!

2 Likes

Excellent work!
Look forward to the update with historical data.

1 Like

Shweeet. Thanks for this.

I love energy monitoring data. :nerd_face:

1 Like

Dayum.... More chill stuff.

2 Likes

I set this up and it didn't let me select any of my Iris v2 outlets, and I wondered why. They only report power, and do not collect the cumulative energy consumption in the driver state.

I know it's a different approach than you've taken in this app, but it would be nice to get this table to support any device that reports power consumption. Although maybe that's done by asking the drivers to be updated to support cumulative energy.

1 Like

Correct. Power companies calculate costs based on energy usage. Energy is power over time. Power is just a point in time reading. So, something needs to constantly read power usage while keeping track of time to accurately calculate energy usage. I don't think that'll be feasible in an app.

1 Like

I thought a good approximation could be done by the app subscribe to power reports from the device and having a energy accumulator for each device. When the power value changes, it would add (power * delta_time) to the energy accumulator. Similarly, the table would show the (accumulator + power * delta_time) when displaying the table.

That was how I initially thought this app was going to work.

But, that's a complication, and perhaps a different app!

2 Likes

That could, and probably would, result in wildly inaccurate results. Easiest scenario to highlight the challenge would be the power meter plug on my dryer. I have it set to report power changes of >500W to cut down on spamming the z-wave mesh. Here's some reporting from a cycle last night.

2022-12-29 00:10:11.662	 6218
2022-12-29 00:07:41.661	 545

So, during that three minutes, did we use .3 KWH or .027 KWH? Stack that over a day/week/month and you can see how the problem would compound very quickly.

1 Like

If you wanted the app to compute a reasonable approximation for energy usage on a particular device, you'd want to not use high values on those devices.

Do any of the device handlers already use this sort of algorithm internally? E.g., my Aeotec Smart Energy Switches (which show up here) have a setting for Minimum Watts Change Report value. Does that affect the energy value it reports? Is it computed in the device and reported, or is it computed in the device handler? There's no way I can see to reset it, for instance.

1 Like

"It's a Christmas Miracle" I am blown away by the talent of our staff/users/developers. Almost every visit here I see another piece of functionality, that makes HE even better.
Thanks to all !

5 Likes

From what I can tell with the Aeotec Heavy Duty Smart Switch, Zooz ZEN15, and Kasa plugs that I have, energy is calculated on the device itself. I even wrote a small app that would let me reset the energy value for any device. All of them just go back to their previous reading with the next update.

1 Like

How well would this work with iotawatt or is it fairly device agnostic?

1 Like

As long as it reports energy, it'll work with the app.

1 Like

Sneak peak:

I'm still doing some testing around scheduling readout resets and what-not. My plan is to add cost columns for this week and this month along with the option to also set those to a hub variable. Also need to run back through the changes I've made over the last few days to better write some of the logic.

5 Likes

@FriedCheese2006,
Thanks for this. I am not sure why the readings for my Tasmota plugs are not being populated?
I've just tested the plugs in Home Assistant and the data populate fine in your table.

Table

Computer status in HE

image

Exercise Machine status in HE

image

1 Like

The driver directly in HE is not setting the normal attribute of "energy" but is using a non-standard attribute of "energyToday" instead. I presume when you bring the same data over from HA, it's using the "energy" attribute like normal. I would suggest asking the driver author to update the driver to use the standard energy attribute or you can edit it yourself.

1 Like

Version 0.2.1 Released

  • Significant UI Overhaul - created a new page for linking the cost data to hub variables; complete with it's own table. Updated color coding to hopefully make the data easier to read (feedback is welcome here).

Ignore the negative values; the issue causing those has been fixed (like 90% sure)


  • Historical data - added tracking of energy usage over the current/past week and current/past month. Variable options have been added to allow linking the costs for 'this week' and 'this month' per device along with totals.
3 Likes

If it works for my tuya zigbee 3.0 plugs I'll be ecstatic. Have been fighting the electric company for ages and have proved they're overcharging me by 10% at least. Fun since also fighting breast cancer and fibro.
How'd you manage to get a black background, the white fries my eyes and its more power hungry on a lot of phones.
Incidentally has anyone else had outlets switching themselves off for no discernable reason? Two were running a fridge and freezer amongst other things, but the third is running reptile lights and two hubs.. Doesn't happen with the same plugs on Shartlife

Thanks for all the work. If it works with my gear it'll be absolutely perfect.

Rosie.

1 Like