Real-Time Sports Scores w/ TeamTracker and TeamTracker-Card (Beta)

OK, let me finish this code and update and repost the Dashboard to use all names. It looks to me that some other index ‘6’ is off. Mine is in flux as I was also adding Playoff Seed this am and I noted the change.

Ok no problem. Tell me if I can try an other code

Will do. I just finished doing the code for NHL. It now uses this to select the fields in the table:

        - name: GP
          data: entries
          modify: x.stats.find(y=>y.abbreviation == 'GP').displayValue

So now, as long as ESPN does NOT change the abbreviations, they can do whatever they like with the positional layout of them. I have updated the dashboard YAML in GITHUB. Can you grab only that and replace your dashboard and test for me it would be great. I will continue on doing a similar update for NFL, MLB and NBA.

My NHL now:

ok I have try the now code for the dashboard and sill the same, only headlines.

OK, let me post a new thread and we’ll move issues over to that. We should not take away from @vasqued2 and his thread here that deals with Teamtracker. Give me a few hours and we can start to post there.

I have now posted a new “Share Your Projects” that deals with the STandings component.
I suggest moving discussions dealing with Standings to there.

@compoundbow83 and others, please use that to post questions on the Standings portion. I already know I have to modify the NFL, NBA and MLB stats to the new lookup method implemented for NHL.

Today the teamtracker-card stopped working. it worked fine until just a few minutes ago and the only thing I can see that changed is a Chrome update.

I get this now…

has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

anybody knows if this is a problem on my end or not? I´ve tried reinstalling the repository, but no change…

Other custom repositories work as expected, just not this one.
Team tracker also works, just not the card…

Pretty sure it’s unpkg, where the Lit/LitElement imports are pulled from, causing the issue. Every custom card I have that uses unpkg is currently broken. @vasqued2, would it be possible to include the imports and switch to a local import? Awesome card integration and card btw!

Sorry. I’m out of town this week and next and don’t have the access I need to make or test changes.

If anyone has a fix and wants to submit a pull request, please do so. Same if there is a link with more info on how others have fixed it in other cards. I might be able to pull it in to a beta release this weekend if it’s a simple fix.

It’s still working for me in the Apple app. Is there a specific front end that is causing the problem or is it just working for me because it’s cached?

Just did some digging and it appears unpkg did indeed have issues earlier that impacted some regions and they’ve been resolved now. Maybe that’s why I’m not seeing issues now?

I believe you are correct as I have full functionality back now as well. I’ll do some testing tomorrow with local imports in the interim.

all working as of today :smiley:

Could the “days until” value be modified to represent the actual number of days instead of the remaining time divided by 24 hours?

Currently, it displays “2 days” at 9 PM on Thursday, but it should say “3 days” until midnight and then switch to “2 days” afterward. Is it possible to make this change? Couldnt find anthing regarding this…

image

After some limited testing the following appears to work and allow for removing the dependency on unpkg:

const LitElement = customElements.get("hui-masonry-view")
  ? Object.getPrototypeOf(customElements.get("hui-masonry-view"))
  : Object.getPrototypeOf(customElements.get("hui-view"));
const html = LitElement.prototype.html;
//import { html, LitElement } from "https://unpkg.com/lit?module";

I found similar code chunks across quite a few of my custom lovelace cards. I don’t know the full extent of advantages/disadvantages of the above code(reliability, future-proofing, compatibility, etc.) but in my brief testing I’ve had no issues. Would love a clarification or more explanation from someone more versed in JS!

In the Standings blog, someone asked a question that I believe would be a good enhancement request for Teamtracker so I am posting here also.

See Sports Standings and Scores - #32 by kbrown01

Essentially there are some of us that want the entire team set for particular sports so that we can look at all things going on, but also would like a view that contains only our favorite teams. I think it would be great to add an additional attribute to a teamtracker team … “favorite”. This additional attribute would only carry the fact that a team is one of my favorites (defaults to “false” but could be “true”).

Then all-sports dashboards can be viewed as all teams or just “favorites”. Or better, a view of all my “favorities” independent of sport. Yes, I know I can just do this in some view by changing the YAML for the card to add that team, but auto-entities and templates would reduce that to a few lines of code and when I add a new team, mark it as a favorite in the sensor creation, it would just be there.

I use the humanize() function that is part of the arrow library (https://github.com/arrow-py/arrow) to calculate, translate, and localize the “days until”.

I would recommend opening an issue there.

1 Like

Unless I am missing something, it seems like you could get the same functionality by just using a standard naming convention and then using a template filter to only pull in the sensors you want.

For example, all my sensors are named something like tt_{league}_{team_abbr} or tt_test_{league}_{team_abbr} so I can filter out the test or prod sensors only. See my example below.

It seems like if you use a naming convention like tt_{league}_{team_abbr} and tt_{league}_fav_{team_abbr} you could pull in all of the sensors or only the fav depending on whether you included fav or not in the filter.

The reason I like driving it off of the sensor name is because it gives a lot more flexibility. For example, someone could filter based on conference or division if the wanted to. You couldn’t do that with a simple binary flag.

If I’m missing something, let me know.

  template: |
    {%- for team in integration_entities("teamtracker") -%}
        {%- if "sensor.tt_nba_" in team -%}
                {{{"type": "custom:teamtracker-card",
                   "show_league": true,
                   "debug": true,
                   "outline": true,
                   "outline_color": "lightgray",
                   "entity": team }}},
        {%- endif -%}
    {%- endfor -%}

You are not missing anything. You could use that as a naming convention and I think not break anything (I have done). But personally to me naming a team as you suggested is cheating. Maybe we are cheating too … because we want some team treated different that others. It was only pointed out in my blog and I thought I would present it here.

I think your people use teamtracker (which is top notch by the way) to follow their teams. My people use it by Sport and not by Team.

We can do what you want without even a naming convention, just a simple JSON file that contains your favorites. I will do that for folks then.

The difference you suggest is minimal.

Do I do?

- platform: teamtracker
  league_id: NFL
  team_id: DET
  name: Detroit Lions
  favorite: true

or

- platform: teamtracker
  league_id: NFL
  team_id: DET
  name: Detroit Lions Favorite

You control the integration, but from an experienced software person … one of these is the better answer.

You young’uns is so cute. The best solution is the one that provides the most flexibility w/ the least amount of coding changes. Actually, scratch that. The best solution is one that already works. Someday you’ll have enough experience to realize the wisdom of those words.

Let’s look at what would be needed for your proposal for a second.

Change the sensor setup. Change the UI config setup. Add an options flow handler for the flag. Update the localization files for the UI changes including languages I don’t speak. Force a config schema upgrade on the entire install base. Reestablish and regenerate a regression baseline. With most changes occurring in the portion of the code base w/ the least amount of test coverage.

Then about two weeks after release, someone would ask to add another boolean flag to tag the sensors that are their roomate’s favorites. Or to hide the scores for teams they want to watch later and not be spoiled. Or. Or. Or.

It’s almost as if an “experienced software person” were going to implement something like you requested if they would recognize the limitations of a boolean and implement it as a tag to give more flexibility.

But I’m not going to do that either.

Because name is essentially a sensor tag already. And the best solution is one that already works.

Sorry that this 61 yr old youngin that owns three software companies offended you for suggesting an enhancement.

We’ll handle it differently but simply.

Thanks for your invaluable advice.