Chromecast bindings

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"
	Item Play_switchlist changed from OFF to ON
	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)     

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?


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.

I just upgraded from #1094 to #1096.

At boot, I have the following error:

2017-11-25 09:09:48.188 [ERROR] [org.openhab.binding.chromecast      ] - Component descriptor entry 'OSGI-INF/*.xml' not found

My things remain uninitialized:

When adding a new ChromeCast via PaperUI, I get:

2017-11-25 09:13:55.744 [WARN ] [g.discovery.internal.PersistentInbox] - Cannot create thing. No binding found that supports creating a thing of type chromecast:audio.

Is there anyone else experiencing the same thing?

Yes, see OH2 startup error in latest build

FYI, it’s fixed in build #1098.

Since the upgrade to #1094 (and now still with #1103), I do get quite a lot of Chromecast errors in my log. Things like:

2017-12-01 22:37:26.059 [ERROR] [] - Exception occurred while informing handler: null
java.lang.NullPointerException: null
	at su.litvak.chromecast.api.v2.ChromeCast.getRunningApp( ~[?:?]
	at su.litvak.chromecast.api.v2.ChromeCast.getMediaStatus( ~[?:?]
	at org.openhab.binding.chromecast.internal.ChromecastCommander.handleRefresh( ~[?:?]
	at org.openhab.binding.chromecast.internal.ChromecastCommander.handleCommand( ~[?:?]
	at org.openhab.binding.chromecast.handler.ChromecastHandler.handleCommand( ~[?:?]
	at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.channelLinked( ~[?:?]
	at$0( ~[?:?]
	at java.util.concurrent.Executors$ [?:?]
	at [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201( [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:?]
	at java.util.concurrent.ThreadPoolExecutor$ [?:?]
	at [?:?]

Or these:

2017-12-01 22:36:26.023 [WARN ] [su.litvak.chromecast.api.v2.Channel ] - Error while reading
su.litvak.chromecast.api.v2.ChromeCastException: Remote socket closed
	at [219:org.openhab.binding.chromecast:]
	at su.litvak.chromecast.api.v2.Channel.access$200( [219:org.openhab.binding.chromecast:]
	at su.litvak.chromecast.api.v2.Channel$ [219:org.openhab.binding.chromecast:]
2017-12-01 22:36:26.049 [WARN ] [su.litvak.chromecast.api.v2.Channel ] -  <--  null payload in message 

Do others have similar experiences?

I had loads of issues until i upgraded to 1104. Seems quite stable at the moment for me.

@Lewis I know this is an old thread but I was able to play a local mp3 file by placing the file in the [openhab2-dir]/conf/html directory and then calling it using the code below (of note, I used the default paperui config names).

rule “test chromecast”
Item ChromecastTest changed from ON to OFF

I hope this helps someone else. You can always place your mp3 on a public server as well, but I like having all my openhab config in one place for easy backups

I still haven’t figured out how to resume music playing after the announcement but I suppose this is an outstanding issue that everyone has.


I only just started using the binding a a day ago (and also just realised I am using an old version) but my plan was to store whatever is playing in a variable (ie url/ artist) and then feed it back to the chromecast after the announcement. Seems quite simple so I’m assuming it doesn’t work that easily if people are having issues?

@thejayo I also started using the binding yesterday but I am using the most recent snapshot from cloud bees. I know you can use the binding to retrieve song info, but I’m not sure there is a way with the current binding to save the currently playing url for playback after your announcement. If there is a way to do this that would be awesome.

Has anyone gotten this to cast youtube videos?
I plan to set a schedule via rules to cast Youtube Sky News Live every 7AM on my TV.
The techslides sample works but I can’t get to cast youtube videos.

2018-03-20 20:21:38.863 [ome.event.ItemCommandEvent] - Item 'Play_Switch' received command ON
2018-03-20 20:21:38.993 [ome.event.ItemCommandEvent] - Item 'CastLRTV_URI' received command
2018-03-20 20:21:39.084 [ome.event.ItemCommandEvent] - Item 'CastLRTV_Control' received command PLAY

How do you stream Google Play Music Playlist to chromecast? Do you use a rule or the native Google Play Music App on your Phone? I would like to start a Google Play Music Playlist. I have checked all items, but non of them offers me a clear URL or command of the Playlist.

1 Like

You need to use your phone. You should then be able to control it from openhab but you cannot start it from openhab.

1 Like

Hi Fritzcm, appreciate this is an old post but did you ever get Chromecast to play YouTube videos?

So I finally got this to work. To play videos from youtube use the following. Replace XX with your Chromecast IP and change v=XXXXXX to the video you want

executeCommandLine('curl -H “Content-Type:application/json” "http://192.168.XX.XX:8008/apps/YouTube" -X POST -d "v=dQw4w9WgXcQ"', 5000)

Promising, your post burnt my afternoon :slight_smile:
i have tried this without success. nothing is happening.

The GET works but not the POST 404

same issue on two chromecasts : Chromecast first generation and chromecast Second generation

i have tried with different formats and ports.

[16:34:25] openhabian@openhabian:~$ curl -H "Content-Type: application/json" -X POST -d 'v=oHg5SJYRHA0'
[16:34:27] openhabian@openhabian:~$ curl -H “Content-Type: application/json” -X POST -d ‘v=oHg5SJYRHA0’
curl: (6) Could not resolve host: application
[16:34:30] openhabian@openhabian:~$ curl -X POST -H "Content-Type: application/json" -X POST -d 'v=oHg5SJYRHA0'
curl: (52) Empty reply from server
[16:34:40] openhabian@openhabian:~$ curl -X POST -H "Content-Type: application/json" -X POST -d 'v=oHg5SJYRHA0'
[16:34:47] openhabian@openhabian:~$

i have Pi-hole , same behaviour when disabling it :slight_smile:

SOS! please

Hi everyone, is there any ETA for Next/Previous buttons? I’m currently trying to control my Google Home players that are usually playing Spotify. Is there any workaround via API callback or something?

Are you Chromecast’s included in a group (Google Home app) ? You can try my GH bridge . OrangeAssist - Google Assistant Integration

Just issue a command like “go to next song”