Sports Standings and Scores

Sorry about that. Mine all say “Coming soon!” and looking back at the github page for the project it doesn’t have anything for playoffs. I’m guessing it would be similar to the NHL, but columns and data points would be slightly different.

Yes, I never finished playofffs except for NHL and it is really wildcard.
Someone else at some time was trying to build something like a bracket but I moved on to other tasks.

Anyone have any suggestions on api locations for other racing series (Formula E, F2, F3, WRC, IRC, NASCAR (yes i know ESPN for this one), etc) like jolpica? I’ve been Google’ing furiously and have only found things that require installing a database (FastF1, etc). Trying to get at least basic info (calendar, standings) to start. Would eventually like to look to add live timing info or more (if possible). I’m new to REST sensors and yaml coding, so most of what I’m doing is copy/paste and adjusting…but im trying. If I can get some more series, I can work on a “standard” layout to allow, hopefully, @kbrown01 to merge into the full dashboard, so any and all assistance is greatly appreciated.

Honestly outside of @marcokreeft87 and his great work, I am not sure anyone has looked into racing - I haven’t seen it posted.

I think it will come down to you using 1 of 3 options:

  1. Use the ESPN API’s that are available for F1, IRL and NASCAR or any other open API site.
    Maybe try these for IRL:
    IRL (calendar/race stats) - https://site.api.espn.com/apis/site/v2/sports/racing/irl/scoreboard?seasontype=2&level=3
    IRL (standings) - https://site.web.api.espn.com/apis/v2/sports/racing/irl/standings?seasontype=2&type=0&level=3
    and keep hunting for the hidden racing endpoints.

  2. Scrape or find websites that have JSON data you can pull directly for each league.
    For example I looked at the https://www.fiaformula2.com/Standings/Driver site and saw that the code was laid out almost identical to @kbrown01 SOS Scraper and just reworked that - here is the code that I have in my multiscrape.yaml file:

- name: F2 schedule
  resource: https://www.fiaformula2.com/Standings/Driver
  scan_interval: 360000
  sensor:
    - unique_id: f2_schedule
      name: F2 schedule
      select: '#__NEXT_DATA__'
      value_template: '{{ now() }}'
      attributes:
        - name: f2_schedule
          select: '#__NEXT_DATA__'
          value_template: >
              {{ (value | from_json)['props']['pageProps'] }}

Now I have no idea if this will work in a month, but its a start. Here is what the top of the sensor data looks like:

  1. Last is write a python script or whatever you code with to pull data from more complex sites/or need different organizing - I had to do that for the NCAAF CFP before the final CFP standings were nailed down.

Good luck and look forward to what you create.

2 Likes

thanks brotha…appreciate you

Hi All,

I have read through the forum but still not seeing data coming in. I think there is something definitely wrong with my config. I am running HA-Core.

That being said let me get into it.

PreREQs:

  • I have installed all GUI needed
  • I have created fresh sensor file
  • I have updated my code on UI with latest dashboard code

I am still not able to see data currently:

My current config:

**I set up for in future if I want to add more sensors

Finally:
I am using this Dashboard YAML here => [SportStandingsScores/dashboard.yaml at 2fad100bfe50edaf8ed4bd82b461465c1215851b · kbrown01/SportStandingsScores · GitHub]


Kindly trying to find what I am missing, as I feel its something big.

Thanks for any help in advance.

Sorry I am new user, so I was not able to post a lot of photos, due to being new!

define

not seeing data coming in

Do you mean the sensor has no data?
Start slow, if you test a template in developer’s tools like this:

{{ state_attr('sensor.nfl_standings','children')}}

do you see something like this as result?

Hi,

Thank you for such a quick reply.

Whats happening is I still dont get any data coming into my dashboard for any sport league currently, after adding required sensors

That above command produces this below:

Thank you for taking time to help!

OK, so you have data.
Let’s go on deeper:

try this

{{ state_attr('sensor.nfl_afc_east', 'entries')}}

NOTE: the attribute is ‘entries’

That returns a null statement

It helps if you show us what you see. Also if you go into settings->Devices & entries->entities and type in nfl_afc_east what do you see? You should see this -

Sometimes when you are first setting it up Home Assistant creates a 2nd sensor. with an _2 by it. You will need to delete the proper sensor (null) and then rename the _2 sensor.

Again -showing us what you are seeing will help us help you.

Hey I updated my photo above, my apologies there and currently in entities it does not exist which is one of my problems.

Okay - so if You follow what @kbrown01 has you will need to make sure that your template.yaml file has the conferences. Make sure you grab his template.yaml from his github - at the top of this thread.

I moved the conferences from templates.yaml to my sensors because I ran into a limitation with Templates in college football. So I have moved away from templates.

So either use kevin’s template.yaml config or put the following in your sensor.yaml file.

I also put the leagues in their own yaml. So for NFL I have a nfl_sensors.yaml file in a sensors directory. You can see it in the thread above. Here is what I have for NFL in my nfl_sensors.yaml. You could problably put these in your senors.yaml but if you are going to follow a lot of sports it may become unruly.

##
## NFL Standings
##
- platform: rest
  scan_interval: 604800
  name: NFL Standings
  unique_id: sensor.nfl_standings
  resource: https://site.web.api.espn.com/apis/v2/sports/football/nfl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes:
      - children
      
- platform: rest
  scan_interval: 604800
  name: NFL AFC East
  unique_id: sensor.nfl_afc_east
  resource: https://site.web.api.espn.com/apis/v2/sports/football/nfl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes_path: "$.[0]['children'][0]['standings']"
  json_attributes: 
   - entries   

- platform: rest
  scan_interval: 604800
  name: NFL AFC North
  unique_id: sensor.nfl_afc_north
  resource: https://site.web.api.espn.com/apis/v2/sports/football/nfl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes_path: "$.[0]['children'][1]['standings']"
  json_attributes: 
   - entries 
   
- platform: rest
  scan_interval: 604800
  name: NFL AFC South
  unique_id: sensor.nfl_afc_south
  resource: https://site.web.api.espn.com/apis/v2/sports/football/nfl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes_path: "$.[0]['children'][2]['standings']"
  json_attributes: 
   - entries 
   
- platform: rest
  scan_interval: 604800
  name: NFL AFC West
  unique_id: sensor.nfl_afc_west
  resource: https://site.web.api.espn.com/apis/v2/sports/football/nfl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes_path: "$.[0]['children'][3]['standings']"
  json_attributes: 
   - entries 
   
- platform: rest
  scan_interval: 604800
  name: NFL NFC East
  unique_id: sensor.nfl_nfc_east
  resource: https://site.web.api.espn.com/apis/v2/sports/football/nfl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes_path: "$.[1]['children'][0]['standings']"
  json_attributes: 
   - entries 
   
- platform: rest
  scan_interval: 604800
  name: NFL NFC North
  unique_id: sensor.nfl_nfc_north
  resource: https://site.web.api.espn.com/apis/v2/sports/football/nfl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes_path: "$.[1]['children'][1]['standings']"
  json_attributes: 
   - entries 
   
- platform: rest
  scan_interval: 604800
  name: NFL NFC South
  unique_id: sensor.nfl_nfc_south
  resource: https://site.web.api.espn.com/apis/v2/sports/football/nfl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes_path: "$.[1]['children'][2]['standings']"
  json_attributes: 
   - entries 
   
- platform: rest
  scan_interval: 604800
  name: NFL NFC West
  unique_id: sensor.nfl_nfc_west
  resource: https://site.web.api.espn.com/apis/v2/sports/football/nfl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes_path: "$.[1]['children'][3]['standings']"
  json_attributes: 
   - entries  

You need an entry for each conference

Thank you so much. I started getting data now for NFL.

So i just tried for NHL following the same but getting null again:

##
## NHL Standings
##
- platform: rest
  scan_interval: 604800
  name: NHL Standings
  unique_id: sensor.nhl_standings
  resource: https://site.web.api.espn.com/apis/v2/sports/hockey/nhl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes:
    - children

###
### NHL Divisions
###
- platform: rest
  scan_interval: 604800
  name: NHL East Atlantic
  unique_id: sensor.nhl_east_atlantic
  resource: https://site.web.api.espn.com/apis/v2/sports/hockey/nhl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes:
    entries: "{{ state_attr('sensor.nhl_standings','children')[0]['children'][0]['standings']['entries'] }}"

- platform: rest
  scan_interval: 604800
  name: NHL East Metropolitan
  unique_id: sensor.nhl_east_metropolitan
  resource: https://site.web.api.espn.com/apis/v2/sports/hockey/nhl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes:
    entries: "{{ state_attr('sensor.nhl_standings','children')[0]['children'][1]['standings']['entries'] }}"

- platform: rest
  scan_interval: 604800
  name: NHL West Central
  unique_id: sensor.nhl_west_central
  resource: https://site.web.api.espn.com/apis/v2/sports/hockey/nhl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes:
    entries: "{{ state_attr('sensor.nhl_standings','children')[1]['children'][0]['standings']['entries'] }}"

- platform: rest
  scan_interval: 604800
  name: NHL West Pacific
  unique_id: sensor.nhl_west_pacific
  resource: https://site.web.api.espn.com/apis/v2/sports/hockey/nhl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes:
    json_entries: "{{ state_attr('sensor.nhl_standings','children')[1]['children'][1]['standings']['entries'] }}"
###
### NHL Wildcard
###
- platform: rest
  scan_interval: 604800
  name: NHL Wildcard Standings
  unique_id: sensor.nhl_wildcard_standings
  resource: https://site.web.api.espn.com/apis/v2/sports/hockey/nhl/standings?region=us&lang=en&contentorigin=espn&type=3&level=2&sort=playoffseed%3Aasc%2Cpoints%3Adesc%2Cgamesplayed%3Aasc%2Crotwins%3Adesc&seasontype=2
  value_template: "{{ now() }}"
  json_attributes:
    east_atlantic_top: "{{ state_attr('sensor.nhl_wildcard','overall')[0]['children'][0]['standings']['entries'] }}"
    east_metropolitan_top: "{{ state_attr('sensor.nhl_wildcard','overall')[0]['children'][1]['standings']['entries'] }}"
    east_wildcard: "{{ state_attr('sensor.nhl_wildcard','children')[0]['standings']['entries'][:2] }}"
    east_hunt: >
      {% set hteams = namespace(hteam=[]) %}
      {% for team in state_attr('sensor.nhl_wildcard','children')[0]['standings']['entries'][2:] %}
        {% for stat in team['stats'] | selectattr('name','eq','clincher') %}
        {% else %}
              {% set hteams.hteam = hteams.hteam + [team] %}
        {% endfor %}
      {% endfor %}
      {{ hteams.hteam }}
    east_eliminated: >
      {% set eteams = namespace(eteam=[]) %}
      {% for team in state_attr('sensor.nhl_wildcard','children')[0]['standings']['entries'][2:] %}
        {% for stat in team['stats'] %}
          {% if stat.name == 'clincher' %}
              {% set eteams.eteam = eteams.eteam + [team] %}
          {% endif %}
        {% endfor %}
      {% endfor %}
      {{ eteams.eteam }}
    west_central_top: "{{ state_attr('sensor.nhl_wildcard','overall')[1]['children'][0]['standings']['entries'] }}"
    west_pacific_top: "{{ state_attr('sensor.nhl_wildcard','overall')[1]['children'][1]['standings']['entries'] }}"
    west_wildcard: "{{ state_attr('sensor.nhl_wildcard','children')[1]['standings']['entries'][:2] }}"
    west_hunt: >
      {% set hteams = namespace(hteam=[]) %}
      {% for team in state_attr('sensor.nhl_wildcard','children')[1]['standings']['entries'][2:] %}
        {% for stat in team['stats'] | selectattr('name','eq','clincher') %}
        {% else %}
              {% set hteams.hteam = hteams.hteam + [team] %}
        {% endfor %}
      {% endfor %}
      {{ hteams.hteam }}
    west_eliminated: >
      {% set eteams = namespace(eteam=[]) %}
      {% for team in state_attr('sensor.nhl_wildcard','children')[1]['standings']['entries'][2:] %}
        {% for stat in team['stats'] %}
          {% if stat.name == 'clincher' %}
              {% set eteams.eteam = eteams.eteam + [team] %}
          {% endif %}
        {% endfor %}
      {% endfor %}
      {{ eteams.eteam }}
type or paste code here

In template editor if i search for any NHL Entity, it gives back a null/none statement. [Ran out of photos I could post]

The status for all my NHL Entities is down as well:

I figured out the above - my sensor code in NHL was incorrect and needed to be chagned properly for each entity in NHL Sensors for the below:

  json_attributes_path: "$.[0]['children'][0]['standings']"
  json_attributes:
    - entries

Thank you to this forum for your time and patience to help! @bburwell

I figured that since I post some of the snippets of the code that I have built off of kbrown’s excellent foundation over the past few months, that it might be useful to create a github site with my sensors/dashboard/code so those that may be looking to compare or might need it would be able to grab.

I have also added some notes on troubleshooting and will update when I can.

Here is link to my github site that may be of some use:
GitHub - bburwell/HA-Sports-Scores: HA Sports Scores, Standings, Sensors and Dashboards

@kbrown01 - please let me know if you want me to delete this post and create a new community thread. Completely understand if you want me to pull this post.

1 Like

keep going!
I’ll cycle back now and again, just finishing my TV remotes that now have DirecTV, Vizio and Samsung

Thanks @kbrown01

Here is what is currently posted on my github:

Here is link to my github site that may be of some use:
GitHub - bburwell/HA-Sports-Scores: HA Sports Scores, Standings, Sensors and Dashboards

Yaml and dashboard configuration for Sports Scores.

I orginally found Kbrowns code because I was trying to get a sports ticker setup and ran across the community site that he started. That is why you will see marquee text scrolling on some of the dashboards.

My goal was to have a single place to look at scores quickly thorugh HA. This is a work in progress and based on the excellent work Kbrown started and others have contributed to. I am just riding coat-tails, go to the thread below to see those who are working to make this project great - Sports Standings and Scores

I would also encourage reviewing the:

They are all a part of this project.

Setup vs Kbrowns

My setup has changed from Kbrowns in that he uses Templates (which work for most sports) where I moved most to REST sensors. The reason was that NCAA conferences sometimes exhausted the limits and wouldn’t return anything. In the sensors directory I have the sensors I populate and are broken out, where possible, by sport.

Dashboards directory has the following dashboard code:

  • US Sports (NHL/NFL/MLB/NBA/WNBA)
  • Soccer (Premier/Championship/English League 1/English League 2/ENL/Budesliga/Bundesliga2/MSL/NWSL)
  • US College NCAA (Mens Football/Mens Basketball)
  • Racing - F1/NASCAR

Sensors directory has the following sesnsor yaml’s broken up by sport:

  • US Sports
    • nhl_sensors.yaml
    • nfl_sensors.yaml
    • mlb_sensors.yaml
    • nba_sensors.yaml
    • wnba_sensors.yaml
  • Soccer
    • soccer_sensors.yaml includes all -Premier/Championship/English League 1/English League 2/ENL/Budesliga/Bundesliga2/MSL/NWSL
  • US College NCAA
    • ncaaf_sensors.yaml (Mens Football)
    • ncaam_sensors.yaml (Mens Basketball)
  • Racing
    • racing_sensors.yaml (F1/NASCAR)

Template.yaml

I also have template.yaml that is used for items that I haven’t converted yet or need to be in the template.yaml.

Configuration.yaml to split up individual sensors

I have added the configuration.yaml section that I use to call the sensors.

Sandbox

I create Sandbox dashboards to test what I am trying to create without messing up my existing dashboards. Because of that I have also included the sandbox code I use and you will see in the sensors/dashboards. Some of it is commented out, some isn’t used, and some are placeholders. I am including the code because I am lazy :wink: and figured some may want to explore some of the items I have done.

Troubleshooting

Lots of good info in the thread above on trouble-shooting and I may add more later.

What I will say is when you run into problems try to figure where some of the basics firsts.

  1. Make sure that the configuration yamls are correct and check your logs. HA needs everything pretty and will let you know in logs (most of the time) where it is having a problem.
  2. Double-check your configuration against my config, kbrown’s or others that may have contributed to the community thread above.
  3. Use the Home Assistant Developer tools (states and template) mostly to check your sensors and see if the data is in the sensor and use template to test code if it isn’t showing up in your dashboard.

Here is an example when I wanted to scroll the data that was included in the nhl_starting_goalies sensor and I wanted to see how it was formatted and if it was there so I tested in the Template first.

You can see that I am using that data with marquee wrapped around to scroll across the header

  1. If there isn’t data in the sensor but you know it is setup correctly, take a look at Settings->Devices & Services->Entities. You can see if there is an error or possibly a duplicate. There have been times that I made a change and HA created a 2nd, duplicate sensor and threw a _2 at the end of it. If this happens, delete the original and then go in and edit the entity and remove the _2. Here is what an error looks like as an example

  2. Be patient on the intial load - if may take a bit to populate the sensors the first time.

  3. Sometimes ESPN changes their formatting and you will most likely need to go in and change the decluttering template.

  4. Ask questions on the community but please use the formatting tools for your code, and show what isn’t working. A bunch of us can test quickly in our environment and possibly help.

  5. 99% of the people on the community want to help. Harsh words may be a language translation thing or if they are being mean the village normally rises up.

Pictures

Here are a couple pics of the dashboards that use the code in the dashboard and sensors directories. Feel free to pull anything out of it you don’t need or won’t use:




2 Likes

@bburwell thanks for your work. I stumbled across the org. GitHub repo yesterday and today I saw your updated one.
But I have some questions/issues on my setup.

I uploaded all yamls from the sensor folder to my sensor folder. Restarted HA and it seems that all sensors are working fine.
I am most interested in the NFL ones so I focus on NFL now.
I created a new Dashboard + edited the dashboard via the raw editor and pasted the content of Sports_US_Professional inside.
Reloaded the page and voila it looks like it works.

BUT there are some missing things
NFL - Standings - Overall → empty site
NFL - Standings - Schedules → only Denver Broncos which I can unfold, but empty again
NFL - Standings - NFL Playoffs → some errors related to templates missing
NFL - Live/Pre/Post… → Empty

See below screenshots



Maybe you can enlighten me how to fix them.
Thanks!