Set cover position based on current position

That makes no difference. xx | int is the same as xx|int or xx |int etc.

You can’t use templates in lovelace service calls, you need a card like this in order to use templates in lovelace.

You also need to take into consideration when the position is currently < 25, because this will not work as you have it now.