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