Energy Dashboard Teslemetry Weirdness Help

Using the Teslemetry integration to pull in energy information about my grid consumption, solar, and battery.

I get random fouled-up readings every night, which appear to be correlated with the Tesla battery discharging and then charging from the grid. If anyone has any suggestions on how to fix this, it would be greatly appreciated.

Energy dashboard freakout

Teslemetry provides 3 sensors, with positive/negative values representing charging/discharging the battery or producing/consuming from the grid.

To get them into the energy dashboard, first need split the positive and negative values and turn them both positive.

{% if not has_value('sensor.my_home_battery_power') %}
{{ this.state }}
{%- elif states('sensor.my_home_battery_power')|float >= 0 -%}
{{ states('sensor.my_home_battery_power') }}
{% else %}
0
{% endif %}

and

{% if not has_value('sensor.my_home_battery_power') %}
{{ this.state }}
{% elif states('sensor.my_home_battery_power')|float < 0 %}
{{ states('sensor.my_home_battery_power')|float*(-1) }}
{% else %}
0
{% endif %}

Then using integral helper create kWh sensors which can then be used for in to/from values in the energy dashboard.

It appears that over 4 hours or so about 1% of the battery is used to run internal processes. The battery then charges from the grid and the energy dashboard flips out.

Energy dashboard config

Energy consumption

Random spikes

Percent slowly draining