Chromecast bindings

chromecast
binding
Tags: #<Tag:0x00007fe0571dc268> #<Tag:0x00007fe0571dd6b8>

(bruno) #41

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?


(Dries) #42

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.


(bruno) #43

Thanks Dries, I will test it soon.


(Dries) #44

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?


(Kai Kreuzer) #45

Yes, see OH2 startup error in latest build


(Dries) #46

FYI, it’s fixed in build #1098.


(Dries) #47

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] [ome.core.thing.link.ThingLinkManager] - Exception occurred while informing handler: null
java.lang.NullPointerException: null
	at su.litvak.chromecast.api.v2.ChromeCast.getRunningApp(ChromeCast.java:188) ~[?:?]
	at su.litvak.chromecast.api.v2.ChromeCast.getMediaStatus(ChromeCast.java:291) ~[?:?]
	at org.openhab.binding.chromecast.internal.ChromecastCommander.handleRefresh(ChromecastCommander.java:102) ~[?:?]
	at org.openhab.binding.chromecast.internal.ChromecastCommander.handleCommand(ChromecastCommander.java:55) ~[?:?]
	at org.openhab.binding.chromecast.handler.ChromecastHandler.handleCommand(ChromecastHandler.java:147) ~[?:?]
	at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:243) ~[?:?]
	at org.eclipse.smarthome.core.thing.link.ThingLinkManager.lambda$0(ThingLinkManager.java:290) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]

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 su.litvak.chromecast.api.v2.Channel.read(Channel.java:413) [219:org.openhab.binding.chromecast:2.2.0.201712011716]
	at su.litvak.chromecast.api.v2.Channel.access$200(Channel.java:50) [219:org.openhab.binding.chromecast:2.2.0.201712011716]
	at su.litvak.chromecast.api.v2.Channel$ReadThread.run(Channel.java:132) [219:org.openhab.binding.chromecast:2.2.0.201712011716]
2017-12-01 22:36:26.049 [WARN ] [su.litvak.chromecast.api.v2.Channel ] -  <--  null payload in message 

Do others have similar experiences?


(Chris Colden) #48

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


(Ellis Johns) #49

@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”
when
Item ChromecastTest changed from ON to OFF
then
CaveCast_PlayURI.sendCommand(“http://10.10.10.64:8080/static/barking.mp3”)
CaveCast_Control.sendCommand(ON)
end

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.


(Jay) #50

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?


(Ellis Johns) #51

@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.


(Fritz) #52

Hi,
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 https://www.youtube.com/watch?v=XOacA3RYrXk
2018-03-20 20:21:39.084 [ome.event.ItemCommandEvent] - Item 'CastLRTV_Control' received command PLAY


(Wlanrouter) #53

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.


(Chris Colden) #54

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


(Keiron Cheesbrough) #55

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


(Keiron Cheesbrough) #56

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)

Youtube and Chromecast
(Nakh Home) #57

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" http://192.168.1.62:8008/apps/YouTube -X POST -d 'v=oHg5SJYRHA0'
[16:34:27] openhabian@openhabian:~$ curl -H “Content-Type: application/json” http://192.168.1.62:8008/apps/YouTube -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" http://192.168.1.62:8009/apps/YouTube -X POST -d 'v=oHg5SJYRHA0'
curl: (52) Empty reply from server
[16:34:40] openhabian@openhabian:~$ curl -X POST -H "Content-Type: application/json" http://192.168.1.62:8008/apps/YouTube -X POST -d 'v=oHg5SJYRHA0'
[16:34:47] openhabian@openhabian:~$

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

SOS! please


(Josh) #58

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?


(Lucky) #59

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”


(Michael Parment) #60

Is it possible to get IP or name of the chromecast in the error:

2019-02-07 09:01:24.145 [WARN ] [su.litvak.chromecast.api.v2.Channel ] - Error while reading
su.litvak.chromecast.api.v2.ChromeCastException: Remote socket closed
        at su.litvak.chromecast.api.v2.Channel.read(Channel.java:425) ~[263:org.openhab.binding.chromecast:2.5.0.M1]
        at su.litvak.chromecast.api.v2.Channel.access$200(Channel.java:51) ~[263:org.openhab.binding.chromecast:2.5.0.M1]
        at su.litvak.chromecast.api.v2.Channel$ReadThread.run(Channel.java:137) [263:org.openhab.binding.chromecast:2.5.0.M1]
2019-02-07 09:01:24.161 [WARN ] [su.litvak.chromecast.api.v2.Channel ] -  <--  null payload in message

/Mike