Sports Standings and Scores

OK. I setup the includes and just copied your template.yaml and sensor.yaml and all the standings sensors were created

Awesome. So sounds like you are semi-experienced. So you want this in it’s own dashboard? Possibly with the tabbed view like is shown or?

Ha! Yeah I sort of know what I’m doing lol. I understand how things work within HA. I just wasn’t sure how to implement everything. Yeah separate dashboard is fine with the tabbed view is great.

Well grab this (too long to post here)

You may need to do some editing at first to remove some things you do not have, the goal is to get you on NFL. You would only have NFL sensors now but that should not error the whole card (it might).

1 Like

Well I used your sensor and template files so every sport was created. Place the dashboard.yaml in same place as the sensor.yaml and template.yaml location? Do I need an include for it as well?

No. Create a new dashboard. In left bar …

Settings → Dashboards and create new dashboard

Name it whatever you like.

Then you edit the raw configuration for the whole page as shown below and paste in the dashboard code from the Git.

OK. Dashboard is now there with the tabs but none of the info is populated. Am I supposed to do anything with these files? I didn’t put them anywhere yet.

‘gen_teamtracker_sensors.xsl’
‘helper_templates.txt’
‘standings.json’
‘standings.xml’

No. YOu would only have NFL but it is possible that because you do not have NHL, MLB, NBA setup it errors.

It is also possible that you used different naming … how did you nae your teamtracker entities?

You of course would only have entries if you selected the NFL tab …

I copied your files so I have every sport setup including NBA but an example of an nfl one i see is sensor.buffalo_bills. Is that correct?

sensor.buffalo_bills would be a teamtracker one.
If you use the developer’s tools and look at the states, what do you get for:

sensor.nfl_standings
sensor.nfl_afc_west

Do these so data like this?

and this?

I only see the nfl standings sensor not the afc west one. The standings one does have the data

OK, you either need to reload “templates” or restart HA. If the full stats are there and not the divisions, you get nothing. Also, if you do not see the divisions one … be sure that the first line in template.yaml is:

sensor:

You may have copied it before I added it in the original post, I added it in an edit. Look above for the template.yaml and be sure that is the first line. After I edit such things I always run check configuration too, it does help to identify issues. If it isn;t there at all to see states, it is defined wrong in YAML, if it is there and no data … then that needs to be addressed to see why.

Boom! That was it. Standings are now populated for all sports. Goalies all say undefined for NHL though. Do the other tabs only get populated when there is data? for example the live tab is just blank for all. Thanks for the help!

The tabs Postgame, Live and Pregame are just organizing Teamtracker. The other tabs for standings are mine I wrote. So like NFL, NHL would have POST and PRE but nothing LIVE. In fact, no sport is playing right now so all LIVE would be empty.

NFL PRE should give this for the weeks games:

You would note that not even Monday’s game is populated yet. This is an ESPN thing, we can only serve up what ESPN gives.

If you want starting goalies, that is some new stuff. Create a scrape sensor to get their ever changing “cookie”: For this, I add in configuration.yaml:

scrape: !include scrape.yaml

Then add a scrape sensor to get the cookie. This is in scrape.yaml which is now another include like the other includes:

  - resource: https://www.dailyfaceoff.com/starting-goalies
    sensor:
      - name: Starting Goalie BuildID
        unique_id: sensor.starting_goalie_buildid
        select: '#__NEXT_DATA__'
        value_template: >
            {{ value | regex_findall('buildId":\s?"([a-zA-Z0-9_-]{1,99})"') | first }}

Then add this to sensor.yaml:

##
## Starting Goalies
##
- platform: rest
  name: nhl_starting_goalies
  unique_id: sensor.nhl_starting_goalies
  scan_interval: 3600
  resource_template: "https://www.dailyfaceoff.com/_next/data/{{states('sensor.starting_goalie_buildid')}}/starting-goalies.json"
  value_template: "{{ value_json.pageProps.date }}"
  json_attributes_path: "$.pageProps"
  json_attributes:
    - data

This should extract the data for today’s starting goalies (NOTE: It will be blank as there are no NHL games today).

For some reason the pregame tab isn’t working. It’s just blank. Any ideas?

For what league?

All of them….

OK, pre/post and (of course live)?
Then your naming is not the same as mine or done in a different way.
if you go to Developer’s Tools and template and put this in:

{% for team in integration_entities("teamtracker") %}
{{team }}
{%- endfor %}

this is what I get, what do you get?

That should show every single “teamtracker” entitiy

Yep. All sensors appear when using that string

OK, let’s go deeper. What do you get from this in the same way in developer’s tools:

{% for team in integration_entities("teamtracker") -%}
{% if state_attr(team, "league") == "NFL" -%}
{% if states(team) == "PRE" -%}
{% if state_attr(team, "team_homeaway") == "home" -%}
{{team}}
{% endif -%}
{% endif -%}
{% endif -%}
{% endfor -%}

Mine shows this: