I was wondering if anybody has connected Chromecast to Openhab and find it really useful…
I am debating if this would be a good gadget to get :)… I like the idea, but I would preferif via Openhab I could not only control Chromcast once is active, but I was wondering if I could "turn on TV, initiate Chromcast and streem Spotify (for example)… is it feasible? if not what devise should I be focused on?
I haven’t found any use for the Chromecast yet. But I do use the Google Home speaker and Google Home mini. You can use them as a cheap wifi speaker. They make a perfect integration device for text-to-speech or programmatically playing music.
I use chrome cast audio everyday. I have my wake rule turn on 2 1950’s valve radios, and use chrome cast audios to play internet radio through them, along with lights and stuff if it is dark.
I also use 3 Chromecast audio’s and one Chromecast. Depending on the app which I use to send data to the Chromecast, specific devices are turned on etc.
I dont use my chromecast devices in openhab much. But I do use my Google Home devices abit.
I have used openhab to send stream of sounds to my Google Home devices. (I used a GH device at Halloween playing scary sounds at the frontdoor, controled by openhab).
My plan is to use these devices alot more to send more specific notifications (by speech) from openhab til GH devices at special events or rules.
Fx let openhab send a text to speech, if someone is walking around the outside of house in the middle of the night. If the garagedoor is open, when it´s suppose to be closed, and I forgot to check and went to bed, turning off the light will check and send the message, if its not closed. If the frontdoor isnt locked when I go to bed… etc. Simple stuff like that is in my opinion usefull. I will be using Google Home devices for stuff like that, not chromecasts devices, as I wont have the speech respons, untill it´s connected to a speaker. And since I probably will ask Google to close the garagedoor in case I forgot, a chromecast device wont do much good.
Number Radio_Station "Radio Station [%d]"
String Play_radio "Radio URI [%s]" {channel="chromecast:audiogroup:0e548657-769b-43e3-87db-7f1c75a2a915:playuri"}
String Play_on_office_speaker "office speaker URI [%s]" {channel="chromecast:chromecast:42138b4fe1c262a4988221de8d4d610d:playuri"}
Switch Stop_Home_group "Stop Home group" (Chillingworth) {channel="chromecast:audiogroup:0e548657-769b-43e3-87db-7f1c75a2a915:stop", expire="5s, command=OFF"}
Rule
rule "Select Radio Station"
when
Item Radio_Station received command
then
switch(receivedCommand) {
case 0 : Stop_Home_group.sendCommand(ON)
case 1 : Play_radio.sendCommand("http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio2_mf_p")
case 2 : Play_radio.sendCommand("http://bbcmedia.ic.llnwd.net/stream/bbcmedia_lrshrops_mf_p")
case 3 : Play_radio.sendCommand("http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio5live_mf_p")
case 4 : Play_radio.sendCommand("http://bbcwssc.ic.llnwd.net/stream/bbcwssc_mp1_ws-einws")
case 5 : Play_radio.sendCommand("http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4fm_mf_p")
case 6 : Play_radio.sendCommand("http://bbcmedia.ic.llnwd.net/stream/bbcmedia_lrmersey_mf_p")
case 7 : Play_on_office_speaker.sendCommand("http://bbcmedia.ic.llnwd.net/stream/bbcmedia_lrshrops_mf_p")
case 8 : Play_radio.sendCommand("http://bbcmedia.ic.llnwd.net/stream/bbcmedia_walesmw_mf_p")
}
end
Sitemap
Text label="Radio" icon="receiver" {
Selection item=Radio_Station mappings=[0="off", 1="Radio 2", 2="Radio shropshire", 3="Radio 5 live", 4="BBC world servcie news",
5="Radio 4", 6="Radio Merseyside", 7="Radio Shropshire on office speaker", 8="Radio Wales"]
Then it is a simple mater of creating a dummy switch and linking everything in a new rule for that switch
I am no coder so this may not be the best solution but it works for me.
I use the idle channel to determine if a Chromecast is streaming, and the appID channel to set volume for specific apps.
Switch Chromecast_Stop "Chromecast[]" { channel="chromecast:XXXX:stop", autoupdate="false" }
Dimmer Chromecast_Volume "Volume [%d%%]" { channel="chromecast:chromecast:XXXX:volume" }
Switch Chromecast_Idle "Chromecast []" { channel="chromecast:XXXX:idling", autoupdate="false" }
String Chromecast_App "Chromecast App" { channel="chromecast:chromecast:XXXX:appName" }
rule "Turn on Harmony Hub when casting"
when
Item Chromecast_Idle changed to OFF
then
HarmonyLivingRoomActivity.sendCommand("Chromecast")
//lower the volume if app is TuneIn Free
if (Chromecast_App.state == "TuneIn Free") { Chromecast_Volume.sendCommand(35) }
else { Chromecast_Volume.sendCommand(60) }
end
rule "Turn off Harmony Hub five minutes after Chromecast goes to idle"
when
Item Chromecast_Idle changed to ON
then
createTimer(now.plusMinutes(5))
[
if (Chromecast_Barney_Idle.state == ON && HarmonyLivingRoomActivity.state == "Geneva XL") { HarmonyLivingRoomActivity.sendCommand("PowerOff") }
]
end
With the stop channel, you can stop casting with Chromecast_Stop.sendCommand(ON). You can build this into a rule that detects if the Harmony Hub activity changes, so that you won’t keep casting to a device that’s not turned on. I use it in my “Away Mode” rule, which turns everything off when I leave the house.
The stop channel immediately returns to OFF, so there’s no need to send a follow-up OFF command.
Do they have a web-based app to play the stream you want without logging in? If so, you should be able to find the stream by starting the web-based player in Chrome and then using the inspection tools to look for it.
Alternatively, if you can say “hey Google, play ____ on BBC Sounds”, then you can use an OH item to trigger a Google Assistant routine and run that command. There will be a slight delay since GA doesn’t get item updates immediately.
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
16
The ChromeCast Audio I have I’m my bathroom, doesn’t have a “send command” type channel.
But…
If I were to break the bank and get a Google Home device, it’s possible I could send an utterance like " Hey Google, stream BBC Radio 6 Music, to the bathroom " (just like I can from my Android phone)
Or…
Do you mean using Google Action method? (which I thought was for Google to openHAB???)
Is there a way to sent a command to Google FROM openHAB?
Which is probably just as easy / difficult / costly as setting up some kind of in-house streaming / transcoder.
(I have a couple of DVB-T2 dongles, that I had been thinking of using as DVB-T2 radio to internal IP stream things, but that’s an effort in itself)
I have the ability to create a routine in the Google Home app on my phone and start it “when a device does something”. Do you have that? It’s possible that it’s regional and hasn’t deployed to the UK yet.
If you can do this, then you can expose a switch item with Google Assistant and send an ON command to trigger the routine and carry out any command you would normally give by voice.
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
19
Oh…
Interesting approach…
I’ll have to look closely at that.
I think I’ve seen something like it in the UK Google Home app.
Note that I haven’t actually tried this, because the playURI works for my purposes. I was thinking about experimenting with it just to see how much lag there is between the OH item changing and GA triggering the routine.