Enter the friendzone

On Chromecasts and Slack

Or how we had to hack a Chromecast and Raspberry Pi in the name of music.

"Without music life would be a mistake"

Friedrich Nietzsche

Or how we had to hack a Chromecast and Raspberry Pi in the name of music.


Okay, first a little background. We - at Bagaar- are involved in all things digital. By nature many of us are interested in discovering new things and that includes music, lots of music. In the past we built a Slack integration that checked the 'current DJ' at the office Last.fm scrobbles and posted them to a Slack channel for all to see.

This worked fine while we were using an Apple Airport and Airplaying our tunes with Spotify.

Almost there...

Being developers and all, we obviously saw this as a challenge rather than a problem. I knew the Chromecast had an API, so I started digging. Some Googling later, I found a nice JavaScript library -(https://github.com/thibauts/node-castv2) - that did just what I wanted. It can fetch all kinds of data from the Chromecast: Artist, Track, Album, Spotify URI, etc... but there was one issue left. The Chromecast sits in our internal network and we're not too keen on opening ports into our network when not absolutely necessary.

WebSockets to the rescue

In the office we have a Raspberry Pi connected to a television doubling as office dashboard. It seemed the perfect candidate to host our music tracker. On the Pi we decided to run a little Node.js application that connects to a WebSocket server and waits for commands. Now whenever someone uses the Slack command a webhook on a server is called that sends a message to the Pi over the websocket, which then in turn fetches and parses the Chromecast data and sends it into the originating Slack channel.

Point and case:


Everybody happy!

Read more