Count only if

I currently have a counter running on a Shelly 1PM power sensor, which works well. In order to calculate the costs a little more precisely, I would like to add a counter in parallel, which ONLY counts when the house battery is < 5%.

So I know that the kWh with battery / PV cost me around 8 cents and the other one cost 25 cents (from the grid). Can this be done with a helper or do I have to put a sensor with calculation in my configuration.yaml.

Ideal would be a second entity in the counter helper or a condition that can be set

IF bla = 1
THEN count

can you share the yaml you have for your existing counter?

Its basically just a counter helper :man_shrugging:

yeah, I know the counter helpers. you said you have it currently counting your power sensor that you want to modify. could you post that yaml