Absolutely.
Not sure I’ll get to it the next NFL game. But, I’ll certainly play with it when I can.
It will be fun that the wife won’t understand
Absolutely.
Not sure I’ll get to it the next NFL game. But, I’ll certainly play with it when I can.
It will be fun that the wife won’t understand
Example Homerun notification … just in case anyone wants it:
alias: Notify Homerun
description: ""
trigger:
- platform: state
entity_id:
- sensor.rangers
attribute: last_play
condition:
- condition: and
conditions:
- condition: template
value_template: "{{ 'homered' in trigger.to_state.attributes.last_play }}"
- condition: template
value_template: >-
{{ trigger.to_state.attributes.team_id ==
trigger.to_state.attributes.possession }}
enabled: true
action:
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
- service: notify.all_phones
data:
title: Run the bases!
message: >
{{ trigger.to_state.attributes.team_name }} got a {% if num_of_scores ==
1 %}homer {% elif num_of_scores == 4 %}grand slam {% else %} {{
num_of_scores | int }} run homer {% endif %}. {{ trigger.to_state.attributes.last_play }}
mode: queued
variables:
num_of_scores: >-
{{ ((((trigger.to_state.attributes.last_play | length) -
(trigger.to_state.attributes.last_play | replace("scored","") | length)) /
6) + 1) | int }}
The delay is so she can watch it before getting notified
You can certainly adjust the delay based on how you watch it. We are watching on MLBtv on ROKU. This works for us. Adjust as necessary.
The ‘Run the bases’ notification is a family joke. Ya gotta run around the living room!!!
- platform: teamtracker
league_id: XXX
team_id: CAY
sport_path: soccer
league_path: tur.1
name: caykur-rizespor
you can change team_id and name with your team.
but this only shows your team’s matches in the turkish league.
If your team plays in many leagues at the same time (eg Turkish league, champions league), I don’t know how it will be displayed on the same card.
I was able to get responses in logs that it was grabbing info but it showed No competitions, even thou when I send the same query in postman I get the match info.
2023-08-20 17:43:30.544 DEBUG (MainThread) [custom_components.teamtracker] team_newcarlos: Data returned for 'C. ALCARAZ' from http://site.api.espn.com/apis/site/v2/sports/tennis/atp/scoreboard?lang=en&limit=25
2023-08-20 17:43:30.545 DEBUG (MainThread) [custom_components.teamtracker] team_newcarlos: Num_events '2' from http://site.api.espn.com/apis/site/v2/sports/tennis/atp/scoreboard?lang=en&limit=25
2023-08-20 17:43:30.545 DEBUG (MainThread) [custom_components.teamtracker] team_newcarlos: Data returned for 'C. ALCARAZ' from http://site.api.espn.com/apis/site/v2/sports/tennis/atp/scoreboard?lang=en&limit=25
2023-08-20 17:43:30.545 DEBUG (MainThread) [custom_components.teamtracker] team_newcarlos: Num_events '2' from http://site.api.espn.com/apis/site/v2/sports/tennis/atp/scoreboard?lang=en&limit=25
2023-08-20 17:43:30.546 DEBUG (MainThread) [custom_components.teamtracker.event] team_newcarlos: async_process_event() No competitions for this event: Western & Southern Open
2023-08-20 17:43:30.546 DEBUG (MainThread) [custom_components.teamtracker.event] team_newcarlos: async_process_event() No competitions for this event: Winston-Salem Open
2023-08-20 17:43:30.546 DEBUG (MainThread) [custom_components.teamtracker.event] team_newcarlos: No competitor information 'C. ALCARAZ' returned by API
2023-08-20 17:43:30.550 DEBUG (MainThread) [custom_components.teamtracker] Finished fetching team_newcarlos data in 8.941 seconds (success: True)
"groupings": [
{
"grouping": {
"id": "1",
"slug": "mens-singles",
"displayName": "Mens Singles"
},
"competitions": [
{
"id": "136757",
"uid": "s:850~l:851~e:718-2023~c:136757",
"date": "2023-08-20T20:45Z",
"startDate": "2023-08-20T20:45Z",
"timeValid": true,
"recent": true,
"status": {
"period": 3,
"type": {
"id": "2",
"name": "STATUS_IN_PROGRESS",
"state": "in",
"completed": false,
"description": "In Progress",
"detail": "3rd Set",
"shortDetail": "3rd"
}
},
"venue": {
"fullName": "Cincinnati, USA",
"court": "Center Court"
},
"format": {
"regulation": {
"periods": 5
}
},
"notes": [
{
"text": "(1) Carlos Alcaraz (ESP) leads (2) Novak Djokovic (Srb) 7-5 6-7 (7-9) 5-5",
"type": "event"
}
],
"geoBroadcasts": [],
"broadcasts": [],
"competitors": [
{
"id": "3782",
"uid": "s:850~l:851~a:3782",
"type": "athlete",
"order": 1,
"homeAway": "home",
"possession": true,
"curatedRank": {
"current": 1
},
"linescores": [
{
"value": 7.0,
"winner": true
},
{
"value": 6.0,
"tiebreak": 7,
"winner": false
},
{
"value": 5.0
}
],
"athlete": {
"guid": "07843754-8bdf-63b0-5983-24252738169e",
"displayName": "Carlos Alcaraz",
"shortName": "C. Alcaraz",
"fullName": "Carlos Alcaraz",
"flag": {
"href": "https://a.espncdn.com/i/teamlogos/countries/500/esp.png",
"alt": "Spain",
"rel": [
"country-flag"
]
},
Is there an automation for when I watch the game on my direct tv. when my football team scores a touchdown, my light turn to my team’s color? Can that be automated? But only active when I’m home and I’m actually watching the game?
Here’s a new one for NFL folks that was fun to put together.
I created a template sensor that basically contains all teams in an NFL game in which either team has entered the red zone. The “state” is the count of games in the “Red Zone” (likely not needed but so be it).
The attribute “teams” contains the entity_id’s of all teams in the games in which are considered “Red Zone” … ball at 20 or closer to the opponents end zone:
- name: NFL Red Zone
unique_id: sensor.nfl_red_zone
state: |
{% set redzone = namespace(teams=[]) %}
{%- for team in integration_entities("teamtracker") -%}
{%- if state_attr(team, "league") == "NFL" -%}
{%- if states(team) == "IN" -%}
{%- if state_attr(team, "team_homeaway") == "home" -%}
{%- if state_attr(team,'possession') is not none -%}
{% set possession = state_attr(team,'possession') %}
{% set team_id = state_attr(team,'team_id') %}
{% set opponent_id = state_attr(team,'opponent_id') %}
{% set team_abbr = state_attr(team,'team_abbr') %}
{% set opponent_abbr = state_attr(team,'opponent_abbr') %}
{% set down_distance_text = state_attr(team,'down_distance_text') %}
{% set down_distance_endzone = state_attr(team,'down_distance_text').split(' ')[4] %}
{% set down_distance_yardline = state_attr(team,'down_distance_text').split(' ')[5] %}
{% set possession_abbr = opponent_abbr if opponent_id == possession else team_abbr %}
{% set non_possession_abbr = opponent_abbr if opponent_id != possession else team_abbr %}
{%- if (possession_abbr != down_distance_endzone) and (down_distance_yardline | int) <= 20 %}
{% set redzone.teams = redzone.teams + [team] %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{{ redzone.teams | count }}
attributes:
teams: |
{% set redzone = namespace(teams=[]) %}
{%- for team in integration_entities("teamtracker") -%}
{%- if state_attr(team, "league") == "NFL" -%}
{%- if states(team) == "IN" -%}
{%- if state_attr(team,'possession') is not none -%}
{% set possession = state_attr(team,'possession') %}
{% set team_id = state_attr(team,'team_id') %}
{% set opponent_id = state_attr(team,'opponent_id') %}
{% set team_abbr = state_attr(team,'team_abbr') %}
{% set opponent_abbr = state_attr(team,'opponent_abbr') %}
{% set down_distance_text = state_attr(team,'down_distance_text') %}
{% set down_distance_endzone = state_attr(team,'down_distance_text').split(' ')[4] %}
{% set down_distance_yardline = state_attr(team,'down_distance_text').split(' ')[5] %}
{% set possession_abbr = opponent_abbr if opponent_id == possession else team_abbr %}
{% set non_possession_abbr = opponent_abbr if opponent_id != possession else team_abbr %}
{%- if (possession_abbr != down_distance_endzone) and (down_distance_yardline | int) <= 20 %}
{% set redzone.teams = redzone.teams + [team] %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{{ redzone.teams }}
Then in my system I have a tab the displays all “IN” games (but only home teams as to not double the games). I use decluttering templates but you could yank out the code and do as you wish in yur own view. The key here is that is adds card-mod to set the card background-color and border to emphasize red zone. This is the decluttering template and if you need more information on using such a thing you can ask here or in the other thread … Sports Standings and Scores - #258 by kbrown01
game_stats:
card:
type: custom:auto-entities
unique: true
show_empty: false
card:
type: custom:layout-card
layout_type: masonry
card_param: cards
filter:
template: |
{%- for team in integration_entities("teamtracker") -%}
{%- if state_attr(team, "league") == "[[sport]]" -%}
{%- if states(team) == "[[status]]" -%}
{%- if state_attr(team, "team_homeaway") == "home" -%}
{%- if team in state_attr('sensor.nfl_red_zone','teams') -%}
{{{"type": "custom:teamtracker-card",
"entity": team,
"card_mod": {"style": "ha-card {\n background-color: #ffcccc; \n box-shadow: 0 0 10px 5px red;\n}\n"},
"home_side": "right"}}},
{%- else -%}
{{{"type": "custom:teamtracker-card",
"entity": team,
"home_side": "right"}}},
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
exclude:
- entity_id: '*team_tracker*'
sort:
method: attribute
attribute: date
What happens? As this is a masonry grid of cards, it draws all the games but if a team enters the Red Zone, it is “emphasized”. This is only a mockup testing the card-mod against existing cards as no games are on now. But I tested with titles and background-color on Monday night and it worked perfectly.
You will not be watching many games on DirecTV this year (except your local ones or NFL Network). All out of market are YouTubeTV now (yuck).
But you could easily take that automation I posted above, cut it back to only your teams and change the action from announcing something on Alexa to your specific light (adding the condition only of you are home).
And I can’t help you with the “watching the game part” … no one likely can. You would need to know broadcast/channel info at least and I would guess if you fell asleep or went to the bathroom!
Love it @kbrown01. Great job!
Once tested, I’ll follow with the template for those not watching all teams in case anyone wants/needs it.
Thank you, new to writing jinga and template script. I would just want it to turn my lights my team color when they score. I would just make the condition be when my TV is on the direct TV source. May I ask what would i change on your automation for my own? @kbrown01
This much more than you need and doesn’t have anything to do with scores.
You just need an automation. Do it in the front end. State trigger would be your team sensor with the attribute of Team score.
The action would be to call the service you need to change your lights, a pause of time, and the service call again to change them back to ‘normal’.
Might want to add a condition that the sensor state is IN so it does not change your light when it is resetting from POST to PRE for the next week.
If you don’t want it to happen on the point after, you can compare the from_state of the team_score to the to_state and make sure it is greater than 1.
This should be close. You will need to fill in your services for your light.
description: "Notify Team Score"
mode: single
trigger:
- platform: state
entity_id:
- sensor.dallas_cowboys
attribute: team_score
condition:
- condition: and
conditions:
- condition: template
value_template: "{{ trigger.to_state == 'IN' }}"
- condition: template
value_template: "{{ trigger.to_state.team_score - trigger.from_state.team_score > 1 }}"
action:
- service: ""
data: {}
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- service: ""
data: {}
selam emre teşekkür ederim.
will try your yaml. added with ui but dont think it is working.
I added via Uİ with the right paths and it works great.
but i cant see the CL league game.
tried it but it didnt work.
can you get the CL game info.
Thank you so much, this is what I have so far. I’m going to add the direct tv function as a condition once my device comes in the mail and setup. But once they score, the lights will turn on and turn off after 10 seconds. I also created a toggle switch to be on in order for any of this to work. Due to don’t want to annoy my wife if I’m not watching the game, lol.
description: Notify Team Score
trigger:
- platform: state
entity_id:
- sensor.dallas_cowboys
attribute: team_score
condition:
- condition: and
conditions:
- condition: template
value_template: "{{ trigger.to_state == 'IN' }}"
- condition: template
value_template: "{{ trigger.to_state.team_score - trigger.from_state.team_score > 1 }}"
action:
- service: scene.turn_on
data: {}
target:
entity_id: scene.cowboys_color
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- service: light.turn_off
data: {}
target:
entity_id: light.living_room_lights
mode: single
Add a state condition under conditions for your switch to be on.
@jeffcrum if i wanted to have my lights flash blue first and then gray (team colors). I would create a scene for both colors and just add a delay in the action part between them, right?
I don’t have any lights and have not messed with scenes. But, sounds right to me.
You will be able to test if your DirecTV is on but you will not be able to test if it is playing your game. Well maybe but only parsing name off of currently playing and not sure it would show like Lions @ Chiefs or just something like NFL Football. If you are after out of.market games live, which is the only way your lights will work which is live, then only YouTubeTV or a sublicense of them has games this year.
It is not clear to me what LG Cowboys is
LG cowboys is just a switch toggle i made so it will only work if i turn it on so it wont turn on if my wife is watching tv instead. To not upset her.
Another note for you. The team colors are inside the team tracker card as attributes. You could grab them from there if you wanted to be more generic and fixed to one team.
Example just from dev tools, of course you could use the sensor that triggered the automation:
If you implemented that way, you could use the same automation with multiple different teams and get the lights to trigger with their colors. I kinda like that and I may add but only for my favorite teams. Would be too much to run for the entire NFL.