Passing an entity to from a button in Lovelace to a script

Hi everyone,

I’m trying to learn how to use parameters to pass information from a button in lovelace to a script using the variable {{ which_tv }}. I’d like to use one script to be able to change any television to any source depending on the button i use. I’ve been trying for hours but just cant get it to work.

Where am i going wrong?


Use “{{ tv_entity }}” (incl. double quotes) instead of media_player.tv_entity
Check out this example:

Thanks starob. Unfortunately I’ve tried that but it doesn’t work. I’ve since learnt from my FB post that it may be to do with conditions not accepting templates. It seems I need to use a template condition. Something like this… - conditions: “{{ is_state ( {{ tv_entity }}, ‘off’ ) }}”
I’m playing around with that now.