Template variable in script call

You can’t use templates in lovelace without something like the template card.

Also why do you want to move it from the script to the UI?