Sports Standings and Scores

where I must do this? And how?

Look at my first post and second block of code (Decluttering Templates):
https://community.home-assistant.io/t/sports-standings-and-scores/547094/438

The dashboard code has ā€œpo_level_titleā€ in the decluttering template.

Hello,
Iā€™m looking some solution for stuff like that: Eisbaren Berlin - Ice Hockey - BetsAPI
Or for example Sofascore has API connection too.

I tried by ESPN, but they not provide more leagues from EU unfortunately.

Could we set it with other API?

Best,
Rafal

Because I put my tables behind a collapsable element, I wanted a way of quickly reporting the top team in each conference/division - as an example:

{%- for x in state_attr('sensor.scoreboard_mlb_national_west', 'entries') -%}
{%- set rank = x['stats']|selectattr("name", "eq", "divisionGamesBehind")|map(attribute="value")|first -%}
{%- if rank == 0.0 -%}
{{x['team']['displayName']}}, {{x['stats']|selectattr("abbreviation", "eq", "PCT")|map(attribute="displayValue")|first}} PCT
{%- endif -%}
{%- endfor -%}

There is a limitation at the moment where if two teams share the same rank, it reports them a bit jank, but Iā€™ll fix that at some point

Hope this helps someone

1 Like

Hello,

Wondering if someone can help me with a couple of quick questions that google hasnā€™t solved.

  1. Is there an easy way to re-order the main sport tabs to reflect their season? I can easily copy and past them into the order I want. Iā€™m certain that will lead to a mess at some point. Iā€™ve also tried using ā€œhidden: trueā€ without success.

  2. Iā€™ve tried using CSS unsuccessfully to create an overall ranking number for ESPN pages that only offer a conference view. I can sort the teams, but can not figure out how to create my own ranking entry. Iā€™ve tried entries from various CSS tutorials without success.

The attached image shows the data I get from ESPN. Iā€™d like to create my own numbers based on sorting. I can hide their ā€œRankā€ data easy enough and adjust the column widths. But that means I end up with 2 templates for the same sport based on my abilities.

i cannont think of any except copy paste. But I would replicate that dashboard and edit it off line with a nice, YAML-based editor. Since I use oXygen editor ($s), it is quite easy to reorganize because you can collapse/expand things. You could see how easy it would be to move ā€œMLBā€ first which would be from attribute to the 144 collapsed lines in the card.

Here I just highlighted the lines for MLB and dragged them first:

image

For the second question what is the formula for that ranking? I assume it is no more then some mathematical application of other fields.

You could leave them in the same order (so you donā€™t make a mess :grin:) and just change defaultTabIndex as the seasons change.

I was thinking that also but I believe that is only the start Tab and not a real reordering. Not sure it would fit the desire.

Yup. That is exactly what it is. Just throwing other options out there.

Is there a way to add parameters to a rest sensor that automatically update as they refresh daily? ie. events that are 15 days old as well as 30 days in the future?

Iā€™m pulling from the ā€œscoreboardā€ extension of ESPN APIā€™s. My maximum download that will actually populate the corresponding table is set at 350 records. Iā€™ve tried the google and even AI with no success.

- platform: rest
  scan_interval: 86400
  name: MLS Soccer Schedule ESPN
  unique_id: sensor.mls_soccer_schedule_espn
  resource: https://site.api.espn.com/apis/site/v2/sports/soccer/usa.1/scoreboard?limit=350&dates=20240601-20240715
  value_template: "{{ now() }}"
  json_attributes:
    - events
    - competitions

I would rather use ā€˜limit=350&dates=2024ā€™ if itā€™s possible to sort it accordingly.

This is an MLS table. But once I get it figured out Iā€™ll use it for other sports and purposes.

Thank you in advance.

You can do it using Multiscrape:

Using your example, iā€™ve set the start date to be 7 days before today and the end date to be 3 days after:

- name: test_schedule_mscrape
  resource_template: "https://site.api.espn.com/apis/site/v2/sports/soccer/usa.1/scoreboard?limit=350&dates={{(now() - timedelta(days= 7)).strftime('%Y%m%d')|string}}-{{(now() + timedelta(days= 3)).strftime('%Y%m%d')|string}}"
  scan_interval: 21600
  log_response: true
  timeout: 60
  headers:
    User-Agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
  button:
    - unique_id: test_schedule_mscrape_refresh
      name: Refresh
  sensor:
    - unique_id: test_schedule_mscrape
      name: test_schedule_mscrape
      value_template: "{{now()}}"
      on_error:
        log: warning
        value: last
      attributes:
        - name: events
          value_template: "{{ value_json.events }}"
        - name: competitions
          value_template: "{{ value_json.competitions }}"
1 Like

Finding the schedule data has allowed me to tweak my setup, I can now have 7 days either side of today for either results or upcoming fixtures alongside my scoreboard

Using the updated rest sensor, I can get a maximum of 30 past dates and about 60 future. Way to much data for a tablet view, likely fine on a web browser.

Is your collapsable table formatted for mobile? It looks like it could be very useful on an iPhone. Especially if you prioritize the columns you want to display.

That is a too wide open question. I put my stats in a scrollable card using card mod. Is that what you are looking to do?

I havenā€™t optimised for mobile yet (ive only made it available via web browser at the moment) - Iā€™ll probably go with a scrollable table at this stage

NHL overall not working. When I click on Overall it just brings up a blank page.

Devisional, Comference, Wildcards works normally and displays the tables.

Code for the overall is:

type: custom:decluttering-card
template: nhl_settings
variables:
  - title: Overall
  - entity: sensor.nhl_*_*
  - attribute: entries
  - excluded_entities:
      - sensor.nhl_starting_goalies
      - sensor.nhl_wildcard
      - sensor.nhl_wildcard_standings
  - sort: x.stats.find(y=>y.shortDisplayName == 'PTS').value

I donĀ“t change enything on this code.

My overall for NHL loads fine. The code looks the same.

Check your logs to see if something else is happening.

There is only this in the logs:

State attributes for sensor.nhl_west_central exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
State attributes for sensor.nhl_wildcard_standings exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
State attributes for sensor.nhl_east_atlantic exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
State attributes for sensor.nhl_east_metropolitan exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
State attributes for sensor.nhl_west_pacific exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored

But this is only a warning und no problem I think

That is correct. You can add this to configuration.yaml to get rid of those.

recorder:
  exclude:
    entity_globs:
      - sensor.mlb_*
      - sensor.nfl_*
      - sensor.nhl_*
      - sensor.nba_*

I have no idea what the issue is though :frowning:

I added the one with recorder.

Ok, thanks anyway. Maybe someone else has an idea why my overalls are empty