Sports Standings and Scores

Not here:

Perhaps because my sensor is gathering preseason … it is set to:

resource: https://site.web.api.espn.com/apis/v2/sports/hockey/nhl/standings?seasontype=1&type=0&level=3

seasontype = ‘1’ is preseason

This seem to be about getting a dashboard for the game scoreboard. Note that there are two “apps” or threads.

One deals with the Scoreboard and that is Teamtracker which is here:

This thread deals mostly with standings but uses Teamtracker for live/pre/post game information.

I think you are asking a Scoreboard question and you should probably post there.

I’m actually looking for all games of the week from FBS 1A - using the wildcard and the division short code yields only the game that’s happening soonest.

I may be over reaching here - but is that even possible?

As I said, your question deals with games and not standings. You are asking in the wrong group.

This group deals with standings, not pre-game, in-game and post-game stats.

Thanks for the reinforcement of your statement and your willingness to help!

I agree with @kbrown01 If you are looking for games for the next week and wanting them displayed in the TT card - I am not sure how to do that.

I will also say we are beholden to ESPN. You can see in Updated Top 25 card that I posted in this thread for the FBS poll doesn’t show up until Tuesday typically.

You can use some of the code I posted to show all FBS games that are available. I use them because I am working on building out conference cards that deal with standings and then display the games/card of that conference. Don’t pay attention to the conference variables I was testing to see if TT could filter, but it can’t yet, so I went with @kbrown01 suggestion.

Here is an example of the all games card I reference to make sure I have access to all conference games and I haven’t screwed up the code.

That is what the card is showing.

The code to get it is above - specifically this section which calls the decluttering game-stats and I put all of the games pre,post,live on a single tab. Again I am just using that card to make sure my conference cards are correct.

The reason I am showing so many games is that the way @kbrown01 brilliantly wrote the code was that it looks at the TT integration entities. So as long as you have them built then they are in the integration. So if you don’t have the sensors built you won’t see much, only what you created. You can see that took a bunch of what @ehcah put together and I just added conference_id’s and quotes (thanks again @ehcah

Not sure if this helps point you in a direction - but maybe do what kb is saying and reach out to the other group if not.

This is the section in the dashboard that calls the game-stats template.

- attributes:
                                label: Pre,Live,Post NCAAF Conference Games
                                icon: mdi:account-group
                              card:
                                type: horizontal-stack
                                cards:
                                  - type: vertical-stack
                                    cards:
                                      - type: markdown
                                        content: |
                                          <h1>NCAA Games Live</h1>
                                      - type: custom:decluttering-card
                                        template: game_stats
                                        variables:
                                          - sport: NCAAF
                                          - sport_path: football
                                          - league_path: college-football
                                          - conferenceid: 4
                                          - status: IN
                                          - conference: '4'
                                      - type: markdown
                                        content: |
                                          <h1>NCAA Games Coming-up</h1>
                                      - type: custom:decluttering-card
                                        template: game_stats
                                        variables:
                                          - sport: NCAAF
                                          - sport_path: football
                                          - league_path: college-football
                                          - conferenceid: 4
                                          - status: PRE
                                          - conference: '4'
                                      - type: markdown
                                        content: |
                                          <h1>NCAA Games Completed</h1>
                                      - type: custom:decluttering-card
                                        template: game_stats
                                        variables:
                                          - sport: NCAAF
                                          - sport_path: football
                                          - league_path: college-football
                                          - conferenceid: 4
                                          - status: POST
                                          - conference: '4'

KB - have you done this? I moved my sensors into a directory and added this to my configuration.yaml

sensor: !include_dir_merge_list sensors

Sensors work fine. I then moved on to Tempates

I cycled through all 4 modes for templates and no go - I’m lazy and don’t want to rewrite the template code but that is the one that is really cluttered.
I run HA in a docker container but that shouldn’t matter. My directory structure looks like this:
yaml

These are the 4 I cycled through:

Advanced usage

We offer four advanced options to include whole directories at once. Please note that your files must have the .yaml file extension; .yml is not supported.

This will allow you to !include files with .yml extensions from within the .yaml files; without those .yml files being imported by the following commands themselves.

  • !include_dir_list will return the content of a directory as a list with each file content being an entry in the list. The list entries are ordered based on the alphanumeric ordering of the names of the files.
  • !include_dir_named will return the content of a directory as a dictionary which maps filename => content of file.
  • !include_dir_merge_list will return the content of a directory as a list by merging all files (which should contain a list) into 1 big list.
  • !include_dir_merge_named will return the content of a directory as a dictionary by loading each file and merging it into 1 big dictionary.

no worries if you haven’t.

What is the error?

A “monolithic” templates.yaml would need a line at the top (sensor:) as shown below.

If you broke it into multiple files, it would need to be at the top of each file.

image

Thanks Ill look in to it.

Let me know if I should be pinging @Ildar_Gabdullin in the flex-table but since this kind of crosses figured I would post here first.

I’m still on my quest to build out individual Conference cards as I posted above. The item I am adding now are the team schedules for the rest of the season.

I’m doing this by creating a sensor for each team - which is kind of what the api requires. Here is an example:

- platform: teamtracker
  league_id: "NCAAF"
  team_id: "ASU"
  sport_path: football   
  league_path: "college-football"  
  conference_id: 4
  name: "Arizona State University"
- platform: rest
  scan_interval: 36000
  name: NCAAf Arizona State University Schedule
  unique_id: sensor.ncaaf_arizona_state_university_schedule
  resource: http://site.api.espn.com/apis/site/v2/sports/football/college-football/teams/ASU/schedule
  value_template: "{{ now() }}"
  json_attributes:
      - team
      - events 

The Api includes some of the data in the team section and some in the events section so I pulled both. (Maybe I should just dump the api into a sensor?) Which gets me to my first idea:

  1. I would like to loop through the sensors that make up the conference. Starting with Big 12. Is that possible?
  2. Each card that is created means I need to pull some data from events and some from team - can we passs multiple sensosrs to the Flex-table Card? Specifically I want the Title to be dynamic (which definitely is a Flex-Table question)
  3. For what ever reason I cannot drill down to
- name: Record
          data: '[[events]]'
          x.competitions[0].competitors[0].record[0].displayValue

It won’t return the card.
It looks correct though:

This is the beginning of the card:

This is my template:

ncaa_team_schedules:
    card:
      type: custom:flex-table-card
      title: '[[title]]'
      css:
        table+: 'padding: 0px; width: 1000px;'
        tbody tr td:first-child: 'width: 5%;'
        tbody tr td:nth-child(2): 'width: 5%;'
        tbody tr td:nth-child(3): 'width: 5%;'
        tbody tr td:nth-child(4): 'width: 5%;'
        tbody tr td:nth-child(n+5): 'width: .5%;'
        tbody tr:hover: 'background-color: black!important; color:white!important;'
        tbody tr td:nth-child(7): 'background-color: green; color: white;'
      card_mod:
        style:
          .: |
            ha-card {
              overflow: auto;
              }
          $: |
            .card-header {
               padding-top: 6px!important;
               padding-bottom: 4px!important;
               font-size: 14px!important;
               line-height: 14px!important;
               font-weight: bold!important;
             }
      sort_by: events+
      entities:
        include: '[[entity]]'
        exclude: '[[excluded_entities]]'
      columns:
        - name: Game Time
          data: '[[events]]'
          modify: x.date.split('T')[0]
        - name: Teams
          data: '[[events]]'
          modify: x.shortName
        - name: Home Team
          data: '[[events]]'
          modify: >-
            '<div><img src="' +
            x.competitions[0].competitors[0].team.logos[0].href + '"
            style="height: 20px;vertical-align:middle;">&nbsp;' +
            x.competitions[0].competitors[0].team.displayName + '</div>'
        - name: Away Team
          data: '[[events]]'
          modify: >-
            '<div><img src="' +
            x.competitions[0].competitors[1].team.logos[0].href + '"
            style="height: 20px;vertical-align:middle;">&nbsp;' +
            x.competitions[0].competitors[1].team.displayName + '</div>'

And this is how I am calling it - thanks again to all.

                                      - type: custom:decluttering-card
                                        template: ncaa_team_schedules
                                        variables:
                                          - title: NCAA Big 12 Schedules
                                          - entity: >-
                                              sensor.ncaaf_arizona_state_university_schedule
                                          - events: events
                                          - team: team

I was hoping to pass a group to the FT. replacing sensor.ncaaf_arizona_state_university_schedule with this (eventually flushed out with all teams in the conference)

Big_12_Conference_teams_schedule_group:
    name: "Big 12 Conference Teams Schedule"
    entities:
      - sensor.ncaaf_arizona_state_university_schedule
      - sensor.ncaaf_university_of_arizona_schedule

Hi I hope somebody can help me.

I have this sensor in my configuration.yaml for soccer German 2.Bundesliga


 - platform: rest
   name: team_tracker_bund2_tabelle
   scan_interval: 3600 # 1 Tag // 3600sek = 1 Stunde
   resource: https://site.web.api.espn.com/apis/v2/sports/soccer/ger.2/standings?type=0&level=0
   value_template: "{{ now() }}"
   json_attributes_path: "$['children'][0]['standings']"
   json_attributes:
     - entries
	  

and this to display the standings on the Dashboard

	  type: custom:flex-table-card
entities:
  include: sensor.team_tracker_bund2_tabelle
columns:
  - name: Rang
    data: entries
    modify: x.stats[10].value
  - name: Logo
    data: entries
    modify: '''<img src="'' + x.team.logos[0].href + ''"style="width: 30%">'''
  - name: Mannschaft
    data: entries
    modify: x.team.name
  - name: Sp
    data: entries
    modify: x.stats[0].value
  - name: D
    data: entries
    modify: x.stats[2].value
  - name: Pkt
    data: entries
    modify: x.stats[3].value
	

I want to modify the custom:flex-table-card to display the up and down prior to previous standing like this

but I have no idea to do that

If I understand correctly, you would like to add a new column with an up and down graphic illustrating rank change? If this is correct, you can modify ’ x. ’ to meet your needs. You can also change the minus, arrow-down or arrow-up to other mdi icons if you wish. I removed the NR (not ranked) response as I don’t beleive you’ll want it.

        - name: <div style="text-align:center;">TREND</div>
          data: '[[attribute]]'
          modify: >-
            if (typeof x !== 'undefined' && typeof x.current !== 'undefined' &&
            typeof x.previous !== 'undefined') {
              let content = '';
              let icon = '';
              let text = '';
              
              if (x.current === x.previous) {
                icon = '<ha-icon icon="mdi:minus" style="fill:white;"></ha-icon>';
              } else {
                let difference = x.current - x.previous;
                if (difference > 0) {
                  icon = '<ha-icon icon="mdi:arrow-down" style="color:red;"></ha-icon>';
                  text = '<div style="font-size:14px;color:red;">' + difference + '</div>';
                } else if (difference < 0) {
                  icon = '<ha-icon icon="mdi:arrow-up" style="color:green;"></ha-icon>';
                  text = '<div style="font-size:14px;color:green;">' + Math.abs(difference) + '</div>';
                }
              }
              
              content = '<div style="display:flex;align-items:center;justify-content:center;width:100%;height:100%;">' +
                        icon + 
                        (icon && text ? '<div style="margin-left:5px;">' + text + '</div>' : text) +
                        '</div>';
              content;
            } else {
              '';
            } ```

The challenge I see with your API is that it doesn’t have a previous rank value like we are using in the Top 25 Polls. Now it does have something called rankChange but it looks like every team is 0. Maybe nothing has happened over the past week. Maybe watch that one. I just can’t tell what rankchange does though.

If it doesn’t do anything to get what you want you would have to store the rank each week (like pushing the teams data into a db)

You can see that we are putting the previous rank in a column and then calculating on the current position to see if they are up/down. @ehcah and I use different methods but we are doing the same thing you can see here:

columns:
        - name: Rank
          data: '[[attribute]]'
          modify: x.current
        - name: Up-Down
          data: '[[attribute]]'
          modify: |-
            if (x.current == x.previous)
              '<ha-icon icon="mdi:minus" >'
            else if (x.current =="0")
              '<ha-icon icon="mdi:bomb" style="color:red;" >'
            else if (x.previous == "0")
              '<div><ha-icon icon="mdi:hand-clap" style="color:blue;"></ha-icon>&nbsp;' +  "New " + '</div>';
            else if (x.current > x.previous)
              '<div><ha-icon icon="mdi:arrow-down" style="color:red;"></ha-icon>&nbsp;' +  "Dn "+ (x.current - x.previous) + '</div>';
            else if (x.current < x.previous)
              '<div><ha-icon icon="mdi:arrow-up" style="color:green;"></ha-icon>&nbsp;' + "Up "+ (x.previous - x.current) + '</div>';

The API has the previous rank you can see here:
soccer

There is a rank section which you would sort on and then if rankChange shows the move up or down use that for arrows. There is updated code above that adds UP/DN, dropout-bomb and handclap for that column (snippet shown above, full code up in the thread)

I would recommend grabbing the rank and rankChange as columns and watch rankChange.

Ranks is here:
soccer3
rankChange is here:
soccer4

Anyone have an idea on why I can’t get the score from schedules?

Here is what I am testing:

I know that the scores are in score.displayValue or value as seen here:

I am testing it in the template editor with this code but if i put in .score.value or .score.[‘value’] I get an error that says
score2

but if I just use .score I get this - what am I doing wrong? I want to be able to have the home score and away score so i can calculate winner/loser.

{% set teams = state_attr('group.big_12_conference_teams_schedule_group', 'entity_id') %}
{% if teams %}
  {% for team in teams %}
    {% set events = state_attr(team, 'events') %}
    {% if events and events is not string %}
      {% for event in events %}
        Game Date: {{ event.date.split('T') }}
        Teams: {{ event.shortName }}
        Away Team: {{ '<div><img src="' + event.competitions[0].competitors[0].team.logos[0].href + '" style="height: 20px;vertical-align:middle;">&nbsp;' + event.competitions[0].competitors[0].team.displayName + '</div>' }}
        Home Score: {{ event.competitions[0].competitors[0].score }}
        Away Team: {{ '<div><img src="' + event.competitions[0].competitors[1].team.logos[0].href + '" style="height: 20px;vertical-align:middle;">&nbsp;' + event.competitions[0].competitors[1].team.displayName + '</div>' }}
        Attendence: {{ event.competitions[0].attendance }}
        Away Score: {{ event.competitions[0].competitors[1].score }}
  {% endfor %}
    {% else %}
      No events found for {{ team }}
    {% endif %}
  {% endfor %}
{% else %}
  No teams found
{% endif %}

@bburwell The API response is different when chosing a score value from schedule or scoreboard. What I can’t explain is why x.x.x.score offers a response when x.x.x.score.displayValue requires further definitiion as per below?

- name: CollegeFootballScoreboard
  data: '[[attribute]]'
  modify: x.competitions[0].competitors[0].score

vs.

- name: CollegeFootballTeamSchedule
  data: '[[attribute]]'
  modify: |-
    if (typeof x.competitions[0].competitors[0].score !== 'undefined') {
      x.competitions[0].competitors[0].score.displayValue;
    } else {
      '';
    } 

Hi there, I have not so much experince with HA but step by step I get this to work but there is one thing that i can’t figure out at the moment and I hope somebody can me explain hoe to solve this.

I get this Error in the Dashboard and I think there something missig but I have no idea.

See the declutterinig-card documentation to see how to install it.

At the bottom of this link GitHub - custom-cards/decluttering-card: :broom: Declutter your lovelace configuration with the help of this card

Thanks for that, you are my hero.

I thought i already installed that, but I didn’t. I’ve installed it and now it works!

1 Like

After a lot of try and error and many readings I have it running with the modifications to my needs. I’ve integrated the German ‘1.Bundesliga’ and ‘2.Bundesliga’.

Now my Question is : Is it possible to colorize the fields that i marked in the above picture?
The first 4 cells are qualified for CL the next 2 cells are for EL and the last cells are going down to second league.

My card :

decluttering_templates:
  nhl_settings:
    card:
      type: custom:flex-table-card
      entities:
        include: sensor.team_tracker_bund2_tabelle
      columns:
        - name: '#'
          data: entries
          modify: x.stats[10].value
        - name: Mannschaft
          data: entries
          modify: |-
            if (typeof x.team.logos !== 'undefined')
              '<div><img src="' + x.team.logos[0].href + '" style="height:20px;vertical-align:middle;">&nbsp;' + x.team.displayName + '</div>'
            else
              '<div><span style="display: inline-block;width: 20px;"></span>&nbsp;' + x.team.displayName + '</div>'
        - name: Sp
          data: entries
          modify: x.stats[0].value
        - name: S
          data: entries
          modify: x.stats[7].value
        - name: U
          data: entries
          modify: x.stats[6].value
        - name: 'N'
          data: entries
          modify: x.stats[1].value
        - name: Tore
          data: entries
          modify: |-
            {
              x.stats[5].value +
              " : " +
              x.stats[4].value
            }
        - name: D
          data: entries
          modify: |-
            {
              x.stats[5].value -
              x.stats[4].value
            }
        - name: Pkt
          data: entries
          modify: x.stats[3].value
      strict: true
      css:
        tbody td:nth-child(8)+: 'width: 40px;'
        tbody tr td:nth-child(9): 'background-color: green; color: white;'	  

any ideas?

Perfect thanks @ehcah