There’s an automation to have media casted when you have two radio select inputs with one having a chromecast selected, and another with the media, but the part I have below is to stop the media being casted, which is where my confusion lies.
When the user selects None
in the input select with the chromecasts listed, it should stop the media playing on whatever chromecast was selected, but the trigger in this code is when the user selects None
, and at that point the code has no clue what was previously selected.
- am I correct or am I missing something?
- how would you actually accomplish this if i’m not incorrect
code:
automation:
- alias: Stop Streaming Radio
trigger:
- platform: state
entity_id: input_select.radio_station
to: "None"
action:
service: media_player.turn_off
data_template:
entity_id: >
{% if is_state("input_select.radio_player", "Mansarda") %}
media_player.bed_2
{%-elif is_state("input_select.radio_player", "Doccia") %}
media_player.bed_3
{%-elif is_state("input_select.radio_player", "Bed") %}
media_player.bed
{%-elif is_state("input_select.radio_player", "Bath") %}
media_player.bath
{%-elif is_state("input_select.radio_player", "Salotto") %}
media_player.salotto
{%-elif is_state("input_select.radio_player", "Salotto Video") %}
media_player.salotto_video
{% else %}
none
{% endif %}