#Write to template sensor in automation

1 messages · Page 1 of 1 (latest)

swift basin
#

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?

long galleon
#

It’s possible with a trigger-based template sensor using a custom event as a trigger with a payload, but it would be easier to feed the template sensor you already have into a utility meter entity. Then you can use the utility_meter.calibrate service to reset the value every time the battery is charged

swift basin
#

Ok, thanks I will try. I find the utility meter a bit complicated but if it works I'll figure it out