My Own Awesome Goal Celebration Button
When Budweiser came out with their goal celebration light, I fell in love with it immediately. For the uninitiated, it's a red light that connects to your WiFi and lights up and makes sounds whenever your favourite NHL teams score a goal. But there were two problems: 1) it was always sold out, and 2) it's expensive -- $160, a little steep for a novelty light... So I got to thinking that I could make my own. I've already had experience working with NHL's scoreboard feed for the Scoreboard module on my Magic Mirror. In theory, it should just be a matter of monitoring the feed, and when there's a score change, do, well.. something... with it.
I have plenty of smart home devices. It would be fantastic if I could tie into those to signal a goal. I have a marquee light sign above my TV that reads "#CHEER" hooked up to a smart outlet, and a Sonos speaker system. My goal celebration, then, would be to light the "#CHEER" sign and blast the Maple Leafs' goal horn through the Sonos system.
Monitoring the scoreboard feed seems like it would be the easier part of the project, so I set about trying to figure out how to trigger the smart home devices.
#CHEER at the Top of Your Lungs
The #CHEER sign is hooked up to a smart outlet, which is in turn connected wirelessly to my Wink smart hub. There is a public API available that allows anyone to program extra capabilities not natively offered by the hub. You have to request an API key from Wink before you can get started. Luckily I already had one from a previous project. So away I went!
I went in search of libraries that expose the API to various languages and platforms. I found one made for NodeJS called wink-jsv2, and since I'm most familiar with JavaScript, it was the one for me. It took a little trial and error, but after looking at a few examples, I was able to figure out how to trigger the light to turn on and off.
Play It Loud!
Turning on the light is cool, but it doesn't have the drama and excitement I'd like. I wanted the sound of the Maple Leafs' goal horn that is played at Air Canada Centre whenever the Leafs score to come through loud and proud! Surprisingly, finding just the goal horn sound on its own was quite difficult, and the one I did find was distorted. However, finding the horn followed by the celebration song was much easier. Using one of the many audio strippers found on the web, I was able to get just the audio from this YouTube video:
One problem is that the song lasts for a minute. It gets real old, real fast when you don't have 20,000 fans all singing along. After a little time spent in Adobe Audition, I was able to trim it down to a more reasonable 24 seconds.
Getting it to play through the Sonos system was trickier than I expected it was going to be. Unlike Wink, Sonos doesn't have a public API. However many smart individuals spent time reverse engineering the protocol, and I was able to find a Node module for interfacing with Sonos, aptly named sonos. I spent quite a bit of time hacking away before I got things to work right.
Monitoring the Feed
Monitoring the feed was the easy part. NHL's scoreboard feed is available free and clear like so:
http://statsapi.web.nhl.com/api/v1/schedule?teamId=10
This will give you today's scores for team ID 10 -- Toronto Maple Leafs, which I got from:
So using the NHL feed, here's a best-case example:
Not terrific, but also not horrible... but here's a worse (and sadly more typical) case:
Not the instantaneous, jump to your feet celebration I was hoping for.
Hell of a goal by Auston Matthews though!!
P.S.: These two examples are using the first sound clip I found of the goal horn. Not sure if the distortion comes through in the video...
A bit of googling turned up this product:
I have a simple routine that polls the API every second and looks for a change in score.http://statsapi.web.nhl.com/api/v1/teams
Now Here's The Kicker...
The big problem with this approach is that there is a significant delay between seeing the goal scored on TV and for the change in score to be registered in the feed, anywhere from 10 to 30 seconds. Not exactly timely for this kind of application. I spent quite a bit of time researching this, and it looks like all of the publicly available feeds have this type of delay. Ironically the NHL one seems to be the most timely. What I really wanted was to be able to have access to Budweiser's Red Light goal feed, but I couldn't find any reference online of someone who had successfully reverse engineered it. This article comes close; it was the best try I could find.So using the NHL feed, here's a best-case example:
Not terrific, but also not horrible... but here's a worse (and sadly more typical) case:
Not the instantaneous, jump to your feet celebration I was hoping for.
Hell of a goal by Auston Matthews though!!
P.S.: These two examples are using the first sound clip I found of the goal horn. Not sure if the distortion comes through in the video...
So Now What?
For testing purposes, I had the script trigger a goal alert when the space bar was hit... which turned out to be a lot of fun! Instead of triggering automatically based on a change in the feed, there was something innately satisfying about hitting a button when a goal was scored. So it got me thinking that maybe what I needed instead was a goal button that anyone could hit when the Leafs scored.A bit of googling turned up this product:
100 mm of light-up push-buttony goodness! |
And I found a box for an old Apple Airport Express lying around that was just the right size to mount the button on top of.
Apple's thick cut, over-engineered packaging should be able to take repeated slams of the button on top! |
The first step was to flip the box upside down and mark out a hole for the button innards to poke through...
...then cut it out with an X-Acto knife...
...and finally secure the button from underneath using the included fixing nut.
Meanwhile I had on order a brand new Raspberry Pi Zero W. This is an all-in-one computer on a board measuring 6 cm x 3.5 cm. What's special about the Zero W is that is already has WiFi built-in, so everything I needed for communicating with all of my Smart Home devices is included.
Look how tiny this thing is! |
The Airport Express packaging comes with a cardboard insert that separates the unit itself from all the accessories it comes with. Makes for a neat little platform on which to mount the Raspberry Pi. I picked up some 6 mm nylon standoffs, along with some matching nuts and screws, and mounted the board right on the insert.
This insert turned out to be quite convenient! |
Standoffs attached to the Pi |
Holes poked through the cardboard insert. |
Pi mounted to the cardboard insert |
Pi wired to the Big Blue Button |
Everything tucks away neatly, with a convenient hole for the power cable to poke through. |
Now with everything hooked up, here's the button in action:
But Wait! There's Just One More Thing.....
How can I justify using an old Apple box if I didn't also channel my inner Steve Jobs and include "One More Thing™." Once everything was put together, I was reminded of Maple Leaf Gardens with the big dome on top of the square building.The last shrine of the Original Six looks a little like my box with a big dome button on top! |
So why not turn my goal button into a little Maple Leafs Gardens? I took to Adobe Illustrator and designed some stickers that could cover the whole thing.
I spent quite a bit of time on the marquee. Those who know their Maple Leaf Gardens history know that the marquee has changed many times over the years. Maple Leaf Gardens has since been restored and is now a historic landmark... supermarket... and the current marquee is a replica of the original from when the Gardens first opened. I was going to model mine after that, but I thought it would be a better tribute to style my marquee after the last one the Gardens featured while the Leafs still played there. Therefore I modeled mine after this version:
What MLG's marquee looked like on the last day the Leafs took the ice there. |
I bought some full page labels from Staples and printed these all out on a colour laser printer.
I used an X-Acto blade to cut them out, and carefully positioned them on each side of the box. My wife saw me doing this and asked me if I was doing decoupage. I thought that sounded like a fancy French term for stickers. So I said yes.
My favourite detail is the Zamboni parked out back:
Here's the finished product!
It's pretty cool! My kids love hitting the button when the Leafs score, and I can't wait to use this during a hockey party, or better yet during a playoff game!
Alas, I'm always my own worst critic, and I'm already noticing imperfections that I'd like to fix. I don't particularly like the fact that the power cable sticks out the back, and ruins the otherwise clean, standalone nature of this appliance. So I'm going to look into running this off of a battery pack. I've also noticed some imperfections in my sticker design, and I'm planning on making some tweaks and printing out a second version. Luckily the labels are removable... replacing them should be a piece of cake... right?
Anyway, I hope you've enjoyed my latest Nerdy Project!
GO LEAFS GO!!!!
- jc
Do you have this in Git!? I'm trying to do this same set-up with a momentary button, LED lights, and a Google home speaker.
ReplyDeletehey, I was thinking about doing something similar and was wondering if you would like to share how you pulled this off? thanks
DeleteYep! Here you go:
ReplyDeletehttps://github.com/jclarke0000/goal_light
In order for it to work right, you need to host the MP3 file LeafsGoalSongShort.mp3 (or any celebration song of your choosing) on an HTTP server. I just installed Apache on the Raspberry Pi and hosted it there. Also, it helps if your Sonos speaker has a constant IP address. I made a DHCP reservation for my Sonos speakers so that they always have the same IP address. You'll see configurations both for the Sonos IP and the celebration song URL at the top of the script.
This is awesome, I am going to do something similar but I will probably end up buying a Fibaro button. I also tried using nhl API its just too inconsistent. Also if i have the game paused for a min its a huge spoiler. Do you still have the button? any changes to your button setup? Have you tried budweiser goal light? I assume it would be using nhl API as well but not confirmed
ReplyDeleteI still have the button, yes. I stopped trying to synchronize it with a data feed. It is now solely a manual push button that triggers the Maple Leafs goal horn and song to be played whenever we want through the Sonos speakers.
DeleteHave you tried the budweiser goal light? I wonder if there is a way to activate the goal light with home assistant, instead of solely relying on the built in light automation.
Delete