Sports Standings and Scores

Ok, I will test it the next days

I tested and all seems OK. I never entered the “new” code you posted and yet I have this:

It did take a few reboots to get it to all sync up. I need to look at the sensor refresh rates and set them so we get a new key like every maybe 18 hours. The sensor that gets the goalie information would automatically refresh after the new key because it is in the sensor template.

My sensor.nhl_starting_goalies is unavaileble.

This Is my rest:

  - platform: rest
    name: nhl_starting_goalies
    unique_id: sensor.nhl_starting_goalies
    scan_interval: 3600
    resource_template: >
      https://www.dailyfaceoff.com/_next/data/{{states('sensor.starting_goalie_buildid')}}/starting-goalies.json
    value_template: "{{ value_json.pageProps.date }}"
    json_attributes_path: "$.pageProps"
    json_attributes:
      - data

and the sensor.starting_goalie_buildid have the following into: KN4hBpt_cfILOG1wLIrf_

This is ok.

Have you an idea?

I just noticed it also. It has to have something to do with timing and updates. Still trying to figure it out. Because if I go to:

https://www.dailyfaceoff.com/next/data/KN4hBpt_cfILOG1wLIrf/starting-goalies.json

I get the JSON as expected. Which should be exactly what is being done in the sensor.

ok no problem, then I wait :blush:

edit:
at the moment it works without any changes or reboots.

Yes. It seems it is a timing thing or something.

Why do not fonction in my card ??
I have a error:
Capture d’écran 2023-08-03 à 18.45.29

How to make this style of dashboard but for European football? I’m really interested!
For example the French or English league and especially the Belgian league.

Thank you for your help.

did you create the sensors?

  1. create rest sensor
sensor:
  - platform: rest
    scan_interval: 36000
    name: Belgium Pro League Ranking
    unique_id: Belgium Pro League Ranking
    resource: https://site.web.api.espn.com/apis/v2/sports/soccer/bel.1/standings
    value_template: "{{ now() }}"
    json_attributes:
        - children  
  1. create template
template:
  - sensor:
      - name: soccer_belgium_pro_league
        state: 'standing'
        attributes:
          standings: >-
            {{ state_attr('sensor.belgium_pro_league_ranking','children')[0].standings.entries }}
  1. Use it in Flex table Card
            type: custom:flex-table-card
            title: Standings
            css:
              table+: 'padding: 0px; width: 100%;'
            card_mod:
              style: |
                ha-card {
                    overflow: auto;
                }
                $: |
                    .card-header {
                      padding: 12px 0px 8px 4px!important;
                      font-size: 16px!important;
                      line-height: 18px!important;
                      font-weight: bold!important;
                    }
            sort_by: entries-
            entities:
              include: sensor.soccer_belgium_pro_league
            columns:
              - name: P.
                data: standings
                modify: |
                  x.stats[10].displayValue
              - name: Team
                data: standings
              - name: Team
                data: standings
                modify: x.team.displayName
              - name: G
                data: standings
                modify: |
                  x.stats[0].displayValue
              - name: DIFF
                data: standings
                modify: |
                  x.stats[2].displayValue   
              - name: Pts.
                data: standings
                modify: |
                  x.stats[3].displayValue 
1 Like

One note … I have been using the following now because sometimes ESPN changes the order so [10] may give you the wrong info, All my modify selectors are like this now:

x.stats.find(y=>y.abbreviation == 'RS').displayValue

This has two benefits, one as stated, the order can change at random times breaking things. The other is that you can see what you are doing because [10] doesn’t yield much info but the field whose abbreviation is “RS” does.

2 Likes

Perfect, it works. thanks to you.

And is it possible to create a dashboard with a table as above for the NHL but for Belgian football? I’m really interested in getting all the info. And the same for Formula 1 if possible.
Thanks again to you.

for sure, you can look into kbrown’s github project and merge this to soccer or you try maybe with this custom card to tabbed it like you want.

do you know why some soccer league’s the logos are never more working?

I have 2nd German Soccer League

  • team:
    id: ‘3070’
    uid: s:600~t:3070
    location: SpVgg Greuther Furth
    name: SpVgg Greuther Furth
    abbreviation: SGF
    displayName: SpVgg Greuther Furth
    shortDisplayName: Greuther Furth
    isActive: true
    logos:
    - href: https://a.espncdn.com/i/teamlogos/soccer/500/3070.png
    width: 500
    height: 500
    alt: ‘’
    rel:
    - full
    - default
    lastUpdated: 2019-05-08T16:07Z

but this is not working anymore

image

              - name: Team
                data: standings
                modify: "'<div><img src=\"' + x.team.logos[0].href + '\" style=\"height: 20px;vertical-align:middle;\">&nbsp;' + x.team.displayName + '</div>'"   

German Bundesliga

  • team:
    id: ‘11420’
    uid: s:600~t:11420
    location: RB Leipzig
    name: RB Leipzig
    abbreviation: RBL
    displayName: RB Leipzig
    shortDisplayName: RB Leipzig
    isActive: true
    logos:
    - href: https://a.espncdn.com/i/teamlogos/soccer/500/11420.png
    width: 500
    height: 500
    alt: ‘’
    rel:
    - full
    - default
    lastUpdated: 2019-05-08T16:07Z
              - name: Team
                data: standings
                modify: "'<div><img src=\"' + x.team.logos[0].href + '\" style=\"height: 20px;vertical-align:middle;\">&nbsp;' + x.team.displayName + '</div>'"   

this is working

image

maybe I am blind. Thx

Capture d’écran 2023-08-05 à 17.40.01

But I don’t have the logos.
What should be added?
what is “object” ??

apologies, i’m really a nobs in this stuff…

for me, this:

- name: Team
                data: standings
                modify: "'<div><img src=\"' + x.team.logos[0].href + '\" style=\"height: 20px;vertical-align:middle;\">&nbsp;' + x.team.displayName + '</div>'"

NOT function on the belgium foot.

To help you debug we need to know exactly what to look at.
It is possible the error “Cannot read properties of undefined (‘0’)” means that ESPN does not have a logo or is not returning it.

So show the exact URL you are using for the sensor meaning this one:

resource: https://site.web.api.espn.com/apis/v2/sports/soccer/bel.1/standings

Then tell us which team or teams are not working with logos. When I look at Belgium First Division A, I see this (snipped down to entries):

                "entries": [
                    {
                        "team": {
                            "id": "5807",
                            "uid": "s:600~t:5807",
                            "location": "Union St.-Gilloise",
                            "name": "Union St.-Gilloise",
                            "abbreviation": "USG",
                            "displayName": "Union St.-Gilloise",
                            "shortDisplayName": "Union SG",
                            "isActive": true,
                            "logos": [
                                {
                                    "href": "https://a.espncdn.com/i/teamlogos/soccer/500/5807.png",

x = entries so …

x.team.logos[0].href is certainly valid and should return ‘https://a.espncdn.com/i/teamlogos/soccer/500/5807.png

which is this:

image

I would note that the images you show are all black and look like others have posted to use markdown card. This solution is not the markdown card, this is using flex-table-card. DO not get confused and combine things.

For Belguim football, these should be the entries for the stats in long form:

                            {
                                "name": "gamesPlayed",
                                "displayName": "Games Played",
                                "shortDisplayName": "GP",
                                "description": "Games Played",
                                "abbreviation": "GP",
                                "type": "gamesplayed",
                                "value": 2.0,
                                "displayValue": "2"
                            },
                            {
                                "name": "losses",
                                "displayName": "Losses",
                                "shortDisplayName": "L",
                                "description": "Losses",
                                "abbreviation": "L",
                                "type": "losses",
                                "value": 0.0,
                                "displayValue": "0"
                            },
                            {
                                "name": "pointDifferential",
                                "displayName": "Goal Difference",
                                "shortDisplayName": "GD",
                                "description": "Goal Difference",
                                "abbreviation": "GD",
                                "type": "pointdifferential",
                                "value": 3.0,
                                "displayValue": "+3"
                            },
                            {
                                "name": "points",
                                "displayName": "Points",
                                "shortDisplayName": "P",
                                "description": "Points",
                                "abbreviation": "P",
                                "type": "points",
                                "value": 6.0,
                                "displayValue": "6"
                            },
                            {
                                "name": "pointsAgainst",
                                "displayName": "Goals Against",
                                "shortDisplayName": "A",
                                "description": "Goals Against",
                                "abbreviation": "A",
                                "type": "pointsagainst",
                                "value": 0.0,
                                "displayValue": "0"
                            },
                            {
                                "name": "pointsFor",
                                "displayName": "Goals For",
                                "shortDisplayName": "F",
                                "description": "Goals For",
                                "abbreviation": "F",
                                "type": "pointsfor",
                                "value": 3.0,
                                "displayValue": "3"
                            },
                            {
                                "name": "ties",
                                "displayName": "Draws",
                                "shortDisplayName": "D",
                                "description": "Draws",
                                "abbreviation": "D",
                                "type": "ties",
                                "value": 0.0,
                                "displayValue": "0"
                            },
                            {
                                "name": "wins",
                                "displayName": "Wins",
                                "shortDisplayName": "W",
                                "description": "Wins",
                                "abbreviation": "W",
                                "type": "wins",
                                "value": 2.0,
                                "displayValue": "2"
                            },
                            {
                                "name": "deductions",
                                "displayName": "Point Deductions",
                                "shortDisplayName": "Deductions",
                                "description": "Point Deductions",
                                "abbreviation": "PD",
                                "type": "deductions",
                                "value": 0.0,
                                "displayValue": ""
                            },
                            {
                                "name": "ppg",
                                "displayName": "Points Per Game",
                                "shortDisplayName": "PPG",
                                "description": "Points Per Game",
                                "abbreviation": "PPG",
                                "type": "ppg",
                                "value": 0.0,
                                "displayValue": "0"
                            },
                            {
                                "name": "rank",
                                "displayName": "Rank",
                                "shortDisplayName": "Rank",
                                "description": "Rank",
                                "abbreviation": "R",
                                "type": "rank",
                                "value": 1.0,
                                "displayValue": "1"
                            },
                            {
                                "name": "rankChange",
                                "displayName": "Rank Change",
                                "shortDisplayName": "Rank Change",
                                "description": "Rank Change",
                                "abbreviation": "RC",
                                "type": "rankchange",
                                "value": 0.0,
                                "displayValue": "0"
                            },
                            {
                                "id": "0",
                                "name": "overall",
                                "abbreviation": "Total",
                                "displayName": "Overall",
                                "shortDisplayName": "OVER",
                                "description": "Overall Record",
                                "type": "total",
                                "summary": "2-0-0",
                                "displayValue": "2-0-0"
                            }

What I mean is your column definitions would be like this for say “Games Played”:

x.stats.find(y=>y.abbreviation == 'GP').displayValue

here is what I have:

and here is the card I’m using:

type: custom:flex-table-card
title: Jupiler Pro League
css:
  table+: 'padding: 0px; width: 100%;'
card_mod:
  style: |
    ha-card {
        overflow: auto;
    }
    $: |
        .card-header {
          padding: 12px 0px 8px 4px!important;
          font-size: 16px!important;
          line-height: 18px!important;
          font-weight: bold!important;
        }
sort_by: entries-
entities:
  include: sensor.soccer_belgium_pro_league
columns:
  - name: P.
    data: standings
    modify: x.stats[10].displayValue
  - name: Team
    data: standings
  - name: Team
    data: standings
    modify: x.team.displayName
  - name: G
    data: standings
    modify: |
      x.stats[0].displayValue
  - name: DIFF
    data: standings
    modify: x.stats[2].displayValue
  - name: Pts.
    data: standings
    modify: x.stats[3].displayValue

if I put this in my map, here is the result:

entities:
  include: sensor.soccer_belgium_pro_league
columns:
  - name: P.
    data: standings
    modify: x.stats[10].displayValue
  - name: Team
    data: standings
    modify: >-
      '<div><img src="' + x.team.logos[0].href + '" style="height:
      20px;vertical-align:middle;">&nbsp;' + x.team.displayName + '</div>'
  - name: G
    data: standings
    modify: |
      x.stats[0].displayValue
  - name: DIFF
    data: standings
    modify: x.stats[2].displayValue
  - name: Pts.
    data: standings
    modify: x.stats[3].displayValue

Capture d’écran 2023-08-06 à 09.36.59

I have nothing at all !!

out, I wish I could have my card than this:
Capture d’écran 2023-08-06 à 09.39.59

It looks like you are going straight from the rest sensor instead of templating it down.

That is okay, but it means you need to add more levels of the JSON.

If I am reading it correctly, Try

x.children[0].standings.entries.team.logos[0].href

And where should I put this @jeffcrum ?