My project started to gain some traction on Reddit so I thought I would share with the Home Assistant Community at large.
In essence, it is a custom sensor that allows you to track your favorite NHL team(s) in the front end and/or use the information exposed to trigger an automation. It uses the NHL’s undocumented API so all the information comes straight from the source. Want to be notified when the Habs game is about to start? Easy. Want that LED strip around your TV to flash red when the Blues score? Done. Want the Leafs to win the cup? Well… can’t help you there.
The custom component is available for installation through HACS. Manual installation is of course also possible. Check it out here!
I’m currently working on firing a custom event when a goal is scored so that automations can be triggered even more effortlessly. As of version 0.5.0, you can use the nhl_goal event to trigger automations! Looking forward to your feedback!
I’m curious what kind of delay there might be in their API for updates when goals are scored. I can only imagine the lightbulbs start going crazy blinking at a random time because a goal finally updated via API.
After extensive testing, it is usually immediate. For best results, you can set scan_interval to 1 which will poll the API every second. Then, if your automations get triggered early because of stream/broadcast delay, you can adjust the delay in your automations.
Disclaimer: Polling the API is not recommended if running off an SD card or if you have an extremely low data cap with your ISP. Objectively, the sensor does not consume a lot of data but this will definitely add up with a high frequency of updates.
@jayblackedout I was wondering where to find you to thank you and call you a wonderful human being for making this work so well. Thank you, you wonderful human being.
When are you doing the PR on the main HA to make this a permanent integration?
@databoy2k Haha, that’s very kind of you. There’s a few things I want to work out before submitting the PR. Hopefully I’ll manage to get everything up and running before Christmas and will submit then.
Hi @jayblackedout thank you for putting this together, I was waiting of the nhl_goal feature (which is huge) so now I’m incorporating this into my setup. I’ve installed through HACS and added this to my configuration file but its throwing this error: Platform error sensor.nhl_api - No module named 'pynhl'
@dusing I moved the API calls to a third-party PyPI package I created to be in line with HASS best practices. This probably means that the package installation failed through PIP. Have you tried restarting Home Assistant?
@Corey_Maxim Maybe I’ll feel adventurous one day. I used to be way more into the NFL in college.
@gkron I’ll get in touch with the guy who shared these automations and will get back to you. I highly recommend you use the new nhl_goal event as a trigger though. You can find the yaml for that in the very first automation example.
Thanks for the good work, well done write up.
Anyone figure out a way to trigger an automation based on whether it is a win or loss. I get colored lights to flash when there is a score but would like a game end win vs game end loss notification.
Should look like this, correct? Automation is in a automations.yaml. Animation seems to fire just fine based on the tracked team goal, however the action does not fire. Manually triggering the service in the dev tools to make sure it work, and it seems to be just fine.
@SirRobin I will add that in a future update. Be sure to star the GitHub repo or check back here for updates.
@THland83 Question to help troubleshoot. When you say you trigger the event in the dev tools, do you mean the actual event or the automation? Also, can you paste what you have in configuration.yaml to set up the sensor?
I’ve found it to be really quick. I’ll be watching a game casted to my tv and my goal song starts playing well before the goal is actually scored. Had to turn that automation off to avoid spoilers lol.
@jayblackedout thank you for this wonderful component. I’m using it to create personalized alexa alerts for when I’m home but unable to watch the games.