How to use variables within a conditional

I have a problem, I want to reuse the code of a script, passing the variables to him, but within the conditional he is not able to read.

code:
( input_select )
radiodespertadorsala:
name: ‘Escolha a Rádio’
options:
- ORF Radio

(script)
despertadorsala:
alias: Despertador da Sala
sequence:
- service: script.turn_on
entity_id: script.despertador
data:
variables:
entidade: media_player.jogos
radio: input_select.radiodespertadorsala

( script for reuse )
despertador:
alias: despertador
sequence:
- service: media_player.volume_set
data_template:
entity_id: ‘{{entidade}}’
volume_level: ‘0.40’
- service: media_player.play_media
data_template:
entity_id: ‘{{entidade}}’
media_content_id: >
{% if is_state("{{radio}}", “ORF Radio”) %}
http://mp3stream2.apasf.apa.at:8000/;stream/1
{% endif %}
media_content_type: ‘audio/mp4’

the problem is that the radio variable is not read inside the if, I’m probably putting the wrong syntax, I would like help

Ty

Instead of this:

{% if is_state("{{radio}}", "ORF Radio") %}

try it like this:

{% if is_state(radio, "ORF Radio") %}
1 Like

now it’s working, i knew there was something wrong with the syntax i always tried to put between {{}} but I saw that it is not necessary in these cases, thank you very much

1 Like

as it now works for you, please read this and consider formatting your config properly by enclosing it within three back quotes.