[No Longer Maintained] Energy Cost Calculator

I'll see what I can do. Added it to the request list in post #2.

1 Like

Thank you!

1 Like

It would be nice to also see how much in $$ it's actually producing as well. For me, my Net Metering cost is the same as my consumption cost 1:1 but others may have a lower production cost vs consumption cost in their net metering rules within their state.

1 Like

Version 0.4.2 Released

PSA: If you run into an error, please get me the error message from the logs page. If you don't, I have no way to know what went wrong nor how to prevent it from occurring again. Please and thank you.

Added reset options for individual devices.

A known issue (that I thought of right after releasing) is that you have to complete the prompts or they will hang.

For example:
If you go in and select a device, but then back out, then next time you go in, the selection will be at the same place. The only way to reset the selection is to go all the way through the prompts.

1 Like

Version 0.4.3 Released

Hotfix for reset menu selections. They should all reset if the page is left without completing to prompts.

1 Like

@iEnam @djh_wolf @Noob_using_hubitat

If you are using Markus' Tasmota driver (the Oh La labs branded one), you can update the "Tasmota - Universal Metering Plug/Outlet (Child)" driver with this one and it will allow you to directly use the plugs in this app (I'm just copying todayEnergy to "energy").

If you are using Gary's version I've got a pull request in to them for the single outlet driver to add the energy attribute.

I've only done basic testing so let me know if you find issues with either update.

1 Like

Cheers for the thought/work.

I'm actually using this:


... Which I've found to be awesome.

The issue with these plugs appears to be that sometimes, if you pull the power (the other half does this occasionally because she's annoying - I need to hide them!). When power is restored, the current 'energy total' isn't always saved correctly on the device. I'm assuming this isn't saved 'in real time' and is instead periodically written to the device's flash?

This results is slightly out of whack energy readings.

See the results here:

Edit

Also, the devices rely on their individual tasmota timesettings, per device. This caused a fair bit of confusion at the start, and I'm not going to fanny around attempting to check/ensure each plug has the time set correctly. Stuff that, I'd rather work from a hubitat clock. This obviously also screwed the 'energy today' figures, and thus my approach is now to take stock of the first reading of the actual day, and calculate from there using timestamps to compare.

/edit

For this reason I've knocked up a fairly horrible bit of webcore, but it works. Essentially whenever a figure is saved as a webcore variable for that day, it records a timestamp. If that 'daily timestamp' has expired (midnight), then it's overwritten as a new week and wipes the remainder of the week's figures, because it assumes the plug has been left out of the socket for too long. Same deal for weekly figures (I want to see last week and this week).

Also, if the energy reading for that day is somehow slightly less than the end figure from yesterday (should be impossible, but this happens when unplugged for a bit), then that day is essentially zerod from then and a new set of figures for that day begins.

It's never out by far (a few pence at a guess), but it satisfies my ocd.

As I said, horrible bit of webcore but currently perfect for my needs.

I just need to work on tracking total time on/off, taking into account midnight crossovers, which'll allow me to calculate actual costs per hour per device and allow me to add some decent restrictions for "only allowed to run for x amount of time per day" or "max cost per day".

Out of curiosity, here's my bathroom dehumidifier, running in at a total of 7p for the week so far (although I only applied the code late last night and it's about 6am here Tuesday now).

Also, the washing machine which had one cycle yesterday (26p) and is currently mid cycle this morning (2p) - using different settings to see the actual difference in cost using different temperature cycles...

1 Like

The driver you show is the second link. I'd need to make the same edits to the double plug, but that'll take about 30 seconds to do. My edits are copying "energyToday" over to the standard "energy" attribute so that they can be used with this app.

This app will do most of this for you.

At midnight and 11 seconds, I grab the current energy reading and set that to a variable for each device (dayStart). Every time there's a refresh or energy update from a device, the current energy value is pulled again. I first do (current - dayStart) to make sure it's not a negative. If it is, then I know the energy reading was reset, so I reset dayStart back to 0 and then try again. A positive result is written today's energy.

The today's energy reading is added to the week and month for the device, along with the total for the day. I then calculate how much energy has been used since the last reading (energyUse). This is multiplied by the currently set rate to get the cost amount which is added to daily, weekly, monthly, and totals. This approach allows for the energy cost to be calculated on a rolling schedule, if need be.

EDIT
Updated the other driver:
Single plug
Double plug

1 Like

I'm looking for feedback.

I'm basically at the maximum width for the table before the display starts getting funky. This is problematic since I can't add more columns (like average daily use/yesterday use). I have a few different ideas (and am open to others) about how to keep expanding.

My initial thought is to break out cost into its own table. This would give two tables...one for usage and the other for cost. My initial thought is to keep them on the same main page like this:

But, could also move the cost table to its own page like the variable table.

Anyone see issue with this or have an opinion one way or the other?

2 Likes

Excellent, thanks for this.
I've used the single plug driver (Gary's version) and it is working now as expected.

1 Like

This looks great and much cleaner on it's own page with energy usage and cost separated.
Also, is it possible to display the whole table on a dashboard?
Thanks again for the excellent work!

1 Like

I was going to say no, but then again....maybe.

1 Like

The answer is no. I had a thought to dump the string used to generate the table into a variable, but hub variables have a max length of 255 characters. It won't work.

For me I really only care about cost. I am graphing energy usage so maybe an option for just usage or cost or both?

1 Like

I could auto-hide the table sections. Something like a dropdown menu where you select which tables to show by default with options for:

  • Cost
  • Usage
  • Cost and Usage

Then, the table sections will auto-hide based on the selection. They'll still be there, just tucked away.

Version 0.4.4 Released

Small update mainly for new users but serving as a proof of concept for me.

A new install will show this:

And after installation, those two sections will hide by default.

2 Likes

I feel like I've potentially wasted my time, as this app appears from the shots to be far better than my webcore attempt.

I only attempted mine because at the time, there was no alternative.

The one part I can't see (and haven't accomplished myself, satisfactorily) is tracking the 'time on' figures too.

This would allow me to set maximums and report actual average costs/hour.

My current logic is based on a seperate virtual switch, which is flicked on/off according to rules which are tweaked per device, linked to power consumption.

Eg washing machine needs to have near-zero power change for say, 2 minutes before being confirmed as off.

Is any of this something you plan on adding?

Awesome work here....

2 Likes

Tried a reset of an individual device and it didn't seem to work. Or perhaps I don't understand what it's supposed to do.

See screenshots below.
Just before I hit the next button to commit change

This I believe, is the pertinent part of the debug log.

This is what the device looks like after the change, Exactly as it did before I tried to reset it.

1 Like

It's failing to get the right device ID. What type of device is that?

It's a virtual omni sensor.

1 Like