As per the title i would like to have an automation to play a radio station at a certain time but this works on a google puck device but the radio part doesnt work on a sonos one:
- id: Bedroom 4 Wake Up Routine
alias: Bedroom 4 Wake Up Routine
trigger:
- at: '20:40'
platform: time
condition: []
action:
- service: tts.google_say
entity_id: media_player.bedroom_4_sonos
data:
message: 'Good Morning'
- delay: '00:00:05'
- service: media_player.play_media
entity_id: media_player.bedroom_4_sonos
data:
media_content_id: https://radio.virginradio.co.uk/stream-tunein
media_content_type: music
Any ideas? Or anyone have an Sonos automations which will play a radio station ?
This is the error I get when trying on a Sonos one:
Log Details (ERROR)
Wed Jul 03 2019 22:14:28 GMT+0100 (British Summer Time)
Error on play_media with UPnP Error 714 received: Illegal MIME-Type from 192.168.1.43
Thanks!
Mark
Update! - fixed it by using the URL:
x-rincon-mp3radio://radio.virginradio.co.uk/stream-tunein
Sure. I am building a new local hass.io addon best on BestLibre’s Mopidy addon which adds Icecast during the installation along with a few extra Mopidy extensions like MQTT control.
When you start playing music on Mopidy, the output is sent to Icecast which outputs the audio to a local stream on your hass.io installation.
E.g. http://hassio.local:8000/mopidy
This local stream can be sent to Sonos using the media_player integration of your Sonos by adding it to the media_content_id parameter of the media_player.play_media service.
E.g.
entity_id: media_player.your_sonos
media_content_id: x-rincon-mp3radio://hassio.local:8000/mopidy
media_content_type: music
This is still a work in progress and I have to test it more thoroughly to see if the music keeps playing without to much pauses.
Please note that I have icecast running alongside Mopidy and not just icecast. Mopidy (which also has an mpd interface) outputs its audiostream to an icecast server.
The configured MPD media_player is used to change what music Mopidy is playing and streaming towards icecast and is not used to output the audio directly to a device like a Sonos.
Do you use Mopidy or mpd in your setup? If not, then I assume you do not need the separate media player configuration you mentioned.
What I then do is take the output URL from icecast, in your case http://192.168.1.239:8000/stream and send it to a second Sonos media player using the media_player.play_media service with the following values
entity_id: media_player.your_sonos
media_content_id: x-rincon-mp3radio://192.168.1.239:8000/stream
media_content_type: music
I’m still somewhat confused about how to get the sound to Lovelace ultimately.
Currently I have FFMPEG on a separate RPI which streams to icecast2. If I browse to it I can hear the microphone attached to the RPI.
If I go to the Mopidy web ui in Hassio and I go to Iris and I enable Icast with the same url I can also hear the microphone (even though the Mopidy server constantly states it is connecting and never does).
I know icecast is on port 8000 and I know MPD is 6600 and Mopidy is 6680.
I’m not sure what your end goal is. Are you trying to play the icecast stream through Mopidy in your browser and if so in Lovelace and not in Iris? In our setup, it is the output from Mopidy that needs to be played on other media player devices like Sonos.
It is specifically for the output to Sonos that we use the x-rincon-mp3radio:// in the media_content_id.
The screenshot you share seems to mix things up. The host and port in the Iris settings in my case is the server where Mopidy is running, not the stream I’m playing. That’s probably why the system cannot connect to Mopidy.
I’m not a 100% sure if the services shown by Iris in the settings are the configuration of Mopidy or from Iris itself. In my case it does indeed work when I choose to stream the content to the browser, but I also see the URL of the stream itself there what seems to be different in your case.
I know that Thomas Loven has a way to make your browser act as a media player, but I have no experience with that and am not sure if it helps in achieving what you try to achieve
Also you might be interested in what @vittoriom excellently wrote up on his blog a while ago in using a similar approach using Chromecasts: