NFL game sensor (scores, possession, etc)

So, I’m getting ready for the NFL season and noticed my card stopped working. It was showing the details for the first regular season game, but now it’s showing ‘Better Luck Next Year’ I’m not a programmer by any stretch, but I can follow along a bit. Did the source this was using change, or is there something bigger going on?

Thanks for the help!!

Nothing changed other than which games they show. There’s an issue on Github tracking this, but the issue is now that we’re “in season” only the current week’s game shows. In this case that means only Jax/Oak shows up in the feed.

Should be just fine after this week, but as far as the API is concerned, that’s the only game (and only teams) in existence.

1 Like

Happy Pre-Season everyone!
Just thought I’d check and see if anyone else is seeing issues with team colors?
The sensor doesn’t appear correct for me
image
49ers colors are listed as the same as the Packers colors

But in the json, they’re correct
image

1 Like

My fault, and thanks for catching & fixing and thanks @zacs for accepting @D34DC3N73R’s fix PR. I was in too much a hurry to get the afc/nfc game colors covered. Since I started playing with WLED a few weeks ago, I’d planned on using the colors for lighting effects during games the regular season, so this bug would have bitten me hard once pre-season ended. I’ll be too busy until then to add the lighting stuff to my nfl automations, but here’s a sneak peak of my dashboard will look on Sundays:


1 Like

Guys this is Awesome!! I have several cards built and working perfectly.

Here’s the thing I want to do…, there used to be an integration from NFL to IFTTT that I used to trigger my RGBWW lights to flash every time my team scored.

Does anyone have any automations that trigger on every score for a given team?

I’ve been working on a blueprint for mobile app notifications that I’m almost, but not quite, ready to share, and I have an automation & script combo for light flashing (I’m using a wled strip, and have it pull the team colors for a number of teams I’m following). The automation & script isn’t polished, but I’ll share as an example (you’ll definitely need to modify to suit your needs/specific setup).

automation:

alias: NFL WLED Team Colors
description: >-
  Watches for any NFL integration entity game score to change (or to enter 'POST'
  status) and changes 
trigger:
  - platform: event
    event_type: state_changed
condition:
  - condition: template
    value_template: >-
      {{ trigger.event.data.entity_id in integration_entities('nfl')

      and trigger.event.data.old_state is not none

      and trigger.event.data.new_state is not none and
      trigger.event.data.new_state.attributes.team_score is not none and
      trigger.event.data.old_state.attributes.team_score is not none and
      trigger.event.data.new_state.attributes.opponent_score is not none and
      trigger.event.data.old_state.attributes.opponent_score is not none

      and ( (trigger.event.data.new_state.attributes.team_score !=
      trigger.event.data.old_state.attributes.team_score) or
      (trigger.event.data.new_state.attributes.opponent_score !=
      trigger.event.data.old_state.attributes.opponent_score) or
      trigger.event.data.new_state == 'POST' )}}
action:
  - service: script.nfl_wled_color
    data:
      team: '{{ trigger.event.data.entity_id  }}'
      team_scored: >-
        {{ 'yes' if trigger.event.data.new_state.attributes.team_score >
        trigger.event.data.old_state.attributes.team_score else 'no' }}
mode: queued
max: 3

script:

alias: NFL WLED Color
fields:
  team:
    name: Team Sensor
    description: NFL Sensor
    example: sensor.nfl_phi
    required: true
    selector:
      entity:
        domain: sensor
        integration: nfl
  team_scored:
    name: Team Scored
    description: Set to true if the team scored, false if the opponent scored
    example: true
    default: true
    required: false
    selector:
      boolean:
variables:
  red: '{{ state_attr(team,''team_colors'')[1][1:3] |int(0,base=16)}}'
  green: '{{ state_attr(team,''team_colors'')[1][3:5] |int(0,base=16)}}'
  blue: '{{ state_attr(team,''team_colors'')[1][5:7] |int(0,base=16)}}'
  colors: '{{ "team_colors" if (team_scored == "yes") else "opponent_colors" }}'
sequence:
  - service: scene.create
    data:
      snapshot_entities: >-
        light.wled_2, select.wled_color_palette_2, number.wled_intensity_2,
        number.wled_speed_2
      scene_id: wled_capture
  - service: rest_command.screen_pi_wled_nfl_score
    data:
      team_primary: '{{ state_attr(team, colors)[0][1:7] }}'
      team_secondary: '{{ state_attr(team, colors)[1][1:7] }}'
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: scene.turn_on
    target:
      entity_id: scene.wled_capture
    metadata: {}
mode: single
icon: mdi:palette

rest_command:

  screen_pi_wled_nfl_score:
    url: 'http://WLED_ADDRESS/win&A=192&SX=128&IX=128&FX=71&CL=H{{ team_primary }}&C2=H{{ team_secondary }}&C3=H000000&FP=3'

I’m not especially happy with the event trigger, it triggers on EVERY state change, but since my wife and a few friends all do survivor pools, it makes it easy for me swap teams in and out of HA every week and it just picks up every nfl integration sensor. The condition filters out a lot of the noise. The blueprint I’m developing won’t use event triggers, I’ve got it in a more polished state since I intended from the start to share it, but I want to finish up a few things and test it this weekend before making it available. The above was all built just for my own use.

4 Likes

Honestly it shouldn’t be that hard for me to add component-specific events (eg your team scored, opponent scored), I just have no time at the moment. I think it would just involve saving a prior state then comparing to current, and firing the event. Hopefully can get to it in a couple weeks.

5 Likes

That would be awesome!

So I finally am ready to share the notification blueprint, called NFL Game Score Notification.

Click the Import Blueprint button to add it to your Home Assistant:
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

This will produce mobile app notifications on any score change (td, field goal, extra point), optionally excluding opponent scores. The notification will include data such as the quarter and game clock at the point the score was reported by the api, timeouts remaining, and win probability. It will also report the final score when the game ends. The notifications will be grouped together (separate from other HA notifications) and include metadata tags that allow the individual notifications to be replaced as new scores come in (in practice this works a little bit like Apple’s recently announced Live Activities, where you just see the latest information if you don’t swipe the notification away during a game).

You can track as many games and notify as many devices as you’d like, just select them in the automation.

I’m looking for some feedback on it before I create a post in the Blueprints exchange. One known issue, that I think is a Home Assistant bug (github frontend issue), is that if you remove a device in the UI, the automation doesn’t update (meaning the device isn’t actually removed from it). Until that is resolved, you’ll need to either edit the yaml to remove a device, or you could simply delete the automation and recreate from scratch since there aren’t many options.

Example notification on iOS 16 (note: not from a real game).
The dots after the scores are the remaining timeouts.

Example notification on an Apple Watch
Watch View

2 Likes

Does this work with android formatting options? You can do some extra things with Android… I did get it installed for the end of MNF and got the closing score. Wont be able to test again until TNF. Thanks for pulling this together!!

What kinds of things would you want? I’m not opposed to adding options, but I don’t have an Android device to test with. At the moment, the code as it is released is only using platform-agnostic features (namely groups and tags). Talking about improvements: I’m thinking I’d like to include a url field, so the notification could link to a specific Home Assistant dashboard view or an external website like the ESPN or NFL websites.

Does anyone have an automation (or preferably Nodered flow) for flashing lights (wled) when your team scores?

Also, what’s the possibility of having this functionality for NCAA Football??

I don’t use NodeRed, but here’s my take at a wled flasher (uses the team colors present in the data):

I’m not using wled, but using a combination of rgb bulbs (philips hue, zigbee, etc), so not quite sure how to adapt this. Plus, all of my automations are in Node Red, so I would love some help trying to decipher this.

The wled stuff I shared above was more of a personal project and I don’t think I’ll be turning that into a polished/finished blueprint or automation any time soon - it’s way too customized to my specific environment. But zacs recently accepted a contribution I made to the ha_nfl repository for a simple Home Assistant rgb light flasher blueprint. It’s very easy to set up and use. You just have to select one or more nfl entities (this integration), and select one or more home assistant light entities when setting up the blueprint. It will flash the light(s) a configurable number of times in the team colors and then return it(them) to the original state(s). It’s quite simple, nothing fancy, but does the job well enough.

NFL Game Score Light Color Flasher

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.
This blueprint will flash one or more lights using the team (or opponent) colors provided by the api on any score change (td, field goal, extra point), optionally excluding opponent scores.

You can track as many games and control as many lights as you’d like, just select them in the automation. You can also select the number of times to cycle through the team colors (1-15 times).

2 Likes

Works great! I tested it on the Eagles/Texans game last night. Amazing how delayed the Amazon Prime broadcast was though. The lights flashed almost a minute before the TV scores. Might need to figure out a delay based on what network is broadcasting.

Yeah, when I watched games via Comcast cable before switching to Youtube TV, every network was also pretty delayed compared to the ESPN data feed. YouTube TV with RedZone and local network games has generally been only 5-10 seconds off, which is probably as good as it gets. The integration polls every 5 seconds during live game time, so it’s almost never going to be a perfect match. When I have some free time I’ll see about adding an optional delay field to the blueprint so users can fine-tune for themselves.

Not sure if this is the right thread, but the kickoff day is wrong on some of the game cards. IS there a way to custom change this? I.E Kickoff in a day when its actually two days away.

No, there’s currently no way. But which ones? Would like to look into why.