Sonos Radio Streams

I have several Sonos devices setup on my network working nicely.

I would like to automate them playing radio streams at various points of the day, but i can’t seem to get it to work.

The streams in question are BBC ones, i have tried the following JSON payloads, but nether seems to work. They are based on the media id’s returned by the devices to Home Assistant.

{
  "entity_id" : "media_player.bedroom",
  "media_content_id": "http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_radio_two.m3u8",
  "media_content_type": "music"
}

{
  "entity_id" : "media_player.bedroom",
  "media_content_id": "bbc_radio_two.m3u8",
  "media_content_type": "music"
}

This is what Home Assistant gives me when i set the player playing with the same stream from the Sonos app directly.

{
  "friendly_name": "Kitchen",
  "is_volume_muted": false,
  "media_content_id": "bbc_radio_two.m3u8",
  "media_content_type": "music",
  "media_duration": 0,
  "media_title": " - bbc_radio_two.m3u8",
  "supported_media_commands": 575,
  "volume_level": 0.33
}

Does anyone know the correct media_contant_id to make this work?

Thanks

Gareth

Were you able to get this working?

I managed to get mine working and playing a stream on the press of a minimise button with the following:

- alias: Minimote Button 1 Radio 2
  trigger:
     platform: event
     event_type: zwave.scene_activated
     event_data:
       object_id: aeotec_dsa03202_minimote_23
       scene_id: 1
  action:
    service: media_player.play_media
#    entity_id: media_player.dining_room
    entity_id: group.Speakers
    data:
      media_content_id: hls-radio://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/llnw/bbc_radio_two.m3u8
      media_content_type: music

If you play the radio station you want and then go to:

http://192.168.0.132:1400/status/perf

(using your IP address for your Sonos)

You should be able to see the stream URL.

1 Like

the easiest way is to add the radio stations you need to your Sonos Favorites an then use the select_source function, see: SONOS: The easiest way of setting playlist or radio streams

The “http://192.168.0.132:1400/status/perf” interface is not available any longer.

The easiest way to determine the URL to be used for media_content_id is to play the station in Sonos (choosing it via Sonos Radio or TunieIn) and then have a look at Developer Tools/States - it will show the exact URL to be used:

One may ask why bother, why not simply add the radio stations you are interested in to the Sonos Favorites and then have them available in the source list? The answer is to that is that you may not want to add everything you want to be able to play from HA to the Sonos favourites. Or that you would like to create different sets of favourite radio stations in HA - one for yourself, another one for you wife or your kids. As Sonos still doesn’t have multi-user support, so using HA can mitigate that shortcoming to a small extent.


(Choosing a entry from above drop down menu will immediately start playing that station on the Sonos boxes in my room)

In case the radio station you are interested in is not available in Sonos Radio or TuneIn, you can go to your radio’s station website to figure out the URL to be used there. This youtube clip shows how that works:

URLs to be used for media_content_id for Sonos are a bit different - they typically have a prefix and will not work without. E.g. the media_content_id for Melbourne’s RRR radio station is not just https://ondemand.rrr.org.au/getstream?id=wshq but will require a x-rincon-mp3radio:// prefix:

x-rincon-mp3radio://https://ondemand.rrr.org.au/getstream?id=wshq

1 Like

This was exactly my solution. I’ve been searching everywhere for this, but couldn’t find it.

I created an automation, once a tag has been scanned:

alias: Top versuz
description: ''
trigger:
  - platform: tag
    tag_id: {{TAG ID}}
condition: []
action:
  - service: media_player.play_media
    data:
      media_content_id: >-
        x-rincon-mp3radio://{{PLACE YOUR HTTPS:// URL HERE}}
      media_content_type: music
      enqueue: play
    target:
      entity_id: {{FILL IN THE NAME OF YOUR RADIO}}
mode: single

2 Likes

This is what did the trick! :slight_smile: you rock!