He hands over the entity_id as a variable to the script and not the state of the entity_id, that’s why he needs states(position_var)
to get the state of the entity_id passed to the script.
@CeeCee
You can’t just use a template in lovelace like you tried, you need something like this.