NFL game sensor (scores, possession, etc)

just pushed an update to float the probability sensors to 2 decimals. otherwise, the card itself seems to work as intended. still getting some errors from the integration between plays.
image

I haven’t experienced that. I did notice if I wanted to set a different team, I needed to delete the integration then set it up again with the new abbreviation.

First of all I want to say thank you for all the work you guys have all done on this. I’m a bears fan, I know I know, but set up a card for tonight game and it’s amazing! I’m fairly new to HA so sometimes I have a tough time but most of the time I can stumble through setting stuff up. I read the whole thread, but could someone point me to an automation for when the bears score? Seems like the API changed so I just wanna make sure I’m understanding it all. Thanks again guys!

It was doing it consistently when I had it set up through configuration.yaml. Would expire and regenerate as ‘sensor.nfl_2’ etc. on every HA restart. Removed the config based setup and set up through the UI instead and now the name of the sensor seems to be stable on restarts. @zacs

That might explain it, I’ve always used the integration UI.

Your card looks ridiculously great, btw.

1 Like

This should work:

alias: NFL - Turn On/Off Touchdown Tracker Input Boolean
description: Turns on input boolean for 3 minutes if NFL score changes by 6+ points
trigger:
  - platform: state
    entity_id: sensor.nfl
    attribute: team_score
condition:
  - condition: template
    value_template: >-
      {{ trigger.to_state.attributes.team_score|int >
      (trigger.from_state.attributes.team_score|int + 5) }}
action:
  - service: input_boolean.turn_on
    data: {}
    entity_id: input_boolean.nfl_touchdown_detector
  - delay: '00:03:00'
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.nfl_touchdown_detector
mode: single

You can make the action whatever. I use an input_boolean helper as a go-between. Helps me with testing. You could easily skip the middle man and make your action the thing you actually want to have happen.

Awesome - I appreciate it! I’ll prob create a helper as well. That’s all I need to add though correct? Haven’t really used templates before

Yes, that should work as long as you’ve already set up the https://github.com/zacs/ha-nfl component @zacs put together, and have set it for the Bears according to those instructions. I do think the custom component is currently only capable of updating once every minute though, due to concerns of getting flagged by ESPN, so it might not be totally instantaneous. Am I correct @zacs?

AFAIK, he’s working on making it “smart” to update more frequently during games. Until that time, I’d recommend setting the time to a higher value and use the google calendar automation to trigger a home assistant update entity automation.

I mean I guess you could just set it to a minute, and use an automation triggered by sensor.nfl when it’s changed to IN, but you’d be pulling the API a lot needlessly.

Yeah, this is how I currently have mine set up. Slow default update value, then frequent forced update during the game. Similar to what we were talking about a couple of weeks ago, as outlined in my linked comment, but with @zacs sensor.

This seems to happen to me when I iterate on the code and deploy a new test, but if the component remains unchanged (or if I setup through the UI), it seems fine.

I am indeed working on making it smarter about refreshing. Missed my window for live testing tonight but planning on having something by Sunday!

Also agree that the card is looking great, and @davearneson are you okay with me adding your automation to the packages in the custom component? Would love for it to be as turnkey as possible :slight_smile:.

Yes, of course. Feel free to use anything I’ve posted in this thread that seems useful. I barely know what I’m doing, so anything that works is probably based on someone else’s ideas. Thanks for your work!

1 Like

Alright, smart refresh is checked in and working (to the extent I can test without live games going on).

edit: The 5 second interval (with 3 test games and logging turned on) seems to have ground my test server a bit. I removed two of my test sensors and it seems in better shape, but just fyi if this happens to anyone testing, you may want to disable logging :sob: . Upon second checking, the server is fine, it’s just the mobile site that is slow. Nothing to see here!

I left the interval config option in the UI, but it is being ignored right now (I’ll remove it fully once I confirm that everything works in the real world on Sunday).

The behavior is:

  • By default check every 10 minutes.
  • Once the official kickoff time is within 20 minutes and in PRE state, or if the game is in IN state, the refresh rate is set to 5 seconds.
  • Once the game enters POST state, the rate gets set back to 10 minutes.

If any of you testing (@D34DC3N73R , @davearneson) are willing to help debug in case shit hits the fan, it’s helpful to add this to your config file:

logger:
  logs:
    custom_components.nfl: debug

I also just realized it’s likely that bye weeks are going to screw with the sensor. I’m going to try to put some logic in for that, but TBH I don’t know what the data will look like in week 6 so there will likely be some issues then.

1 Like

So far so good boys.

It looks like its time to build an LED matrix scoreboard for shits and giggles.

3 Likes

Just wanted to give an update - Everything is working for the most part. The Bears timeouts do not change - I am also working on trying to get my automation for a score to work. For some reason it is not turning on my boolean

Anyway to add an option to delay to the sensors changes for those of us with a tv delay? (Streaming)

1 Like

Probably the only option would be to have a less-frequent sensor. I could add some sort of wait call before updating the values, but I think that could impact HA performance overall. It would have to be optional for sure.

1 Like

Hmm, I just created a sensor for CHI and I get the right timeouts. Are you still seeing 3 timeouts?

great work guys. these are awesome.