[No Longer Maintained] Energy Cost Calculator

Tasmota for HE by markus-li

Found at: Hubitat/drivers/expanded at development · markus-li/Hubitat · GitHub

1 Like

The short answer is....probably not. That's a short coming of the driver. I would maybe be a little more inclined if I had a device that used the driver so I could do proper testing. Even still...the driver is using a non-standard attribute which is the root of the problem. That's made even worse by the fact that the dev of the driver you're using is no longer developing for Hubitat that I'm aware of.

Taking a look at the driver, you might be able to modify this method starting around line 91 (since there's three energy meter drivers in the link) and that will allow it to work with this app:

Summary
void parse(List<Map> description) {
    description.each {
	if (it.name == "energyToday") energy = energyToday
        if (it.name in ["current", "apparentPower", "reactivePower", "powerFactor", "energyToday",
                        "energyYesterday", "energyTotal", "voltageWithUnit", "powerWithUnit",
                        "voltage", "power", "energy", "switch", "level"]) {
            logging(it.descriptionText, 100)
            sendEvent(it)
        } else {
            log.warn "Got '$it.name' attribute data, but doesn't know what to do with it! Did you choose the right device type?"
        }
    }
}

Well, I'm not a coder, so I tried adding the change you identified, but no success.

I believe that the standard Tasmota commands use "energyToday". Refer to Commands - Tasmota

Thank you for at least considering and looking into this.

1 Like

Understood, but the driver devs should have converted that to the standard "energy" attribute used by Hubitat. That helps to prevent issues just like this one where an app is developed to a standardized capability/attribute but the device is not.

I ordered some Tasmota plugs so I can figure out what needs to change in the driver.

Understand.

I'll patiently wait and hope that the edits are small and easy for me.

Look forward to when you have time to investigate the Tasmota plugs.

1 Like

Version 0.3.5 Released

Most just some code cleanup changes for me. Also found a bug where certain variables were not getting a value set after installation until the app was opened the first time. Fixed that.

I think the next add will be to add an option to select a virtual switch that will correlate to rate overrides. This was inspired by this thread discussing critical rate periods that are dynamically set by power companies.

Still brainstorming on how to dynamically set holiday schedules.

1 Like

Just installed and going to have to let it run for a bit. I currently calculate energy cost with RM. So this could potentially allow me to remove several rules. Basically I have one rule per device.

One feature I would like to see is the ability to set the start of month. My utility company ends the month at midnight on the 28th of the month. We have a fixed rate so this will work well for me. Look forward to more updates. Thanks for you contribution.

1 Like

Can you ask them to not do that? :laughing:

1 Like

I can try, but I'm not hopeful. :smirk:

1 Like

Version 0.3.7 Released

Added an option to the "rate schedule" page to configure which day of the month the monthly reset will run.

@terminal3

Ok thanks, I just set it up we will see how it goes.

I just realized, however, that my setup may be a problem for your app. I assume your program does not reset the energy values of the devices. I know from my own setup that different devices use different commands to do that, and I assume you can't pull that from the device info .

At 00:05 on the 28th I reset all energy values. I graph daily, weekly, monthly energy levels for my whole house and monthly energy levels for individual devices that are on energy reporting devices.

How will resetting energy values effect your calculations?

1 Like

Just opened up the app to take a look and see what it showed and the cost for the freezer seems a bit off.

1 Like

Long story short....no problem. The app has code to handle the energy value being reset. I ended up writing it in because of your scenario. I have a number of Kasa plugs that the driver code resets the energy at the beginning of the day but other plugs that never reset unless done manually. The app can handle either situation.

Basically...I have a variable to capture the energy value at day start. If the energy reading for the device drops below that during the day, then I assume the energy reading has been reset and set that variable to 0. Since the cost is calculated based on how much the energy changed, it should be unaffected.

1 Like

Was this one setup today? Can you enable trace logging, do a refresh, and show the logs?

Here you go.

The info entry from 7:53 was before I turned on logging. That was when I entered the new reset date. When I opened the menu to update rate information I entred a new reset date. I then noticed the Energy Rate value was blank so I thought I needed to enter it again. So I re-entered the same value and saved it. Perhaps that is what caused the issue. If I remember correctly everything looked fine at that point.

{edit] It was not setup today. That has been in since I first set it up and I did not reset the freezer plug energy reading.

1 Like

Don't know if related but I checked the event log for the freezer plug and the last energy reading was at 8:01pm, no energy reading in the log prior to that. The event history is at the default of 20 and the reading at 8:01 was the 20th energy reading in the log.

So I assume the others were deleted due to the event log restriction.

1 Like

The rate entry will clear out once it's set. I think I'll add a display right above the input box to show the current rate so it doesn't look like it's been cleared like you ran across.

As for the cost being computed in the hundreds...I'm not sure. Even if you entered the rate a second time, it only applies from that point forward. The only situation that comes to mind is a typo when the rate was original put, then an energy update from the one device giving the wild calculation. When you entered the rate again, everything fixed itself.

For now, the only way to clear the current cost is to either let it age out (which would take a month) or reinstalling the app. Although, I could add a reset button, but would that would be easiest done to have it reset everything.

Is it possible to add devices from across multiple hubs connected to a single hub with hub mesh? In other words, I want to run this on a single hub in a 3 hub configuration but get data for all energy reporting devices across all three hubs in a single table. Thanks for the consideration

1 Like

Yes that is what I am doing. The rate calculator app resides on a hub that has no devices physically on it. All the devices are connected via hub mesh.

1 Like

I tried changing the rate slightly and it only seem to effect the today's cost. Which is now correct BTW. The weekly and Monthly are not, they still show a $200+ value. It seems to me if I change the rate it should re-calculate all values,

1 Like