Tsar
(Christian)
1
I made a list of radio stations :
radio_station:
name: Select Radio Station
options:
- MNM
- Joe
- Radio 2 West Vlaanderen
initial: Joe
icon: mdi:radio
I made a script to play the selected radio station :
--------
data:
media_content_id: >
{% if is_state("input_select.radio_station", "Radio 2 West-Vlaanderen")
%}
http://icecast.vrtcdn.be/ra2wvl-high.mp3
{% elif is_state("input_select.radio_station", "Joe") %}
https://20723.live.streamtheworld.com/JOE.mp3
{% else %}
http://icecast.vrtcdn.be/mnm-high.mp3
{% endif %}
media_content_type: music
------
Now I tought of creating a new list with these url :
radio_station_media_content_id:
options:
- http://icecast.vrtcdn.be/mnm-high.mp3
- https://20723.live.streamtheworld.com/JOE.mp3
- http://icecast.vrtcdn.be/ra2wvl-high.mp3
But how to retrieve the key ?
Maybe this is not the way to go…tell me if so too
Here is what I have. The names of the variables have to match the options in the input_select though:
script:
media_radio_play:
variables:
stations:
radioEINS:
url: "http://radioeins.de/stream"
Byte_FM:
url: "https://dg-ice-eco-https-fra-eco-cdn.cast.addradio.de/bytefm/main/mid/stream.mp3"
Deutschlandfunk:
url: "http://st01.dlf.de/dlf/01/128/mp3/stream.mp3"
Dradio_Kultur:
url: "http://st02.dlf.de/dlf/02/128/mp3/stream.mp3"
Dradio_Wissen:
url: "http://st03.dlf.de/dlf/03/128/mp3/stream.mp3"
Flux_FM:
url: "http://fluxfm.hoerradar.de/fluxfmberlin-live-mp3-hq?sABC=5oq9q1s9%230%2364oqr465o841p6ssop6603q1p4o3174p%23nhqvb&amsparams=playerid:audio;skey:1541001721"
FSK_HH:
url: "http://stream.fsk-hh.org:8000/fsk.ogg"
Jam_FM:
url: "http://stream.jam.fm/jamfm-live/mp3-128/"
Kiss_FM:
url: "http://stream.kissfm.de/kissfm/mp3-128/internetradio/"
KlassikRadio:
url: "http://klassikr.streamabc.net/klassikradio-simulcast-mp3-hq?sABC=5oq9q650%230%23n673063r59n978r1r09nn9on3oq60sqn%23fgernz.xynffvxenqvb.qr&amsparams=playerid:stream.klassikradio.de;skey:1541002832"
Sputnik:
url: "http://mdr-284330-0.cast.mdr.de/mdr/284330/0/mp3/high/stream.mp3"
Sputnik_Black:
url: "http://mdr-284331-0.cast.mdr.de/mdr/284331/0/mp3/high/stream.mp3"
Sputnik_Club:
url: "http://mdr-284331-2.cast.mdr.de/mdr/284331/2/mp3/high/stream.mp3"
sequence:
- service: media_player.play_media
data:
entity_id: media_player.seantv
media_content_id: " {{ stations[station].url }}"
media_content_type: audio/mp3
This is the automation that calls the script:
- id: media_radio_select
alias: media_radio_select
trigger:
- entity_id: input_select.radiostation
platform: state
action:
- service: script.media_radio_play
data:
station: "{{ states('input_select.radiostation') }}"
4 Likes
Tsar
(Christian)
3
Super, that’s a very nice solution ! Thank you !
It works, but now I try to activate it with a button but for some reason I make a mistake…do you see what I’m doing wrong ?
type: button
tap_action:
action: call-service
service: script.media_radio_play
service_data:
station: |
{% states('input_select.radio_station') %}
target: {}
name: PLay music !
Haha, I never saw your reply.
In case you didn’t find the error, your sing-up for the station is wrong. It should be (no “%”+sign)
station: |
{{ states('input_select.radio_station') }}
Tsar
(Christian)
5
I also didn’t remember this one
Even if it seems I found it meanwhile, thanks !
1 Like