Below is one of a million itterations i’ve tried… no matter what i do i cannot get the defined variables to work…
any help would be great!
alias: NagViaAlexa
variables:
room: "{{ states('input_select.nagroomselector') }}"
m_player: |
{% if room == "Lounge" %}
{{ "media_player.lounge_echo" }}
{% elif room == "Kitchen" %}
{{ "media_player.kitchen_echo" }}
{% elif room == "Office" %}
{{ "media_player.office_echo" }}
{% else %}
{{ "media_player.lounge_echo" }}
{% endif %}
sequence:
- service: notify.alexa_media
metadata: {}
data:
target: "{{ states('m_player') }}"
data:
type: tts
message: "{{ states('input_text.nagmessage') }}"
description: ""
icon: mdi:volume-high
koying
(Chris B)
July 7, 2024, 10:46am
2
Demarcation101:
{{ states('m_player') }}
Did you already tried without the quotes?
IMO, the way you write it, it tries to read the state of an entity whose id is “m_player”, rather than using your variable.
I’ve tried loads of combinations
target: "{{ states('m_player') }}"
target: "{{ m_player }}"
target: "{{ 'm_player' }}"
target: {{ m_player }} - this is what I think should work....
target: m_player
I just cant figure out what’s supposed to work
123
(Taras)
July 7, 2024, 12:19pm
4
alias: NagViaAlexa
variables:
room: "{{ states('input_select.nagroomselector') }}"
m_player: |
{% if room == "Lounge" %}
media_player.lounge_echo
{% elif room == "Kitchen" %}
media_player.kitchen_echo
{% elif room == "Office" %}
media_player.office_echo
{% else %}
media_player.lounge_echo
{% endif %}
sequence:
- service: notify.alexa_media
metadata: {}
data:
target: "{{ m_player }}"
data:
type: tts
message: "{{ states('input_text.nagmessage') }}"
description: ""
icon: mdi:volume-high