NFL game sensor (scores, possession, etc)

Sure, I made a custom effect with the colors I wanted in the hyperion backend. And then I use a shell command to call it in Home Assistant.

in configuration.yaml

shell_command:
  hyperion_gpg: curl "http://192.168.0.231:8090/json-rpc"   -X POST   -d "{\"command\":\"effect\", \"effect\":{\"name\":\"Go Pack Go\"}, \"duration\":10000, \"priority\":1, \"origin\":\"Home Assistant\"}"
  hyperion_stop_effect: curl "http://192.168.0.231:8090/json-rpc"   -X POST   -d "{\"command\":\"clear\", \"priority\":-1}"

and this is the automation (which also triggers a LIFX bulb and WLED strips)

- id: '1607306431209'
  alias: NFL - Go Pack Go
  trigger:
  - platform: state
    entity_id:
    - sensor.nfl
    attribute: team_score
  condition:
  - condition: state
    entity_id: sensor.nfl
    state: IN
  - condition: template
    value_template: '{{ (trigger.to_state.attributes.team_score | int) >= (trigger.from_state.attributes.team_score
      | int + 1) }}'
  - condition: template
    value_template: '{{ (trigger.to_state.attributes.team_score | int) <= (trigger.from_state.attributes.team_score
      | int + 6) }}'
  action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
  - data:
      mode: strobe
      brightness: 255
      rgb_color:
      - 3
      - 171
      - 0
      period: 0.5
      cycles: 20
    target:
      entity_id: light.lamp
    action: lifx.effect_pulse
  - data: {}
    action: shell_command.hyperion_gpg
  - type: turn_on
    device_id: fbbc7b604f8cd4f13d8fbf1eb656d6de
    entity_id: 9c7e3d05cf771f816a3974c19e823716
    domain: light
    brightness_pct: 100
  - type: turn_on
    device_id: e8b124eaae74dfc33158bc0bdfeaec57
    entity_id: f6b2a26d93d1906a7b609cf2e5fbd7d0
    domain: light
    brightness_pct: 100
  - device_id: ede6522057e1a6336b15b9c326292d2f
    domain: select
    entity_id: f27d7a8c72655fa2917c7ba3e94e819c
    type: select_option
    option: Go-Pack-Go
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - data: {}
    action: shell_command.hyperion_stop_effect
  - type: turn_off
    device_id: fbbc7b604f8cd4f13d8fbf1eb656d6de
    entity_id: 9c7e3d05cf771f816a3974c19e823716
    domain: light
  - type: turn_off
    device_id: e8b124eaae74dfc33158bc0bdfeaec57
    entity_id: f6b2a26d93d1906a7b609cf2e5fbd7d0
    domain: light
  - type: turn_off
    device_id: ede6522057e1a6336b15b9c326292d2f
    entity_id: 48a682787486ac0673a704168522e697
    domain: light
  mode: parallel

The first delay is set up in case the sensor is ahead of the broadcast. The second delay is so the effects terminate after 10 seconds. You can adjust the conditions so they only happen for touchdowns or field goals. They’re currently set so every point triggers the automation.

This is a version with the LIFX and WLED effects stripped out.

- id: '1607306431209'
  alias: NFL - Go Pack Go
  trigger:
  - platform: state
    entity_id:
    - sensor.nfl
    attribute: team_score
  condition:
  - condition: state
    entity_id: sensor.nfl
    state: IN
  - condition: template
    value_template: '{{ (trigger.to_state.attributes.team_score | int) >= (trigger.from_state.attributes.team_score
      | int + 1) }}'
  - condition: template
    value_template: '{{ (trigger.to_state.attributes.team_score | int) <= (trigger.from_state.attributes.team_score
      | int + 6) }}'
  action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
  - data: {}
    action: shell_command.hyperion_gpg
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - data: {}
    action: shell_command.hyperion_stop_effect
  mode: parallel

Is go pack go the effect you custom-made? I’ll have to make my own effect?

Yeah you can make your own, or use a default one and define colors. I started with the police light effect and changed a couple settings and colors for my go pack go effect.

Hello folks!

I just installed this today, and as simple as the setup appears to be, it is erroring out on me when I restart HA:

Log details (ERROR)

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:361
integration: Sensor (documentation, issues)
First occurred: 3:12:20 PM (1 occurrences)
Last logged: 3:12:20 PM

Error while setting up nfl platform for sensor

Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 361, in _async_setup_platform await asyncio.shield(awaitable) File “/config/custom_components/nfl/sensor.py”, line 40, in async_setup_platform config.entry_id = slugify(f"{config.get(CONF_TEAM_ID)}") ^^^^^^^^^^^^^^^ AttributeError: ‘NodeDictClass’ object has no attribute ‘entry_id’

Hmmmmm. My config in configuration.yaml is super simple:

# Follow the Kansas City Chiefs
  - platform: nfl
    team_id: 'KC'

This is in the ‘sensor’ section of my configuration.yaml. I’m a solid user of HA but I’m not very familiar with troubleshooting it… I don’t see any sensor created. I’m happy to provide any information that may help if you let me know how to gather it. Thanks so much!

Geez, never mind, I was confused about configuring this. I followed the instructions more closely and it’s working just fine. Sorry for the noise. :slight_smile: And thank you for a great integration!

2 Likes

I just found this thread and I am going to dive deeper into the comments. But I wanted to make sure that this group was aware of what @kbrown01 had created and the work that he and a bunch of us have been doing over here with Sports scores in general. A lot of work that maybe could be incorporated. Anyway more of an FYI and hello at the same time :wink:
https://community.home-assistant.io/t/sports-standings-and-scores/547094