I have two integration sensors that track the electricity going in and out of a battery. I want to calculate the energy that is currently in the battery. So I could just take the difference. However, because of conversion losses these values will drift over time.
I thought I could make an offset variable that I will recalculate every time the battery gets fully charged (I can observe that state).
However, it seems there is no way to write to such a offset template sensor, let alone properly define it.
Has anyone an idea if this can be done with automations or in HA at all?