Trying to conditionally set an entity_id list, the second one here is creating an issue of not being a valid entity_id:
- service: tts.google_say
data_template:
language: >
{{states('input_select.intercom_language')|lower}}
entity_id:
- >
{{states('sensor.intercom')}}
- >
{% if states('media_player.theboss') not in ['unknown','unavailable'] %}
media_player.theboss
{% else %} None
{% endif %}
the {{states('sensor.intercom')}}
passes, because I set a condition in the beginning of the script this is a part of, using:
- condition: template
value_template: >
{{states(states('sensor.intercom')) not in ['unknown','unavailable']}}
which effectively checks if the selected medial_player exists.
however, I cant also check for the second player, which is always the media_player.theboss (a mobile device with browser_mod). If this isnāt touched it doesnāt exist, so returns None. Which is not a valid entity_id
How, I only need the tts.google_say part to see the second entity_id if it passes the test
{% if states('media_player.theboss') not in ['unknown','unavailable'] %}
and otherwise only play the first in the list.
Simply using:
{% if states('media_player.theboss') not in ['unknown','unavailable'] %}
media_player.theboss
{% endif %}
without else clause doesnāt guard it either of course.
Ive thought about a āhackā, using the identical media_player twice, but that doesnt feel very adequate
entity_id:
- >
{{states('sensor.intercom')}}
- >
{% if states('media_player.theboss') not in ['unknown','unavailable'] %}
media_player.theboss
{% else %} {{states('sensor.intercom')}}
{% endif %}
this seems to work (probably playing the 2 entity_ids simultaneously, as I hoped) but it really should be playing only the {{states(āsensor.intercomā)}} is that is available, and the media_player.theboss isnāt availableā¦