How to play radio stations on an Alexa devices?

This is the site: Alexa Skill Radio Browser - TuneIn alternative
It’s an Alexa skill. You enable it on your Alexa, then you link it; and then you go in via a browser and edit your favourites (either with URLs or using their database) and ensure each is assigned a number. Then to call it locally you say Alexa, play [number of favourite] or via this integration, you effectively send the same command.

Make sure you have Alexa Media Player enabled in HomeAssistant. Try to create a card manually on the dashboard. Edit code and put in this;

- type: custom:mini-media-player
          artwork: full-cover-fit
          entity: media_player.john_s_echo_show
          name: Home
          shortcuts:
            columns: 2
            buttons:
              - type: custom
                name: [Name of station]
                id: tell radio browser [Favourite number from Radio Browser]
                image: [link to radio logo URL]
              - type: custom

(repeat however many buttons you want)

2 Likes

I am puzzled as I don’t get this to work.
There is no problem to cast radio stations to my Chromecast devices, using Action:

```action:
  - service: media_player.play_media
    data:
      media_content_type: audio/aac
      media_content_id: >-
        http://playerservices.streamtheworld.com/api/livestream-redirect/SRGSTR15AAC.aac
    target:
      entity_id:
        - media_player.mazal
        - media_player.brun_mbr_desk_show5
  - service: notify.alexa_media_mbr_tv
My Echo devices show in the list of media player, 
but while the radio plays on Chromecast, nothing happens on 
the Echo devices (mbr_desk_show5) , 
though I do  get pop-up that automation runs succesfully.

Any updates on how this can be done, either with local music, or via a url to a live radio station?

Not that I know…

Very interesting approach!
I installed the skill and added one station in my favorites on
Alexa Skill Radio Browser - TuneIn alternative > Edit favorites list

It works fine if I launch the skill on the Alexa app on my smartphone and the radio plays just fine! :+1:

But the following script won’t play on my Echo Dot (office) :confused:

type: custom:mini-media-player
artwork: full-cover-fit
entity: media_player.office
name: Home
shortcuts:
  buttons:
    - type: custom
      name: Patate Douce
      id: tell radio browser number 1

I tried with and without the word number in the “tell radio” sentence.
And I see no error when clicking the button…

image

Please note that type: custom is NOT an available value according to

Do you have any idea what I’m doing wrong?

Ok, answering to myself.
I got it working, here is how.

I created a routine in Alexa:

  • when I tell Alexa “joue la patate douce”
  • then run voice command “tell radio browser number 1”
    (with the prerequisite in my post above regarding the favorites in Radio Browser)

In HA, create a script:

alias: "Media: Play La Patate Douce on Office"
sequence:
  - service: media_player.play_media
    data:
      media_content_id: joue la patate douce # exact name of the routine
      media_content_type: routine
      enqueue: replace
    target:
      entity_id: media_player.office
mode: single
icon: mdi:radio

More info on the Alexa routines here

On your HA dashboard, create a mini media player card with a button:

type: custom:mini-media-player
entity: media_player.office
tts:
  platform: alexa
  entity_id: media_player.office
shortcuts:
  buttons:
    - type: service
      name: La Patate Douce
      id: script.media_play_la_patate_douce
show_source: icon
sound_mode: icon
source: icon
artwork: material
info: scroll
toggle_power: true
volume_stateless: false
group: false
2 Likes

Hi, I have Alexa playing TuneIn since quite a long time (2 years). I created a Script to randomly play a radio everyday morning when I enter in my kitchen and also when my wife returns home.
It is quite reliable for the radio play, but the code has some issues (written further below). Maybe someone could help me :innocent:.

alias: Play Radio
description: >-
  0: Alpha FM, 1: Nova Brasil FM, 2: Band FM, 3: FM Dos Chile, 4:Milano Lounge,
  5: Regenbogen 2, 6: Spotify: Vintage Cafe, 7: Spotify: Sad Songs, 8: Spotify:
  Colecao MPB, 9:Spotify: Viagem de Carro - So Brasil 
fields:
  entity_id:
    name: Media Player Entity ID
    description: The entity_id of the media player
    required: true
    selector:
      entity:
        domain: media_player
  notify_entity:
    name: Notify Entity
    description: The entity to send notifications to
    required: true
    selector:
      entity:
        domain: input_select
sequence:
  - service: script.new_script
    data: {}
  - service: notify.alexa_media_echo_show_8
    data:
      message: |-
        {% if states("input_number.number_random") | int == 1 %}
          Tocando a rádio Nova Brasil FM Sao Paulo
        {% elif states("input_number.number_random") | int == 2 %}
          Tocando a rádio Band FM Sao Paulo
        {% elif states("input_number.number_random") | int == 3 %}
          Tocando a rádio FM Dos Chile
        {% elif states("input_number.number_random") | int == 4 %}
          Tocando a rádio Milano Lounge
        {% elif states("input_number.number_random") | int == 5 %}
          Tocando Rádio Regenbogen
        {% elif states("input_number.number_random") | int == 6 %}
          Tocando Playlist Vintage Café no Spotify      
        {% elif states("input_number.number_random") | int == 7 %}
          Tocando Playlist Sad Songs no Spotify      
        {% elif states("input_number.number_random") | int == 8 %}
          Tocando a Playlist MPB no Spotify      
        {% elif states("input_number.number_random") | int == 9 %}
          Tocando a Playlist Viagem de Carro no Spotify      
        {% else %}
          Tocando a rádio Alpha FM Sao Paulo      
        {% endif %}
      data:
        type: announce
  - delay: "00:00:10"
  - if:
      - condition: numeric_state
        entity_id: input_number.number_random
        below: 6
    then:
      - service: media_player.play_media
        data:
          media_content_id: |-
            {% if states("input_number.number_random") | int == 0 %}
              play Alpha FM Sao Paulo on tunein      
            {% elif states("input_number.number_random") | int == 1 %}
              play Nova Brasil FM Sao Paulo on tunein
            {% elif states("input_number.number_random") | int == 2 %}
              play Band FM Sao Paulo on tunein
            {% elif states("input_number.number_random") | int == 3 %}
              play FM-Dos-985-s24997 on tunein
            {% elif states("input_number.number_random") | int == 4 %}
              play Milano Lounge on tunein
            {% elif states("input_number.number_random") | int == 5 %}
              play Radio Regenbogen on tunein
            {% endif %}
          media_content_type: custom
        target:
          entity_id: "{{ entity_id }}"
    else:
      - service: media_player.select_source
        entity_id: media_player.spotify_william_vidal
        data:
          source: "{{ entity_id }}"
      - delay: "00:00:03"
      - service: media_player.media_play
        data: {}
        target:
          entity_id: media_player.spotify_william_vidal
      - service: media_player.play_media
        data:
          media_content_id: |-
            {% if states("input_number.number_random") | int == 6 %}
              https://open.spotify.com/album/5dPAnuLyn7AHGV6XIIcY64?si=-hAia_UsSrCr8SVyPXpcCQ
            {% elif states("input_number.number_random") | int == 7 %}
              https://open.spotify.com/playlist/4ZdTQQNnf7cLvSOnPdYWKa?si=6ed6fac35f28448f                    
            {% elif states("input_number.number_random") | int == 8 %}
              https://open.spotify.com/playlist/37i9dQZF1DWZlBWh8A1Ygd?si=525e0f4d405045e3
            {% elif states("input_number.number_random") | int == 9 %}
              https://open.spotify.com/playlist/0fYaOS0XozDRg1Lr6nhOn1?si=c5c91467ec3b4f76
            {% endif %}
          media_content_type: playlist
        target:
          entity_id: media_player.spotify_william_vidal
      - service: media_player.shuffle_set
        data:
          shuffle: true
        target:
          entity_id: media_player.spotify_william_vidal
mode: parallel
icon: mdi:radio

Issues I have:

  1. I can’t play Spotify Playlists
  2. I could not play the notification in the device that the radio will play, rather only on the Echo Show 8. The reason is because I could not pass the service Notifcation as a field (parameter).