Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95414

How to use variables within a conditional

$
0
0

@kleverson02 wrote:

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

Posts: 4

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95414

Trending Articles