Chromecast bindings

Hi, has anyone had a sucsess playing a radio stream to the chromecast? When playing a mp3 file, everything works fine, but when trying a stream, I get the following error…

2017-04-03 10:44:53.819 [ItemStateChangedEvent ] - CastLRTV_URI changed from http://techslides.com/demos/sample-videos/small.mp4 to http://lyd.nrk.no/nrk_radio_p1_ostlandssendingen_mp3_h
2017-04-03 10:44:53.971 [hingStatusInfoChangedEvent] - ‘chromecast:audio:007ece673a4511f33641702196e5343e’ changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Invalid request: INVALID_MEDIA_SESSION_ID

Stream: http://lyd.nrk.no/nrk_radio_p1_ostlandssendingen_mp3_h

I’ve come across two issues:

1 – If i stream Google Play Music to a Chromecast, and play a song, OpenHAB does not know if the music is playing or paused no matter how many times i cycle it within the Google Play Music app on my phone.
The moment i play/pause the chromecast though OH2 it forever knows what its status is no matter where i pause/play (within Play Music app or Openhab2).

It seems like for OH to know what the chromecast is doing it requires an action to happen in OH first then any changes are logged/updated.

2 - Play/Pause & Next/Previous does not work within netflix. Logs show this:

2017-04-28 22:58:49.747 [DEBUG] [chromecast.handler.ChromecastHandler] - mediaStatus null
2017-04-28 22:58:49.752 [DEBUG] [chromecast.handler.ChromecastHandler] - PLAY command ignored because media is not loaded
2017-04-28 22:58:50.465 [DEBUG] [chromecast.handler.ChromecastHandler] - mediaStatus null
2017-04-28 22:58:50.465 [DEBUG] [chromecast.handler.ChromecastHandler] - PAUSE command ignored because media is not loaded
2017-04-28 22:58:52.397 [INFO ] [chromecast.handler.ChromecastHandler] - NEXT command not yet implemented
2017-04-28 22:58:55.188 [INFO ] [chromecast.handler.ChromecastHandler] - PREVIOUS command not yet implemented

I’m sorry if this is an obvious question. How can I get the URL that is playing my chromecast audio?
I want to play any stream, for example from tunein and then take the URL to use it in openhab2 via sendCommand (“chromecast_audio_7698_playuri”, “URL taken from that”)

1 Like

I have exact the same problem.
Too bad, I would like OH2 to ‘always’ now if my Chromecast is playing or not.
I have a KNX switch I use to turn on/off all my devices in a room. Depending on Chromecast playing yes/no I would know if I need to turn of my projector (which I control via irTrans).

I havn’t had much luck trying to get my Chromecast audio to play any local files.

  • I have tried mounting a share to the Raspberry Pi and using that location as URI
  • added network computer with the share in the hosts file and used that.
  • file:// , file:/// , file:///*insert mounted share
  • config samba and given full writes on the pc for all guests

The chrome cast will play any mp4 from a URL eg: http://techslides.com/demos/sample-videos/small.mp4 but I can not seem to get it to do anything bar playing something thats hosted online.

Could anyone provide any feedback on what I may be missing? Do I need to add something somewhere within Openhab2?

I should add that the Chromecast binding is installed and that is how I have been posting the eg: http://techslides.com/demos/sample-videos/small.mp4 which works… anything else I may put here doesn’t seem too…

My theory is if I can get it to work by just changing that string, I can create my own interface in HabPanel etc… I would prefer not to have to use my phone to Cast things too, i would love to use openhab to tell the chromecast audio to play from a network location or googlemusic etc.

Thank you

I’m facing the same problem. My Chromecast Audio is able to play radio-stations from TuneIn, but when trying to play either radio stream (xxxx.m3u) or a local .mp3 it fails. The posted link to a .mp4 works.

So the Chromecast Audio CAN play radio streams (via TuneIn), how to start such a stream via openHAB??
Using an executeComandLine?? Has anybody found a solution on this way?

Chrome-cast Audio how can i call google play music radio station direct so it will play on Chrome-cast Audio

Many thanks

Is this dead? Examles op playUricommands would be much appriciated. Hand how to use the playuricommand.

Can i play from a network share?
Can i play from youtube?
Can i play radio streams?

Here a dummy example:

rule "Play an MP3 file"

when   
    Item  TEST_Chromecast_GV_Living_Play_Trigger changed from OFF to ON
then
	Chromecast_GV_Living_PlayURI.sendCommand("http://lb.topradio.be/topradio.mp3")
	Chromecast_GV_Living.sendCommand(PLAY)
end

I don’t think it can play from a network share (although I haven’t tested it), but radio streams is fine (see example).

Hi all,
for your information after many attempts I could play files only if I move them under /etc/openhab2/html/…/xxx.mp3.
Is anyone able to play many audio files with one command ? (i tried with group-forEach but no results)
Thanks

Not sure what you mean with playing many files with one command. I guess you are talking about playing a playlist?

I haven’t tried it myself, but you should consider creating an M3U file (which is a playlist file), put it on the same folder as your MP3 files (not necessary, but convenient). And then trigger the Chromecast to play the M3U file.

I have had problems with my chromecast audio volume level, they often start bouncing change the volume up and down spontaneously after an initial volume adjustment. Did any of experience this?
I get the problem both when I control the audio group and the individual units. I get an error i my log like this:

2017-10-01 21:19:01.860 [WARN ] [su.litvak.chromecast.api.v2.Channel ] - Error while reading: Could not resolve type id 'DEVICE_UPDATED' into a subtype of [simple type, class su.litvak.chromecast.api.v2.StandardResponse]
 at [Source: N/A; line: -1, column: -1]
2017-10-01 21:19:01.863 [WARN ] [su.litvak.chromecast.api.v2.Channel ] -  <-- {"device":{"capabilities":4,"deviceId":"2f017b59-0f18-5ac3-e223-abd0f7fb2109","name":"Soveværelse","volume":{"level":0.12999999523162842,"muted":false}},"requestId":0,"type":"DEVICE_UPDATED"}

As a matter of fact, the playlist could be an answer to my problem (I had in mind much pore complex solution!), I’d like to play for example all the songs of a CD (in MP3), but really I do not know how to do it, can you help me?

to Dries

I just tested it. Unfortunately, ChromeCast doesn’t take M3U files. :frowning:

But just to explain what I had in mind:
You have two MP3 files (A.mp3 and B.mp3) stored on a webserver that is publicly accessible (http://mysite.com/MP3/A.mp3).
Then you create an M3U file with the following content:

http://mysite.com/MP3/A.mp3
http://mysite.com/MP3/B.mp3

You put the M3U file on the same folder as the MP3 files (not needed). And you play the M3U file with the following command:

Chromecast_PlayURI.sendCommand("mysite.com/MP3/Playlist.M3U")
Chromecast_.sendCommand(PLAY)

But like I said… it doesn’t work.

A quick and dirty way to do it (if it’s always the same music you want to play), is to generate one big MP3 file out of your multiple MP3 files (https://audio-joiner.com/).

I had checked the solution before, exactly as you had explained, and as you say it does not work.
Sincerely I do not like the solution of a big mp3 (too inelegant :)) , rather better some json or pyton code, but I do not understand why I cannot insert a loop in the rule, scanning one by one a variable with the single http addresses, if a variable is not usable, I could try with a txt file, reading each time the next record (mp3 file). What to you think?

Hmm…
What could work maybe (again, I haven’t tried this):

  • Play your first audio file (set URI parameter and then press play);
  • I guess the status of the player will remain PLAY until the song is finished;
  • When the status changes to PAUSED_PLAYBACK/STOPPED, change the URI parameter and press play again;
  • Getting the file names of the MP3 files should be possible using the executeCommandLine;

I tried something similar, my objective is to play all the songs without any further intervention, so I changed the name of the files using an incremental index.
The rule should be more or less the following (sorry I am a very beginner and the code is quite rough)

rule "musica disco on"
when
	Item Play_switchlist changed from OFF to ON
then
	var i=0
	val result=executeCommandLine("wc -l /etc/openhab2/html/"+"adele"+".m3u", 5000) //this returns the number of files plus other information
	var nameParts =result.split(" ")
	var Parte=Double::parseDouble(nameParts.get(0))+1
	while ((i=i+1) < Parte) {
	var uri="http://192.xx.xx.xx:8080/static/adele1/adele_"         
	CCplayuri4.sendCommand (uri+i+".mp3")   
	Music4.sendCommand (PLAY)     
	}
end

The problem is that now each song start immediately after the previous one, stopping it, and I do not know how to delay the start of the new song (I do not know in advance the duration of the song). You suggest to exploit the state (in my example of Music4, I guess), but I do not know how to command to wait untill the state will change (strange is that a logInfo on Music4.state after the PLAY, returns PAUSE!?). Any idea?

Hi,

I just upgraded to the latest snapshot build (2.2 - #1094). And I noticed that the ChromeCast binding received a big upgrade. :slight_smile: From only 3 channels, it now has 30 channels. Someone has been busy. Thanks!

I didn’t do any tests yet. The documentation also isn’t updated yet. I’ll share my experienced when I have time.

If you decide to upgrade, don’t forget you must delete your CC Things and add them again in order to see the new channels.

@Bruno: there is also a channel “duration”. Using that channel, you will know (I guess) when to play the next song.

Thanks Dries, I will test it soon.