Hi
I hope this helps someone 
I’ve been wanting to have options for the music streams that are pushed into a ChromeCast Audio dongle when our shower gets up to temperature.,
So…
I have a Velbus input channel trigger, mapped to PRESSED and RELEASED to start and stop the music
I have a dimmer Item (created in PaperUI) which is used to store a choice (a number) which relates to the audio stream we want.
We have a selection item in HabPanel which uses this comma separated list :-
1=BBC Radio 2,2=BBC RADIO 4 Extra,3=Planet Rock,4=Absolute Radio
and a rule which plays the music source of our choice… IF the house is awake (so that it doesn’t play music at night) AND when the shower water flow is up to temperature.
var int bathradio = 1
rule "Bathroom Music"
when
Channel 'velbus:vmb7in:c5053467:0B:input#CH1' triggered PRESSED // Input channel 1 of a Velbus VMB7IN
then
bathradio = (BathroomChromeCastSourceChoice.state as Number).intValue // Set the bathradio variable to our choice
//say("Source choice number "+bathradio, "voicerss:enGB", "webaudio") // My way of debugging
if(House_Awake.state === ON){
// say("Up to temperature while house awake", "voicerss:enGB", "webaudio")
// say("Number"+BathroomChromeCastSourceChoice.state, "voicerss:enGB", "webaudio")
// sendBroadcastNotification("Number"+BathroomChromeCastSourceChoice.state)
if(bathradio == 1) {
Bathroom_PlayURI.sendCommand("http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio2_mf_p")
say("Radio choice is number"+BathroomChromeCastSourceChoice.state+" BBC Radio 2", "voicerss:enGB", "webaudio")
} // BBC Radio 2
if(bathradio == 2) {
Bathroom_PlayURI.sendCommand("http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4extra_mf_p")
say("Radio choice is number"+BathroomChromeCastSourceChoice.state+" BBC Radio 4 Extra", "voicerss:enGB", "webaudio")
} // BBC Radio 4 Extra
if(bathradio == 3) {
Bathroom_PlayURI.sendCommand("http://tx.planetradio.co.uk/icecast.php?i=planetrock.mp3")
say("Radio choice is number"+BathroomChromeCastSourceChoice.state+" Planet Rock", "voicerss:enGB", "webaudio")
} // Planet Rock
if(bathradio == 4) {
Bathroom_PlayURI.sendCommand("http://live-absolute.sharp-stream.com/absoluteradio.mp3")
say("Radio choice is number"+BathroomChromeCastSourceChoice.state+" Absolute Radio", "voicerss:enGB", "webaudio")
} // Absolute Radio
}
if(House_Awake.state === OFF){ say("Up to temperature while house asleep", "voicerss:enGB", "webaudio") }
end
What is particularly interesting is where I got the stream url’s from.
I found a site that offers PLS and M3U downloads,
http://www.radiofeeds.co.uk/mp3.asp
like this for Absolute Radio :-
http://www.radiofeeds.co.uk/ar112.mp3.m3u
which contains a single line
http://live-absolute.sharp-stream.com/absoluteradio.mp3
But to look at another file for Planet Rock
http://www.radiofeeds.co.uk/bauer.pls?station=planetrock.mp3.m3u
this file contains
[Playlist]
File1=http://tx.planetradio.co.uk/icecast.php?i=planetrock.mp3
Title1=planetrock.mp3
Length1=-1
Numberofentries=1
Version=2
By visiting a client last week…
I discovered that this would have been so much easier if I had opted for Sonos speakers instead.
It’s just a matter of selecting the favourite (which can be done via OpenHab2) and issuing a Play or Pause command