You already have the template down, but since I don’t know what “a” is, I replaced it with checking the state of a sensor, which can be done with any entity using is_state:
{% if is_state("sensor.my_sensor", "Player 2") %}
or as a direct comparison like you were doing with “a”:
{% if states.sensor.my_sensor.state == "Player 2" %}
So in your script, you just have to make data into data_template
Quick question: What’s the difference between is_state("input_select.media_player", "Player1")
and states.input_select.input_select.media_player.state == "LivingRoom"
Sorry for the late response. Jbardi seems to have you helped out here. There is no real difference between the two statements mentioned by you except for the first one being shorter and imho easier to read.