Sports Standings and Scores

@bburwell … that question is asked too many times. I would think we should do a test in code if red-zone sensor does not exist, do nothing.

I thought I had that in mine, but maybe I didn’t share.

Sorry - on travel this week just getting back.

I agree Red Zone seems to be the sticking point but that is typically/always has been that NFL wasn’t added to sensors - which makes sense. JC had NFL sensors added which seems that it would pass the test - assuming that because mine didn’t have the conditional test and it worked.

@jcnooo do you still have your test sandbox setup? If so I wonder if you could test this change and see if you still can see the cards.

The only change I made was this:

{%- if team in state_attr('sensor.nfl_red_zone','teams') -%}

is now this:

{%- if states('sensor.nfl_red_zone') is defined and team in state_attr('sensor.nfl_red_zone','teams') -%}

Here is the whole test dashboard code:

decluttering_templates:
  game_stats:
    card:
      type: custom:auto-entities
      unique: true
      show_empty: false
      card:
        type: custom:layout-card
        layout_type: masonry
        width: 200px
        max-columns: 5
      card_param: cards
      filter:
        template: |
          {%- for team in integration_entities("teamtracker") -%}
            {%- if state_attr(team, "league") == "[[sport]]" -%}
              {%- if states(team) == "[[status]]" -%}
                {%- if state_attr(team, "team_homeaway") == "home" -%}
                  {%- if states('sensor.nfl_red_zone') is defined and team in state_attr('sensor.nfl_red_zone','teams') -%}
                    {{{"type": "custom:teamtracker-card",
                      "entity": team,
                      "card_mod": {"style": "ha-card {\n\n    color:  black; \n    background-color:  #ffcccc; \n    box-shadow: 0 0 10px 5px red;\n}\n"},
                      "home_side": "right"}}},
                  {%- else -%}
                    {{{"type": "custom:teamtracker-card",
                      "entity": team, 
                      "home_side": "right"}}},
                  {%- endif -%}
                {%- endif -%}
              {%- endif -%}
            {%- endif -%}
          {%- endfor -%}
        exclude:
          - entity_id: '*team_tracker*'
      sort:
        method: attribute
        attribute: date
views:
  - title: Home
    cards:
      - type: custom:layout-card
        layout_type: custom:grid-layout
        layout:
          grid-template-columns: repeat(4, 1fr)
          grid-gap: 10px
        cards:
          - type: vertical-stack
            cards:
              - type: custom:teamtracker-card
                entity: sensor.chicago_blackhawks
                outline: true
                outline_color: deeppink
              - type: custom:teamtracker-card
                entity: sensor.kansas_city_chiefs
                outline: true
                outline_color: deeppink
          - type: vertical-stack
            cards:
              - type: markdown
                content: |
                  <h1>NHL Games Live</h1>
              - type: custom:decluttering-card
                template: game_stats
                variables:
                  - sport: NHL
                  - status: IN
          - type: vertical-stack
            cards:
              - type: markdown
                content: |
                  <h1>NHL Games Coming-up</h1>
              - type: custom:decluttering-card
                template: game_stats
                variables:
                  - sport: NHL
                  - status: PRE
          - type: vertical-stack
            cards:
              - type: markdown
                content: |
                  <h1>NHL Games Completed</h1>
              - type: custom:decluttering-card
                template: game_stats
                variables:
                  - sport: NHL
                  - status: POST
        column_span: 4
    header:
      layout: center
      badges_position: top
    type: custom:grid-layout

and this is what I am seeing with the new code right now:

Posted final March Madness Dashboard to my github- https://github.com/bburwell/HA-Sports-Scores/. Probably won’t change anything this year but hope for more of a true bracket layout next year.

Figured since I had the code already, just needed to adjust for Women’s, I would add it as well to my Github - Template and Dashboard updated code. Also Added Odds & O/U if available.

I also played around with NFL and MLB brackets. More on my Github but this is a quick view of both:

@bburwell Any plans to create a playoff view for the NBA/NHL playoffs?

I started but I haven’t finished yet.

I am keying off the notes section in the API to figure out rounds. In the other sports I don’t run into the dreaded ‘Template output exceeded maximum size of 262144 characters’ error but in NHL and NBA I am running into these. So first round isn’t there.

I am going to need to filter out first round data or find a way to filter on something else. This is the reason I moved to rest mostly because the NCAAF was running into this on almost every team. You don’t have this limitation with REST in Home Assistant.

For anyone who wants to help, I have updated the 6 individual sports sensors NCAAM/NCAAW/NFL/MLB/NHL/NBA, the Template.yaml and the sandbox dashboard NCAA Men’s & Women’s March Madness, NFL, MLB, NBA, NHL on my github.

The code is incredibly lazy and I need to clean it up, but hopefully it will help someone. All of the playoffs are in their own dashboard but I will eventually move them to where they should go.

You can see that I am not showing the first round with NHL and NBA and it is because of template error mentioned above. Everything else is there.

Also remember these are for last season. So I will need to update dates for this season on all teams.

Quick Edit:
Looks like NBA is starting to populate so I have updated both NBA and NHL Dates (see below). NHL should work but will check in a couple days.

NHL 2025: ?dates=20250419-20250623
NBA 2025: ?dates=20250415-20250622

Here are a couple screenshots:


Edit:
Here is what I am seeing for NBA right now (added play-in)

Edit 2:
Couldn’t figure out how to Fix NBA/NHL with filtering/templates, so created a couple python files to create json files and then pull them into REST sensors in HA. I put all of the changes up and tried to show how to use them in the readme. NHL isn’t populating yet so can’t check this years data yet but expect that in a couple days. I do have NBA First round showing up now and I have added broadcast station next to time. All of the code is up on github if anyone wants it.

Edit 3(4/17/2025):
Looks like NHL is getting populated and seems to be working. Remember you will need the Python Script for NHL. I have also added a new dashboard (I consolidated the decluttering into a single template and added WNBA to that dashboard. That is the primary one I will be working on moving forward but will also try to keep the other one updated as well.

This is what I am showing currently for NHL.

1 Like

Thats really looks great.

Can you maybe share the code and explain how to integrate it?

Take a look at my github. All of the code (Sensors/Templates/Dashboard) are up there and the readme covers most of it. Here is the link: GitHub - bburwell/HA-Sports-Scores: Home Assistant Sports Scores, Standings, Dashboards and Yaml's for Home Assistant