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.
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.
Optionally set the currency symbol for dashboard displays/variables.
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 .
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.
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.
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!
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.
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.
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.
"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 !
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.
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.
@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.
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.
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.
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.