Real-Time Sports Scores w/ TeamTracker and TeamTracker-Card (Beta)

Thanks for the tip!

Is there a way to identify an MLB game as being a spring training game?

The ESPN API has a preseason indicator but it is not accessible from the sensor. What are you trying to use it for?

I have an automation set up to flash some lights every time the Philadelphia Phillies score changes (only if they are winning or the score is tied), but I was hoping to find a way to disable the automation for spring training games.

I should be able to add an attribute to indicate the season to the sensor which you can use. Will aim for a release this weekend. Wanted to confirm you didn’t want it displayed on the card because I’m not sure of the space and I’m not sure how consistently display-ready it is across all sports.

Is it possible to make Team tracker card border flash RED , every time home team score?
I have a template like this:

{{ state_attr('sensor.capitals_tracker', 'team_score') }} 

but have no idea how to used in card-mod of this card to implement that. Scroll entire topic, but couldn’t find any answer. Thank you

There is a template for NFL “Red Zone” that changes border to red.
It uses a separate sensor that updates during games to obtain the teams in the red zone.

See Real-Time Sports Scores w/ TeamTracker and TeamTracker-Card (Beta) - #428 by kbrown01

Something similar for hockey should be easy.

2 Likes

Firstly, I want to thank vasqued2 for his integration.

Additionally, although I know that many people have requested this, it would be great to be able to follow or track a league instead of a specific team.

To achieve this, it might be helpful to take a look at the code from MMM-MyScoreboard (GitHub - jclarke0000/MMM-MyScoreboard: Module for MagicMirror to display today's scores for your favourite teams across multiple sports.), which, although designed for MagicMirror, also uses ESPN for results.

This MagicMirror module shows the matches of the day for a league, with the home team listed first and live scores.

Thanks in advance

Take a look at the great work @kbrown01 has done. I think that is what you are looking for.

https://community.home-assistant.io/t/sports-standings-and-scores/547094

v0.14.7 adds a season attribute to the sensor that you should be able to use. It has inconsistent values depending on the sport but you should be able to test for the value preseason to do what you want for MLB. I have no idea what the value will be in the postseason.

Let me know if you have any problems with it.

I have managed to figure out how to make it work (in collaboration with Copilot).

Firstly I have created a rest sensor in configuration.yaml:

sensor:
  - platform: rest
    name: LaLiga Scoreboard
    resource: https://site.api.espn.com/apis/site/v2/sports/soccer/esp.1/scoreboard
    value_template: "{{ now() }}"
    json_attributes:
      - events

And then I have added a flex-table card in the dashboard:

type: custom:flex-table-card
entities:
  include: sensor.laliga_scoreboard
columns:
  - name: Time
    data: events
    modify: >
      let date = new Date(x.date); date.setHours(date.getHours() );
      date.toTimeString().split(' ')[0].substring(0, 5)
    align: center
  - name: Local Team Logo
    data: events
    modify: >-
      '<img src="' + x.competitions[0].competitors[0].team.logo + '"
      style="width: 30px; height: 30px;">'
    align: center
  - name: Local Team Score
    data: events
    modify: x.competitions[0].competitors[0].score
    align: center
  - name: Visitor Team Score
    data: events
    modify: x.competitions[0].competitors[1].score
    align: center
  - name: Visitor Team Logo
    data: events
    modify: >-
      '<img src="' + x.competitions[0].competitors[1].team.logo + '"
      style="width: 30px; height: 30px;">'
    align: center
  - name: Minute
    data: events
    modify: x.status.displayClock
    align: center
card_mod:
  style: |
    thead {
      display: none;
    }

And here is the final result:

Thank you for adding this!

I don’t think I have solved this yet because I don’t like multiple sensors but that is what ESPN is giving me right now. Here is a solution that gives you the games that have been played and the games that are coming up for Sunderland. They are team 366 with ESPN.

It requires 2 sensors for each team (we only need one for the NFL as an example) and maybe I will find a solution and will update this thread).

One is for Sunderland’s completed games:

- platform: rest
  scan_interval: 604800
  name: Soccer Schedule Games Completed Sunderland
  unique_id: sensor.soccer_schedule_sunderland
  resource: https://site.api.espn.com/apis/site/v2/sports/soccer/all/teams/366/schedule?seasontype=1&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes:
      - events

One is for future games


- platform: rest
  scan_interval: 604800
  name: Soccer Schedule Future Sunderland
  unique_id: sensor.soccer_schedule_future_sunderland
  resource: https://site.web.api.espn.com/apis/site/v2/sports/soccer/all/teams/366/schedule?fixture=true
  value_template: "{{ now() }}"
  json_attributes:
      - events  

When you put these into a flex-table you get the following:


If you need the decluttering templates I have updated my github site for the soccer sensors and dashboards. You can get it here - https://github.com/bburwell/HA-Sports-Scores

Sorry for the late reply just saw this.

1 Like

I created a sensor for each NBA team and then use this code to show all games for all ‘home’ teams. But I want to weed out completed games. I only want live or upcoming games. I can’t figure out how to write it tho. Any suggestions?

type: custom:auto-entities
unique: true
show_empty: false
card:
  type: entities
filter:
  template: |
    {%- for team in integration_entities("teamtracker") -%}
      {%- if state_attr(team, "team_homeaway") == "home" -%}
        {{{"type": "custom:teamtracker-card",
          "entity": team }}},
      {%- endif -%}
    {%- endfor -%}
  exclude:
    - entity_id: "*team_tracker*"
options: null
sort:
  method: attribute
  attribute: date

You will want to filter on status - something like this should work would need to test though:

type: custom:auto-entities
unique: true
show_empty: false
card:
  type: entities
filter:
  template: |
    {%- for team in integration_entities("teamtracker") -%}
      {%- if state_attr(team, "team_homeaway") == "home" and states(team) in ["IN", "PRE"] -%}
        {{{"type": "custom:teamtracker-card",
          "entity": team }}},
      {%- endif -%}
    {%- endfor -%}
  exclude:
    - entity_id: "*team_tracker*"
options: null
sort:
  method: attribute
  attribute: date

You can see how a lot of us use a deluttering card and then call the sport in either what Kevin started here ([Sports Standings and Scores])(Sports Standings and Scores) or out at my github above.

It would be good if the F1 attributes also included the times.