Receive Chromecast state

Hello,

My setup has a chromecast in an A/V receiver and uses the harmonyhub to control everything.

The receiver and tv do not support CEC, but I want to emulate it with Openhab. I tried the chromecast binding, but it seems to only support sending commands. Nothing seems to be listening for events from the chromecast. I wanted to use that to trigger the correct activity on my HarmonyHub when a play/pause/stop is received.

I tried the chromecast component of Home Assistant, and it did succesfully receive the new states instantly.

Is there anyone doing something similar here?

Thanks!

Hi there!

I am actually trying to achieve the same and I come to write an MQTT binding for Chromecast which I have put on github: https://github.com/nohum/chromecast-mqtt-connector

Sample items definition:

String audio_wohnzimmer_CONNECTION_STATE {mqtt="<[default:chromecast/your_ip/connection_status:state:default]"}
String audio_wohnzimmer_PLAYER_STATE {mqtt="<[default:chromecast/your_ip/player_state:state:default], >[default:chromecast/your_ip/command/player_state:command:*:default]", autoupdate="false"}
Dimmer audio_wohnzimmer_VOLUME_LEVEL {mqtt="<[default:chromecast/your_ip/volume_level:state:default], >[default:chromecast/your_ip/command/volume_level:command:*:default]", autoupdate="false"}
Number audio_wohnzimmer_VOLUME_MUTED {mqtt="<[default:chromecast/your_ip/volume_muted:state:default], >[default:chromecast/your_ip/command/volume_muted:command:*:default]", autoupdate="false"}
String audio_wohnzimmer_MEDIA_TITLE {mqtt="<[default:chromecast/your_ip/media/title:state:default]"}
String audio_wohnzimmer_MEDIA_ARTIST {mqtt="<[default:chromecast/your_ip/media/artist:state:default]"}
String audio_wohnzimmer_MEDIA_ALBUM_NAME {mqtt="<[default:chromecast/your_ip/media/album_name:state:default]"}
String audio_wohnzimmer_MEDIA_IMAGE {mqtt="<[default:chromecast/your_ip/media/images:state:default]"}

This actually uses PyChromecast which is the component used by Home Assistant :wink:

2 Likes

This is really good. I’ve been using the OH2 Chromecast binding, but it doesn’t get updates about the status properly so this looks a lot better.

I use my Google Home device to say alerts etc, some of them at late at night so I want a rule that will reduce the Google home volume but only if it’s not playing some music etc.

So thanks for creating and sharing this!

1 Like

This would appear more functional than the standard chromecast binding. Would this be something that can be incorporated to openhab, or is the functionality of pychromecast not present in whatever java lib is being used in the current binding?

The OH Chromecast binding definitely receives state. I use it to trigger both Harmony and speaker configurations when applications like Pandora start.

I’ve been in the midst of a giant remodel and all my home automation is currently not connected, so maybe something broke recently?

You can get a whole lot of information from the plug-in. Just make sure you look into the advanced settings. I know, I made one of the last big updates to it.