Energy Dashboard improved support for net meter sensors

I have an “net meter” energy sensor. It increases when I consume grid power, and it decreases when I return power to the grid. With the current energy dashboard logic, this sensor does not work properly if added as either the “Electric Meter Consumption” entity or the “Electric Meter Return” entity. The Dashboard assumes that these values always increase.

Here is an example graph of my sensor (with my notes added.)

One way to support this would be to “ADD NET ENERGY SENSOR” which considers positive delta to be “Consumption” and negative delta to be “Return”.

This Configuration Thread explains some of the hacks that have been devised to get around this.