Sports Standings and Scores

How about:

            else
              '<div>img src="//:0" style="height:20px;vertical-align:middle;">&nbsp;' + x.team.displayName + '</div>'

Not tested. Just googling.

Thoughts?

Possibly when you add the “<” before img. I tested.

It shows the “broken image” logo which is not square.

image

Because the ESPN logos are squares, this works (no logo, but correct spacing):

'<div><span style="display: inline-block;width: 20px;"></span>&nbsp;' + x.team.displayName + '</div>'

image

I love the correct spacing!!! Just saying.

And someone should flush that out if they like, The ESPN official view is this which contains many more columns:

GP (Games Played)
W (Wins)
D (Draws)
L (Losses)
F (Goals For)
A (Goals against)
GD (Goal Differential)
P (Points)

All those are easy to implement

Agree. Just throwing it out there for the masses.

Really great job. Thanks for your time on fixing this!

Here ya go, matches ESPN:

decluttering_templates:
  bpl_settings:
    card:
      type: custom:flex-table-card
      title: '[[title]]'
      css:
        table+: 'padding: 0px; width: 1600px;'
        tbody tr td:first-child: 'width: 5%;'
        tbody tr td:nth-child(2): 'width: 30%;'
        tbody tr td:nth-child(n+3): 'width: 5%;'
        tbody tr:hover: 'background-color: green!important; color:white!important;'
      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;
             }
      entities:
        include: '[[entity]]'
      sort_by: entries
      columns:
        - name: Rank
          data: entries
          modify: x.stats.find(y=>y.abbreviation == 'R').displayValue
        - name: Team
          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: GP
          data: entries
          modify: x.stats.find(y=>y.abbreviation == 'GP').displayValue
        - name: W
          data: entries
          modify: x.stats.find(y=>y.abbreviation == 'W').displayValue
        - name: D
          data: entries
          modify: x.stats.find(y=>y.abbreviation == 'D').displayValue
        - name: L
          data: entries
          modify: x.stats.find(y=>y.abbreviation == 'L').displayValue
        - name: G
          data: entries
          modify: x.stats.find(y=>y.abbreviation == 'F').displayValue
        - name: A
          data: entries
          modify: x.stats.find(y=>y.abbreviation == 'A').displayValue
        - name: GD
          data: entries
          modify: x.stats.find(y=>y.abbreviation == 'GD').displayValue
        - name: P
          data: entries
          modify: x.stats.find(y=>y.shortDisplayName == 'P').displayValue
views:
  - title: Belgian Pro League Standings
    icon: mdi:soccer
    type: panel
    badges: []
    cards:
      - type: custom:decluttering-card
        template: bpl_settings
        variables:
          - title: Belgian Pro League
          - entity: sensor.belgian_pro_league

1 Like

In case anyone wants to know, heres how I look at the data (using oXygen Editor which is my favorite tool for XML, JSON, YAML):

Took me while to figure out “RWDM” has no logos

You can turn on JSON viewer in Microsoft Edge.
View formatted JSON - Microsoft Edge Development | Microsoft Learn

This is what I use.

Sure. I have the luxury of owning a software company and have oXygen Editor installed. Much the same BUT I can test search and path expressions and doing much more than just seeing it. And seamless convert XML-JSON-YAML to eachother and see what is going on.

When I edit YAML dashboards, I copy the YAML to it and collapse/expand/easily move things. I have it on my laptop and the .homeassistant directory is mounted so I can edit and test live.

Just a total time saver.

Absolutely.

I have been a developer and analyzing data for 35 years. I can often catch that stuff.

But, cool tools are awesome :wink:

my dashboard remains empty, black.

is this normal?

Capture d’écran 2023-08-07 à 09.17.36

this is the sensor. empty ??

here is what i have with this code:

an empty page !

there is nothing in the json_attributes:
it’s normal ?

##
## Belgium Football
## 
- platform: rest
  scan_interval: 36000
  name: Belgian Pro League Standings
  unique_id: sensor.belgian_pro_league_standings
  resource: https://site.web.api.espn.com/apis/v2/sports/soccer/bel.1/standings
  value_template: "{{ now() }}"
  json_attributes:

If it works for you, I really don’t see where I made a mistake. everything was copy/pasted, so no errors in the sensors or templates.
I don’t understand.

thx this is working, awesome

ok i got there…
Is it normal that it takes a while for it to take data from the sensor?? this morning at 9 a.m. nothing, at 11 a.m. it works and without changing anything.
Is that normal??

on a normal card:

Capture d’écran 2023-08-07 à 11.07.41

on a dashboard:

it’s verry cool…
now i will try to do this for france, england, and spain.
I hope it will work the same way.

I really thank you very much for the helping hand and the hours spent to help me find the solution. really nice of you.
a big thank you to you. :pray:

1 Like

now that this one is done and working,
is it possible to have a page with the weekend results like this:

Thanks for your patience…

It is not normal but what can happen is you change the entity_id in the sensor but the name is the same it gets named with _2 at the end. These eventually go away or you have to delete the main one and rename the _2 one.

Through all the fiddling this probably is what happened as it did to me when I noticed I misspelled one.

1 Like

great.
and for the weekend results, it’s possible ??
Thanks.

I would think most all that information (albiet not in the same look) should be available in the TeamTracker integration. See GitHub - vasqued2/ha-teamtracker: Home Assistant integration that provides real-time scores in multiple professional (NBA, NFL, NHL, MLB, MLS, and more), college (NCAA), and international (soccer, golf, tennis, mma, racing) sports using ESPN APIs.

So … one would use the custom integration like this (showing just one team):

##
## Belgian Pro League
##
- platform: teamtracker
  league_id: "XXX"
  team_id: "AND"
  sport_path: "soccer"
  league_path: "bel.1"
  name: "Anderlecht"

SHowing:

image

Or you do some custom card yourself based on the returned data. This is all the attributes brought in by TeamTracker. The state is PRE, IN, POST, BYE which is self explanatory. POST stats usually display until ESPN updates with the next game.

attribution: Data provided by ESPN
sport: soccer
league: XXX
league_logo: https://a.espncdn.com/i/leaguelogos/soccer/500/6.png
team_abbr: AND
opponent_abbr: ANT
event_name: ANT @ AND
date: 2023-08-06T11:30Z
kickoff_in: a day ago
venue: Lotto Park
location: Brussels, Belgium
tv_network: null
odds: null
overunder: null
team_name: Anderlecht
team_id: '441'
team_record: 1-0-1
team_rank: null
team_homeaway: home
team_logo: https://a.espncdn.com/i/teamlogos/soccer/500/441.png
team_colors:
  - '#695196'
  - '#fafafc'
team_score: '1'
team_win_probability: null
team_winner: true
team_timeouts: null
opponent_name: Antwerp
opponent_id: '17544'
opponent_record: 1-0-1
opponent_rank: null
opponent_homeaway: away
opponent_logo: https://a.espncdn.com/i/teamlogos/soccer/500/17544.png
opponent_colors:
  - '#C60000'
  - '#ffffff'
opponent_score: '0'
opponent_win_probability: null
opponent_winner: false
opponent_timeouts: null
quarter: 2
clock: FT
possession: null
last_play: null
down_distance_text: null
outs: null
balls: null
strikes: null
on_first: null
on_second: null
on_third: null
team_shots_on_target: null
team_total_shots: null
opponent_shots_on_target: null
opponent_total_shots: null
team_sets_won: null
opponent_sets_won: null
last_update: '2023-08-07 10:45:01-07:00'
api_message: Cached data
icon: mdi:soccer
friendly_name: Anderlecht

yes, I thought about it, but, I take my case in Belgium, there are 22 teams. if I make 22 cards (1 for each team, I would have 11 duplicate cards each time because there are only 11 matches. so how to avoid that.

in the case of this weekend, I have the duplicate card.

i have:
Anderlecht - Antwerp
but also:
Antwerp - Anderlecht.