Chromecast binding - how do people use it?

What Google devices are you using? I can go months without rebooting and have no issues with Chromecast instability. Do you also have dedicated IP addresses for those devices?

My use case is narrower. At certain times of the day I play a random Internet Radio Stream (mp3 streams). Then I have another rule to play a local MP3 file for the mindfulness bell (every x # of minutes). Since I know exactly what the stream was (custom rule logic in Python), I can play the mp3 (knowing its length), and resume the stream again. It works because it is a very narrow use case.

1 Like

I have 2 devices in two different rooms: a Google Home mini and a regular Google Home (cylinder).

Hmm, I don’t have the original Google Home any more, but I do have Mini. If you don’t have dedicated IPs, I’d suggest trying that.

That’s not the source of the instability. I always have fixed IPs on such things, and I’ve had plenty of instability with the Chromecast binding. That said, I didn’t use it for anything, so I just uninstalled it, but it also made the rest of OH laggy/slow as I experienced it. I uninstalled it years ago, so this isn’t something new.

I’m using the Chromecast binding for most of the things listed above:

  • Announcements broadcast using local TTS and sending to a CC group or individual CC devices depending on what is online (Chromecasts often go offline and come back online)
  • Play a sound file (MP3), either as an announcement or in one case to stream “Brown Noise” to help drown out noise. In the “Brown Noise” case, OH needs the CC channels to properly report playback status since the MP3 file eventually ends and OH needs to detect this and restart playback immediately to minimize playback disruption.
  • Detect that a CC device has started streaming audio and turn on the appropriate equipment so it can be heard
  • On the sitemap, when a CC device starts playing (!stopped), enable display of some of the device item channels that are useful (what’s playing, volume/mute control, stop playback)

Given the problems I’ve had with exhausting the OH thread pool I’d like to be able to uninstall the binding but the use cases above are important for me. I’d love to see the binding improved :grinning_face: .

2 Likes

This is one of the things I expect should be taken care of - at least it’s one of the essential goals.

I’m 99% sure that it’s possible to set the Chromecast to repeat either the whole playlist or one item, so it shouldn’t necessary. But, the binding probably doesn’t expose this functionality, I’ll have to try to remember to look for a place such a setting could fit.

1 Like

I have chromecasts throughout my house but i mostly use it for playing music in the garage.

When my garage chromecast isn’t idling in the garage (eg. someting is playing) it automatically turns on both TV’s ON and changes the amps HDMI input to the one the Chromecast is on. so when i’m playing spotify it displays on both TVs.

I have a auto group between my garage and deck speakers, when i play music to that group, openhab controls a ESP32 with a 8 channel relay via MQTT. This relay open/close the negative wire of each speaker channel on a monoprice speaker selector. The garage has inside speakers as well as exerior speakers under the eves, when i select this group it cycles the relay channels off for the garage interior speakers and turns the outside speakers on.

Inside the house, we use Google Mini’s in each room. My wife and kids sleep with the google playing whitenoise.

When any of those minis are detected playing whitenoise, the hallyway lights that connect all the rooms go into a night time setting, so when motion is detected in the hallway the lights turn on to 10% instead of 100% so it doesn’t bleed into the rooms under the door. Just a courtesy setting for those sleeping and thats my way to know when someone is sleeping

1 Like

Hello there, I am joining the conversation to expose my use case and add upon the tools I use to integrate the Google Cast devices into my automation system.

Regarding the pure Chromecast Binding in OpenHAB, it superseeded the ADB binding I was using up until the update to Android TV 14 on my Chromecast with Google TV: I have an automation in place that, given the time of day and sofa occupancy, dims the livingroom lights when some content is played from the Chromecast, and increases the brightness slightly after the content is stopped for 20 seconds

Since the CC+GTV uses directly apps in Android TV, the app developers themself must support reporting via Google Cast of the playback status, and not all apps do that (most notably for me, Jellyfin does not); via the ADB binding it is possible to collect such information bypassing Google Cast advertising, however with the new policies introduced in Android 14 that is not possible anymore, since I always power the TV and Chromecast devices off after finishing watching content (each time I should have to enable again adb over wifi on the chromecast, probably by emulating the remote via the android TV binding but that’s prone to more problems).

I also have a Google Home Mini 1st Gen. speaker, which I am using through Music Assistant installed in a container beside OpenHAB: this tool allows for supporting crossfade between content, looped playback of the same file, and integrates directly with local files and many online streaming services. On top of that, announcements that restore playback afterwards are supported. I can control it via its JSON RPC API from OpenHAB rules

1 Like

For the Google TVs are you aware of AndroidTV - Bindings | openHAB? That might provide better integration for your use case.

I did try with that binding for my automation, however it does not report the playback state if started from an Android TV app rather than with casting. I am already using this binding to emulate the CC+GTV remote from the OpenHAB app and avoid using the original remote that has too many buttons for apps I don’t even keep installed

I didn’t understand this part. Which API is this? A local one in the device?

Perhaps my first message was too long and not easily parsable, so please ask if you have more doubts; regarding the question on the API: I was referring to the software Music Assistant, that I am running inside a Linux container and I am controlling my Google Home Mini speaker through it. OpenHAB enters the equation by polling and sending commands to Music Assistant through an HTTP Thing and some Rules, that interact with Music Assistant via its own local JSON RPC API. Literally the OpenHAB container is sending the request via localhost to the Music Assistant container, which in turn communicates with any Google Cast device on the local network. This setup runs completely offline from the Internet, apart from the google DNS which if I block the Google Home Mini thinks it has lost connection and goes into access point mode for provisioning, but here I am diverting from the main topic

Since we’re at it: all Google Cast devices up untile the Chromecast 2019 expose a local API that let a capable user provision the device completely offline without a Google account nor the Google Home app (or play services installed in an Android OS, which is my case): GitHub - rithvikvibhu/GHLocalApi: (Unofficial) Google Home local API documentation.

A script for exploiting this API is being shared around in GitHub under the name “castanet“, and that is what I used to provision offline the Google Home Mini: Set up a Chromecast from a Linux PC, without an Android or iOS mobile device and without Google Home · GitHub

The Chromecast with Google TV instead has Android TV on board and apparently requires at least a Google account to perform the provisioning (but you can perform all the steps from the device without another “Googled” device)

1 Like

I understand now - you’re using the Music Assistant local API from OH. I assume that Music Assistant still require you to sign up for a “Google developer account” etc. to get local access to the devices. These things are done using “Google Home” related protocols, not the cast protocol, and isn’t really a focus for me, because I can’t test things that require “cloud” accounts as I refuse to use such services.

The reason I asked is that I can see from this thread that if we could find a way to play audio on cast devices, where they would resume what they were doing when the audio was done, it would be a great help to many people. So, I’m always interested in this topic, to see if there’s something I’ve missed. But, doing it using the “Google Home” protocols is already a known approach, one that somebody else than me will have to implement.

Music Assistant does not require any “account“, its just software that you may run on a machine on your network (even isolated). I suggest to reviwe their project if you are interested in the inner workings or how they are achieving the functionality; besides, it’s a useful tool which can integrate many services (both local or non-local) into the same “music library“.

I am not familiar on the way this is achieved inside Music Assistant, however the feature I consider to be “available“ by adding this tool (Music Assistant) to the automation workflow.

1 Like

I blend the Chromecast plugin with the AndroidTV (GoogleTV) on my garage setup as well. Chromecast gets better casting details (whats playing, if its idling or not) ad i mostly use the GoogleTV power status to help with turning my TV’s on/off.

Forgot to add, i created a WLED matrix LED sign, when i’m playing music to the Chromecast, i grab the artist and song title to be displayed on the WLED sign:

2 Likes

Yes, the amount of logging is insane. I had to shunt it to another file without a size limit. Otherwise, it rolls over too fast. In the couple of minute it took to create the test it generated 36 MB of logs. Grrrrrrrrrr.

Here’s a link to the file. I hate doing that but I’m not going to break the file up into nearly 40 separate 1 MB files. https://drive.google.com/file/d/1vDt112AMDU8w0s4VLPKUt4X2L3gk15rc/view?usp=sharing

One thing I did notice is the Thing never went offline (that I noticed, it may have refreshed itself). The Thing IP moved to one of the other devices in the Group automatically.

1 Like

I have downloaded the file, so you can unshare it if you wish to.

1 Like