Football not soccer - Premier League Table

I put this together fairly quickly. It polls an API - https://api.football-data.org/ and then renders the table. I’m sure others will improve.

configuration.yaml

rest:
  - resource: https://api.football-data.org/v4/competitions/PL/standings
    headers:
      X-Auth-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxx
    method: GET
    scan_interval: 300
    timeout: 20
    sensor:
      - name: "PL Standings (FD)"
        value_template: "OK"
        json_attributes_path: "$.standings[0]"
        json_attributes:
          - table

markdown card

type: markdown
title: Premier League Table
content: |2-

    <pre style="font-family:'Courier New',monospace; font-size:13px; line-height:1.1; margin:0; white-space:pre; overflow:hidden;">
    Pos | Team                     | P  | Pts
    ----+---------------------------+----+----
    {% for row in state_attr('sensor.pl_standings_fd','table') or [] -%}
    {{ '{:>2}'.format(row.position) }} | {{ '{:<25}'.format(row.team.name[:22]) }} | {{ '{:>2}'.format(row.playedGames) }} | {{ '{:>3}'.format(row.points) }}
    {% endfor -%}
    </pre>

3 Likes

Thanks for sharing.
Works perfect. Needs a register to get the api key but quick and simple to do.

Handy card to keep a track of the teams.
Thanks. Nice work.

1 Like

Happy to see that Arsenal is still top of the table after this past weekend’s matches…

:slight_smile: It pained me to paste that image. Luckily we all know they’ll bottle it later on…:slight_smile:

1 Like

Thanks for sharing, I have had a go at doing this today but doesnt seem to be working that great with championship. everything is on one line… (apologies immediately as I am learning this stuff as a play with it)

Can you assist. Supplied images/code to help

Pos | Team                      | P  | W  | D  | L  | GD | Pts
----+---------------------------+----+----+----+----+----+----
{% for row in state_attr('sensor.championship_standings','table') or [] -%}
{{- '{:>3}'.format(row.position) }} | {{ '{:<25}'.format(row.team.name[:25]) }} | {{ '{:>2}'.format(row.playedGames) }} | {{ '{:>2}'.format(row.won) }} | {{ '{:>2}'.format(row.draw) }} | {{ '{:>2}'.format(row.lost) }} | {{ '{:>2}'.format(row.goalDifference) }} | {{ '{:>3}'.format(row.points) }}
{%- endfor -%}

Did you get the api token and replace the ‘xxxx’ ?

also did you replace the 25 teams with 24?