#Template Value Reporting Wrong Value in "Individual Devices"

1 messages · Page 1 of 1 (latest)

grizzled moon
#

I have a few template sensors set up to track the remaining energy after individual devices. For example, I have "Living Room General" which measures the daily energy reported by the living room circuit using an emporia vue and subtracts the energy measured by two IKEA outlets at the aquarium and the TV:

{{
(0 if states("sensor.family_room_lights_and_outlets_energy_today") == "unknown" else states("sensor.family_room_lights_and_outlets_energy_today")) | float -
(0 if states("sensor.living_room_media_daily_energy") == "unknown" else states("sensor.living_room_media_daily_energy")) | float -
(0 if states("sensor.turtle_tank_daily_energy") == "unknown" else states("sensor.turtle_tank_daily_energy")) | float
}}

The issue is, the individual device usage on the dashboard is insanely higher than what is reported by the template. This is the case with all my templates calculating in this way. I have daily energy meter helpers set up for the plugs that don't reset each day, and those are what I'm using.

In this example for the living room, the correct value, and what shows on the device info, is around 1.069 kWh, but the energy dashboard reports over 28 kWh. I am having this issue with all the templates I set up this way. The actual monitors of the sub-devices looks correct on the graph (for instance Turtle Tank and Living Room Media in this case). What I would expect to see on the dashboard for "Living Room General" is a bar the size of the difference between "Living Room Lights and Outlets Energy Today" (which I added to show the total of what that breaker reads, but I don't actually need to visualize once all this is working) and "Turtle Tank" (pretty much ignoring "Living Room Media" since that's super low)

Does anyone have any ideas why there is such a discrepency between the numbers? I can see the discrepency in the detail usage "Untracked consumption"

vast galleon
#

What's the state class of your template sensors?

grizzled moon
#

They are all "energy" device class and "Total" state class

vast galleon
#

Can you show side by side history chart and statistics chart for Living Room General?

#

Also download and share an energy CSV for the same day.

grizzled moon
#

Sure - I think the history chart actually shows where part of the discrepency is coming from - There is a huge spike at midnight. But it doesn't answer where the rest of the untracked energy is coming from on the "Individual Devices Detail Usage" chart.

vast galleon
#

You probably shouldn't be making a total sensor based on daily-resetting values, since you don't have any way to set the last_reset attribute properly.

#

The only way you could really make it work is if all your inputs were lifetime sensors and did not reset, I think.

#

Doing "math" on energy sensors is pretty fraught with potential pitfalls and probably you should avoid it if all possible, since the inputs will update at slightly different times and produce weird values.

grizzled moon
#

Gotcha. Okay, I'll probably just show everything then, and eyeball the differences. I might try to make a "grouping" dashboard that shows the general bar above the specific devices. Thanks!

hoary river
#

Then it's easy to chunk into daily energy with a utility meter helper

vast galleon
#

My other idea is if all your sensors are daily resetting, intentionally force the sum sensor to be 0 between 11:59 - 12:01 am, and set the last reset attribute at midnight. Then you wouldn't get weird readings when the different source sensors update at different milliseconds.
But yeah using a power sensor + integral is good if you have it.

grizzled moon
#

I can try those out! Thanks