I have solar, and my electric service has what I understand to be the usual configuration in my area (New England, USA): I have one meter which measures total solar produced (whether used on-prem or returned to the grid) and one net meter which measures consumption from and production to the grid.
I already have an RTL-SDR raspi configured to get the energy readings from those meters; previously it was reporting them to a cloud database, but now I'm having it send the readings to HA's MQTT broker.
The problem is that HA wants to have one reading for consumption and one for return, and I simply have no way to get that information reliably and locally. I looked through the existing documentation, support threads, and FAQs, and I found @torpid imp's FAQ gist, which discusses how to split a net power sensor into two entities which can then be integrated into separate net energy entities.
I figured that was similar enough, so I went through the same process: I created a Statistic to turn the most recent two meter readings into a positive/negative energy delta, created two Templates to split that into a pair of positive energy delta readings, and then created two Utility Meters (using the "delta values" option) to sum those readings into a lifetime total.
The problem is that it isn't accurate; this method consistently underestimates values, despite not performing any multiplication or division; this chart has the "measure" values being the consumption values reported by the Energy Meter I set up above, and the "calc" values represent the raw physical net meter's value minus the value of the production meter; accurate only if solar production is insufficient for the house, which is why this chart spans just a single night.
I have a guess as to why this is happening: I think that in at least some of these indirections (physical cumulative net meter ⇒ virtual delta net meter ⇒ virtual delta split meters ⇒ virtual cumulative split meters) the data is only processed when the source value changes. So, when the physical meter reports the same cumulative value as before, the delta meter doesn't read zero, it simply omits the data point. When the same amount of energy (reported in units of 0.01 kWh) is consumed over two subsequent updates, the split meters omit that data point, and so it never gets aggregated by the Utility Meter integrations.
I feel that the only supportable way to do this calculation is to keep in in the realm of cumulative numbers; perhaps there could be a Utility Meter option (for non-resetting sources, like a physical utility meter) that specifies that it should only track the positive (or negative) deltas in the cumulative reading? I could potentially submit a PR to add such, but I'm new to HA as of two days ago, and I'd like to at least get the basics up and running before I start having to source-dive and write custom code. Is there another way to accomplish this that won't suffer from the same underrepresentation I'm seeing now?
Also, is there any plan to add "Net Consumption" as a directly-supported configuration option in the Energy Config screen? I'm personally willing to jump through hoops like this to set up my HA installation because I'm disabled and don't have a day job, but I'm not going to be recommending it to my friends if the most common utility configuration isn't supported.