This is great, I added the calendar sensor for the schedule to my set-up. Assuming the google calendar is regularly updated with schedule changes, it should come in handy with the fact that game times and event days are not necessarily set in stone this year…
This is how I’ve implemented some automations to start updates using the calendar and then continue throughout the game.
#####Automations#####
- id: saints_update_sensor_to_start_game
alias: Saints - Update to Start Game - Google Calendar
description: ''
trigger:
- platform: state
entity_id: calendar.new_orleans_saints
from: 'off'
to: 'on'
condition:
- condition: not
conditions:
- condition: state
entity_id: sensor.nfl_game_status
state: In Progress
action:
- service: homeassistant.update_entity
data: {}
entity_id: sensor.nfl_game_status
- delay: 00:01:00
- service: automation.trigger
data:
entity_id: automation.saints_update_sensor_to_start_game
mode: queued
max: 15
- id: saints_update_during_game
alias: Saints - Update Every 10 Seconds During Game Only
description: ''
trigger:
- platform: state
entity_id: sensor.nfl_game_status
to: In Progress
condition:
- condition: state
entity_id: sensor.nfl_game_status
state: In Progress
action:
- repeat:
until:
- condition: state
entity_id: sensor.nfl_game_status
state: Final
sequence:
- service: homeassistant.update_entity
data: {}
entity_id: sensor.nfl_game_status
- delay: 00:00:10
mode: single
Sorry formatting is a little sloppy because I (perhaps obviously) made them in the UI.
What are you all using the sensors to do? I see @ryanlocey is setting lights to his team’s colors and playing cheering on an alexa device when they score.
For a touchdown, I am flashing (non-RGB) lights in the Living Room (conditioned by if I’m home and the TV is on) and using the workaround outlined in this thread - Play a local mp3 file on Alexa Echo dot - to play a voice recording from my team’s home in stadium announcer - followed by 1.5 min of on-theme celebratory music randomly from a playlist. I can get into all that if people are interested in discussing? It’s ridiculous, but I’m a season ticket holder and haven’t missed a home game since 2005 until coronavirus came along, so it’s helping me cope!
Thanks for sharing!
I implemented the google calendar for Kansas City and use your initial automations, and it works that I got a notification when the game started (I think it worked, will see on the next game :D). But without a variable and im not sure which I need to display the other team in the notification?
And how do I automate that my lights are flashing if we score a Touchdown?
Although I hope if you implement celebratory automations for Kansas City, none of them are triggered this coming Sunday, here’s what I’ve done to create touchdown automations:
alias: Saints - Touchdown Tracker
description: Turns on input boolean for three minutes if Saints score changes by 6+ points
trigger:
- platform: state
entity_id: sensor.nfl_away_score
- platform: state
entity_id: sensor.nfl_home_score
condition:
- condition: and
conditions:
- condition: template
value_template: |-
{{ trigger.to_state is not none and trigger.from_state is not none and
trigger.to_state.state|int > (trigger.from_state.state|int + 5)
and "NO" in trigger.from_state.attributes.friendly_name
}}
- condition: state
entity_id: remote.living_room_hub
state: 'on'
- condition: zone
entity_id: person.davearneson
zone: zone.home
action:
- service: input_boolean.turn_on
data: {}
entity_id: input_boolean.saints_touchdown_detector
- delay: '00:03:00'
- service: input_boolean.turn_off
data: {}
entity_id: input_boolean.saints_touchdown_detector
mode: single
Before setting up this automation, I created an input boolean using helpers to function as a trigger for any other automations I want and called it “Saints Touchdown Detector.” The above automation turns on this input boolean for three minutes before turning it back off, because there has been some instability with the data getting pulled from NFL.com that resulted in multiple triggers, and that seemed to help prevent multiple triggers for one score.
If you have set up the sensors that @yguns31 outlined in their post, this should work and you can just use the input boolean as a trigger for whatever you want. As I think you saw, I outlined in a previous post how I set up the sensors to update every 10 seconds during a game using that google calendar.
I also created a lovelace page that I can use to keep tabs on all the sensors and/or manually refresh or turn on/off the touchdown tracker if I get impatient or want to test automations.
Let me know if any of this helps or if you have other issues. (I’m not sure how to pull the opponent name from the calendar, maybe someone else can chime in on that one.)
Oh Boy, thanks a lot!
But I wish you good luck on sunday, u are not always blessed with the right decisions from your referees.
I implemented your touchdown tracker and two more automations:
The first one should flash my led red when im at home and the second one send me a push message, if im not at home. (Still not sure how I implement the score and the other team in this. ^^")
Whats the best possibility to test this?
When I first set this up for myself, I tested that I was getting the info pulled correctly from the nfl resource by duplicating all of my sensors and changing the target from “NO” to whatever team was playing the Thursday night game. (This week it’s “LAC” or “LV” for the Thursday game.) Then I just added the sensors to lovelace, ran my “update every 10 seconds” automation, and watched to see if they updated as the game progressed. You could obviously do this by just changing those target values in your regular sensors, but you’ll see there are a number of places where those need to be changed, and I just didn’t want to have to worry about missing one when changing back.
If you want to display who the opponent for the game is from this sensor, it’s going to be the value of sensor.nfl_home_name or sensor.nfl_away_name. (If you used the naming conventions from @yguns31’s sensors from post 31 in this thread.) These sensors don’t parse information in a “Chiefs are playing the Saints away” type syntax, instead (in your case) it would be filtering the data to find the game that has the Chiefs as one of the teams and then telling you the home and away teams of that game. If you want to use the sensors as written to pull both teams to display in a push notification or something, you could use the following template (which I filtered to capitalize the friendly names, because mild OCD):
{{ state_attr('sensor.nfl_home_name', 'friendly_name')|capitalize }} vs. {{state_attr('sensor.nfl_away_name', 'friendly_name')|capitalize}}
This would result in “Saints vs. Chiefs” for the upcoming game. (As a side note, the nfl resource doesn’t update for the upcoming game until Wednesday/Thursday each week, so for me right now this template would show “Eagles vs. Saints” - don’t remind me…)
Thanks. Noticed the playoff xml feed now includes more info for each game, like timeouts remaining, down and distance, ball location and score by quarter. Let me know if anyone would like that information in a sensor.
My silly pandemic project was creating this mini scoreboard using some OLED displays. So having the timeouts enhances the look for me.
(Yes, it’s dumb that I have the scoreboard beside the TV that is showing the game with the score on it.)
Yes. It’s running a ESPhome on a ESP8266 with 4 SPI OLED displays (2 SSD1306 and 2 larger SH1106). I used SPI displays instead of I2C because it’s easier to have multiple displays on one ESP.
The code is a little messy since I use it to display other things when there aren’t games on.