Sports Standings and Scores

Yes, I use oXygen Editor and connect to my remote machine through mounted drives to edit YAML, JSON, XML, etc. But it ain’t free.

Double indent I have no idea, I just use oXygen to indent “for me”.

I never liked Studio Code

Yesterday during NHL downtime I added new input to the Strength of Schedule which shows Green Up-Arrow if the team has more PTs, Red Down-Arrow if team they are playing has more PTs. So in a traditional weekly Fantasy ranking you can not only see how many games your team is in, but the caliber of the teams they are playing.

Your error in looking at the output appears to be two things:

  1. the wrong type of quotes. It looks like your system is putting in left and right smart quotes and not just " or '. This is incorrect.

  2. You still have an extra endif

Using the template editor in developer tools is your friend.

{%- for team in integration_entities('teamtracker') -%} 
{%- if state_attr(team, 'league') == 'NHL' -%} 
{%- if states(team) == "PRE" -%} 
{%- if state_attr(team, 'team_homeaway') == 'home' -%} 
{{{"type": "custom:teamtracker-card", "entity": team, "home_side": "right"}}},
{%- endif -%} 
{%- endif -%} 
{%- endif -%} 
{%- endfor -%}

Yields:

NOTE: Do not just copy the above as I replaced the [[status]] with PRE because the template editor would not know what [[status]] is. But using the above template and putting back the [[status]] variable should solve your issue with the template error.

Even with my eye in this I can see three IFs and 4 ENDIFs. The quotes are harder to spot but that is why you write templates in the developer tools and then copy it to where you need it.

1 Like

I think the wrong quotes in this instance are either the forum software or browsers.

The below are the exact same pastes three different ways.

Just pasted in:
TemplateSyntaxError: Encountered unknown tag ‘endif’. Jinja was looking for the following tags: ‘endfor’ or ‘else’. The innermost block that needs to be closed is ‘for’.

Preformatted sinlge back tick:
TemplateSyntaxError: Encountered unknown tag 'endif'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.

Preformatted triple back tick:

TemplateSyntaxError: Encountered unknown tag 'endif'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.

This is why code and errors should be in the preformatted text tags so we can see what is really going on.

True, it probably is.
But none the less, he does have an extra endif in that (you can easily count them in the error message).

I think he took out the “Red Zone” IF but didn’t remove the ENDIF

1 Like

Happy Holidays to all the Sports Standing and Scores contributors and helpers.
I got my present yesterday with my Detroit Lions!

1 Like

Thank you @kbrown01 and @jeffcrum for the feedback. I used the source code form post #323 above to remove the “red zone” portion. The code within my dashboard only has 3 ENDIF’s. I did have an extra, a week ago, but removed it. I only have the one dashboard for sports tracking. Would there be a cached version somewhere that I am not seeing?

I updated my code as:

{%- for team in integration_entities('teamtracker') -%}
  {%- if state_attr(team, 'league') == "[[sport]]" -%}
  {%- if states(team) == "[[status]]" -%}
  {%- if state_attr(team, 'team_homeaway') == 'home' -%}
    {{{"type": "custom:teamtracker-card",
      "entity": team,
      "home_side": "right"}}},
  {%- endif -%}
  {%- endif -%}
  {%- endif -%}
{%- endfor -%}

In case the paste is being reformatted in my post. Here’s a screenshot of the Dev tool.

So, no error there. That is good.

The reason you get no results is the [[sport]] and [[status]] due to the template tester not knowing what they are.

I replaced them with NHL and PRE and get results.

You are saying that specific YAML is in your dashboard and gets an error?

If you look at your overall dashboard, where do you have that code?
Removing the Red Zone should only be in the game_stats decluttering template:

  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 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

If you do not have Red Zone, then it should be:

  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" -%}
              {{{"type": "custom:teamtracker-card",
                "entity": team, 
                "home_side": "right"}}},
            {%- endif -%}
            {%- endif -%}
            {%- endif -%}
          {%- endfor -%}
        exclude:
          - entity_id: '*team_tracker*'
      sort:
        method: attribute
        attribute: date

There would be no cached version if you have reloaded the page. Of course the call to the template needs the variables, so it should be like this:

                    - attributes:
                        label: Live
                        icon: mdi:hockey-puck
                      card:
                        type: custom:decluttering-card
                        template: game_stats
                        variables:
                          - sport: NHL
                          - status: IN

Which would limit those in that tab to IN games in NHL sport.
Best to test on NFL now as there are no games in NHL until Wednesday.

Mine right now NFL-> LIve (with Red Zone):

My game stats section is after the NHL Settings. This code has my modified ’ instead of " based on your comments above. In the revised code screenshot, each line is ". I will update, reload and restart again.

decluttering_templates:
  nhl_settings:
    card:
      type: custom:flex-table-card
      title: '[[title]]'
      css:
        table+: 'padding: 0px; width: 1600px;'
        tbody tr td:first-child: 'width: 2%;'
        tbody tr td:nth-child(2): 'width: 20%;'
        tbody tr td:nth-child(n+3): 'width: 5%;'
        tbody tr:hover: 'background-color: green!important; color:white!important;'
        tbody tr td:nth-child(7): 'background-color: green; color: white;'
      card_mod:
        style:
          .: |
            ha-card {
              overflow: auto;
              }
          $: |
            .card-header {
               padding-top: 6px!important;
               padding-bottom: 4px!important;
               font-size: 14px!important;
               line-height: 14px!important;
               font-weight: bold!important;
             }
      entities:
        include: '[[entity]]'
        exclude: '[[excluded_entities]]'
      sort_by: entries-
      columns:
        - hidden: true
          data: '[[attribute]]'
          modify: '[[sort]]'
        - name: <div>C</div>
          data: '[[attribute]]'
          modify: >-
            if(typeof x.stats.find(y=>y.abbreviation == 'CLINCH') !==
            'undefined' ){x.stats.find(y=>y.abbreviation ==
            'CLINCH').displayValue}else{'-'}
        - name: Team
          data: '[[attribute]]'
          modify: >-
            '<div><a href="' + x.team.links[0].href + '" target="_blank"><img
            src="' + x.team.logos[0].href + '" style="height:
            20px;vertical-align:middle;"></a>&nbsp;' + x.team.displayName +
            '</div>'
        - name: <div>GP</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'GP').displayValue
        - name: <div>W</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'W').displayValue
        - name: <div>L</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'L').displayValue
        - name: <div>OTL</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'OTL').displayValue
        - name: <div>PTS</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'PTS').displayValue
        - name: <div>RW</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'RW').displayValue
        - name: <div>ROW</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'ROW').displayValue
        - name: <div>SOW</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'SOW').displayValue
        - name: <div>SOL</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'SOL').displayValue
        - name: <div>HOME</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'HOME').displayValue
        - name: <div>AWAY</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'AWAY').displayValue
        - name: <div>GF</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'GF').displayValue
        - name: <div>GA</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'GA').displayValue
        - name: <div>DIFF</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'DIFF').displayValue
        - name: <div>L10</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'L10').summary
        - name: <div>STRK</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'STRK').displayValue
  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' -%}
              {{{"type": "custom:teamtracker-card",
                "entity": team,
                "home_side": "right"}}},
            {%- endif -%}
            {%- endif -%}
            {%- endif -%}
          {%- endfor -%}
        exclude:
          - entity_id: '*team_tracker*'
      sort:
        method: attribute
        attribute: date

I reordered some of my tabs, but the “Live” tab seems the same as yours.

- attributes:
                        label: Schedule
                        icon: mdi:calendar-blank
                      card:
                        type: custom:decluttering-card
                        template: sos_settings
                        variables:
                          - title: NHL Strength of Schedule
                          - entity: sensor.hockey_strength_of_schedule
                          - attribute: sos.dataRows
                    - attributes:
                        label: Pregame
                        icon: mdi:blood-bag
                      card:
                        type: custom:decluttering-card
                        template: game_stats
                        variables:
                          - sport: NHL
                          - status: PRE
                    - attributes:
                        label: Live
                        icon: mdi:hockey-puck
                      card:
                        type: custom:decluttering-card
                        template: game_stats
                        variables:
                          - sport: NHL
                          - status: IN
                    - attributes:
                        label: Postgame
                        icon: mdi:hockey-sticks
                      card:
                        type: custom:decluttering-card
                        template: game_stats
                        variables:
                          - sport: NHL
                          - status: POST

This is one of the errors I’m still receiving. It still shows 4 ENDIFS and my code has only had 3 for several reloads, restarts and reboots.

Logger: homeassistant.helpers.event
Source: helpers/template.py:515
First occurred: 4:31:00 PM (1 occurrences)
Last logged: 4:31:00 PM

Error while processing template: Template<template=({%- for team in integration_entities("teamtracker") -%} {%- if state_attr(team, "league") == "NHL" -%} {%- if states(team) == "[[status]]" -%} {%- if state_attr(team, "team_homeaway") == "home" -%} {{{"type": "custom:teamtracker-card", "entity": team, "home_side": "right"}}}, {%- endif -%} {%- endif -%} {%- endif -%} {%- endif -%} {%- endfor -%}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 513, in ensure_valid
    self._compiled_code = self._env.compile(self.template)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2663, in compile
    cached = self.template_cache[source] = super().compile(source)
                                           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 768, in compile
    self.handle_exception(source=source_hint)
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<unknown>", line 11, in template
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'endif'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 563, in async_render
    compiled = self._compiled or self._ensure_compiled(limited, strict, log_fn)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 766, in _ensure_compiled
    self.ensure_valid()
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 515, in ensure_valid
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TemplateSyntaxError: Encountered unknown tag 'endif'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.

Do you have another template in there that you changed in a similar manner? Might be looking in the wrong spot.

Also, the error has [[status]] in there. Do you have a place you are calling a template where the status variable is not filled in?

I would be confused that the error seems to be from helpers but not sure.
Again I ask, do you have anything in PRE, IN or POST games in the gui? Or do you have nothing.

Maybe you have it in a test setup in your system and another setup.

Can’t believe we’re discussing this on Christmas day. It’s a day for family, not idiots like me.

@jeffcrum I don’t have any other templates. I’ve reviewed template, sensor and multi-scrape to ensure I didn’t cross-paste by accident. Nothing out of sorts. WRT [[status]], I think it’s working?

@kbrown01 I don’t have the NFL configured right now. As of 2 days ago, when there were Live, Pre or Post, games, they were in their appropriate tabs.

I don’t have a test environment. I’m beginning to think hard about Oracle Box on my MacBook though. I’ve restarted all my YAML files, restarted HA and Rebooted the full system, several times. It can’t find those helper files to check them out. I can confirm they have never created one myself.

hahaha. Don’t sweat it. If I could not reply due to family, I would not. We do Christmas with the kids/grandkids Christmas Eve. Just the wife and I watching football.

I think it is time to just post the whole damn dashboard instead of snippets.

I don’t have a test system either. But, I do have test dashboards to paste it into and see what I can see. Although, I am thinking another VM for testing would be prudent. I do a lot of cleanup after helping someone :slight_smile:

Same here. One kid + grands coming later, other is spending today with his girlfriend’s family. Wife watching Netflix … me football and trying to figure out the Playoff for football!

Christmas is odd this year. East coast of Canada, no snow. Our kids are older too. Feels like a random monday. I appreciate the help!

Here is the full dashboard code. I have reordered a few things and changed a few colors, but when I go line by line with GitHub, I’m not seeing the errors. I have removed NFL, MLB, NBA and starting goalies. I wanted to understand how taxing these sensors would be before adding all the rest and then adding college football and soccer (not MLS).

decluttering_templates:
  nhl_settings:
    card:
      type: custom:flex-table-card
      title: '[[title]]'
      css:
        table+: 'padding: 0px; width: 1600px;'
        tbody tr td:first-child: 'width: 2%;'
        tbody tr td:nth-child(2): 'width: 20%;'
        tbody tr td:nth-child(n+3): 'width: 5%;'
        tbody tr:hover: 'background-color: green!important; color:white!important;'
        tbody tr td:nth-child(7): 'background-color: green; color: white;'
      card_mod:
        style:
          .: |
            ha-card {
              overflow: auto;
              }
          $: |
            .card-header {
               padding-top: 6px!important;
               padding-bottom: 4px!important;
               font-size: 14px!important;
               line-height: 14px!important;
               font-weight: bold!important;
             }
      entities:
        include: '[[entity]]'
        exclude: '[[excluded_entities]]'
      sort_by: entries-
      columns:
        - hidden: true
          data: '[[attribute]]'
          modify: '[[sort]]'
        - name: <div>C</div>
          data: '[[attribute]]'
          modify: >-
            if(typeof x.stats.find(y=>y.abbreviation == 'CLINCH') !==
            'undefined' ){x.stats.find(y=>y.abbreviation ==
            'CLINCH').displayValue}else{'-'}
        - name: Team
          data: '[[attribute]]'
          modify: >-
            '<div><a href="' + x.team.links[0].href + '" target="_blank"><img
            src="' + x.team.logos[0].href + '" style="height:
            20px;vertical-align:middle;"></a>&nbsp;' + x.team.displayName +
            '</div>'
        - name: <div>GP</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'GP').displayValue
        - name: <div>W</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'W').displayValue
        - name: <div>L</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'L').displayValue
        - name: <div>OTL</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'OTL').displayValue
        - name: <div>PTS</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'PTS').displayValue
        - name: <div>RW</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'RW').displayValue
        - name: <div>ROW</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'ROW').displayValue
        - name: <div>SOW</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'SOW').displayValue
        - name: <div>SOL</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'SOL').displayValue
        - name: <div>HOME</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'HOME').displayValue
        - name: <div>AWAY</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'AWAY').displayValue
        - name: <div>GF</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'GF').displayValue
        - name: <div>GA</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'GA').displayValue
        - name: <div>DIFF</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'DIFF').displayValue
        - name: <div>L10</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'L10').summary
        - name: <div>STRK</div>
          data: '[[attribute]]'
          modify: x.stats.find(y=>y.abbreviation == 'STRK').displayValue
  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" -%}
              {{{"type": "custom:teamtracker-card",
                "entity": team, 
                "home_side": "right"}}},
            {%- endif -%}
            {%- endif -%}
            {%- endif -%}
          {%- endfor -%}
        exclude:
          - entity_id: '*team_tracker*'
      sort:
        method: attribute
        attribute: date
  sos_settings:
    card:
      type: custom:flex-table-card
      title: '[[title]]'
      css:
        table+: 'padding: 0px; width: 2000px;'
        tbody tr td:first-child: 'width: 2px;'
        tbody tr:hover: 'background-color: green!important; color:white!important;'
      card_mod:
        style:
          .: |
            ha-card {
              overflow: auto;
              }
          $: |
            .card-header {
               padding-top: 6px!important;
               padding-bottom: 4px!important;
               font-size: 14px!important;
               line-height: 14px!important;
               font-weight: bold!important;
             }
      entities:
        include: '[[entity]]'
      sort_by: sos.dataRows-
      columns:
        - name: SOS
          data: '[[attribute]]'
          modify: |-
            if (x[8] > 3 ){
                '<div style="display:none;">'+ x[8] + '</div>' + '<div style="background-color:lightgreen;text-align:center">' + x[8] + '</div>'; }
            else if (x[8] < 3) {
                '<div style="display:none;">'+ x[8] + '</div>' + '<div style="background-color:lightcoral;text-align:center"">' + x[8] + '</div>'; }
            else {
                '<div style="display:none;">'+ x[8] + '</div>' + '<div style=";text-align:center">' + x[8] +'</div>'}
        - name: Team
          data: '[[attribute]]'
          modify: >-
            '<div><img src="' + x[0].team.logo + '"
            style="height:20px;vertical-align:middle;">&nbsp;' + x[0].team.name
            + ' (' + parseFloat(2*x[0].team.wins + x[0].team.overtimeLosses) +
            ')</div>'
        - name: Monday
          data: '[[attribute]]'
          modify: >-
            if(x[1]){'<div><img src="' + x[1].team.logo + '"
            style="height:20px;vertical-align:middle;">&nbsp;' + (x[1].home ? ''
            : '@ ') + x[1].team.name + ' (' + parseFloat(2*x[1].team.wins +
            x[1].team.overtimeLosses) + ')</div>'}else{'<div
            style="text-align:center">---</div>'}
        - name: Tuesday
          data: '[[attribute]]'
          modify: >-
            if(x[2]){'<div><img src="' + x[2].team.logo + '"
            style="height:20px;vertical-align:middle;">&nbsp;' + (x[2].home ? ''
            : '@ ') + x[2].team.name + ' (' + parseFloat(2*x[2].team.wins +
            x[2].team.overtimeLosses) + ')</div>'}else{'<div
            style="text-align:center">---</div>'}
        - name: Wednesday
          data: '[[attribute]]'
          modify: >-
            if(x[3]){'<div><img src="' + x[3].team.logo + '"
            style="height:20px;vertical-align:middle;">&nbsp;' + (x[3].home ? ''
            : '@ ') + x[3].team.name + ' (' + parseFloat(2*x[3].team.wins +
            x[3].team.overtimeLosses) + ')</div>'}else{'<div
            style="text-align:center">---</div>'}
        - name: Thursday
          data: '[[attribute]]'
          modify: >-
            if(x[4]){'<div><img src="' + x[4].team.logo + '"
            style="height:20px;vertical-align:middle;">&nbsp;' + (x[4].home ? ''
            : '@ ') + x[4].team.name + ' (' + parseFloat(2*x[4].team.wins +
            x[4].team.overtimeLosses) + ')</div>'}else{'<div
            style="text-align:center">---</div>'}
        - name: Friday
          data: '[[attribute]]'
          modify: >-
            if(x[5]){'<div><img src="' + x[5].team.logo + '"
            style="height:20px;vertical-align:middle;">&nbsp;' + (x[5].home ? ''
            : '@ ') + x[5].team.name + ' (' + parseFloat(2*x[5].team.wins +
            x[5].team.overtimeLosses) + ')</div>'}else{'<div
            style="text-align:center">---</div>'}
        - name: Saturday
          data: '[[attribute]]'
          modify: >-
            if(x[6]){'<div><img src="' + x[6].team.logo + '"
            style="height:20px;vertical-align:middle;">&nbsp;' + (x[6].home ? ''
            : '@ ') + x[6].team.name + ' (' + parseFloat(2*x[6].team.wins +
            x[6].team.overtimeLosses) + ')</div>'}else{'<div
            style="text-align:center">---</div>'}
        - name: Sunday
          data: '[[attribute]]'
          modify: >-
            if(x[7]){'<div><img src="' + x[7].team.logo + '"
            style="height:20px;vertical-align:middle;">&nbsp;' + (x[7].home ? ''
            : '@ ') + x[7].team.name + ' (' + parseFloat(2*x[7].team.wins +
            x[7].team.overtimeLosses) + ')</div>'}else{'<div
            style="text-align:center">---</div>'}
views:
  - theme: Backend-selected
    title: Sports
    type: panel
    icon: mdi:strategy
    badges: []
    cards:
      - type: custom:mod-card
        card_mod:
          style:
            tabbed-card $: |
              mwc-tab {
                background: var(--ha-card-background, var(--card-background-color, white) );
                border-color: black;
                border-width: 2px;
                border-top-left-radius: 20px;
                border-top-right-radius: 20px;
                border-style: solid;
                overflow: hidden;
                width: 25%;
              }
              mwc-tab[active] {
                background: #d3d3d3 !important;
              }
        card:
          type: custom:tabbed-card
          styles:
            '--mdc-theme-primary': silver
            '--mdc-tab-text-label-color-default': black
            '--mdc-typography-button-font-size': 12px
          tabs:
            - attributes:
                label: NHL
                icon: mdi:hockey-puck
              card:
                type: custom:mod-card
                card_mod:
                  style:
                    tabbed-card $: |
                      mwc-tab {
                        background: var(--ha-card-background, var(--card-background-color, white) );
                        border-color: black;
                        border-width: 2.5px;
                        border-top-left-radius: 20px;
                        border-top-right-radius: 20px;
                        border-style: solid;
                        overflow: hidden;
                        width: 20%;
                      }
                      mwc-tab[active] {
                        background: #d3d3d3 !important;
                      }
                card:
                  type: custom:tabbed-card
                  styles:
                    '--mdc-theme-primary': black
                    '--mdc-tab-text-label-color-default': silver
                    '--mdc-typography-button-font-size': 12px
                  tabs:
                    - attributes:
                        label: Standings
                        icon: mdi:ballot
                      card:
                        type: custom:mod-card
                        card_mod:
                          style:
                            tabbed-card $: |
                              mwc-tab {
                                background: var(--ha-card-background, var(--card-background-color, white) );
                                border-color: black;
                                border-width: 2.5px;
                                border-top-left-radius: 20px;
                                border-top-right-radius: 20px;
                                border-style: solid;
                                overflow: hidden;
                                width: 25%;
                              }
                              mwc-tab[active] {
                                background: #d3d3d3 !important;
                              }
                        card:
                          type: custom:tabbed-card
                          styles:
                            '--mdc-theme-primary': black
                            '--mdc-tab-text-label-color-default': silver
                            '--mdc-typography-button-font-size': 12px
                          tabs:
                            - attributes:
                                label: Divisional
                              card:
                                type: custom:stack-in-card
                                mode: vertical
                                cards:
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: Eastern Atlantic
                                      - entity: sensor.nhl_east_atlantic
                                      - attribute: entries
                                      - excluded_entities:
                                          - sensor.nhl_starting_s
                                          - sensor.nhl_wildcard
                                          - sensor.nhl_wildcard_standings
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: Eastern Metropolitan
                                      - entity: sensor.nhl_east_metropolitan
                                      - attribute: entries
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                          - sensor.nhl_wildcard
                                          - sensor.nhl_wildcard_standings
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: West Central
                                      - entity: sensor.nhl_west_central
                                      - attribute: entries
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                      - excluded_entities:
                                          - sensor.nhl_starting_s
                                          - sensor.nhl_wildcard
                                          - sensor.nhl_wildcard_standings
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: West Pacific
                                      - entity: sensor.nhl_west_pacific
                                      - attribute: entries
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                          - sensor.nhl_wildcard
                                          - sensor.nhl_wildcard_standings
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                      - excluded_entities:
                                          - sensor.nhl_starting_s
                                          - sensor.nhl_wildcard
                                          - sensor.nhl_wildcard_standings
                            - attributes:
                                label: Conference
                              card:
                                type: custom:stack-in-card
                                mode: vertical
                                cards:
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: Eastern
                                      - entity: sensor.nhl_east_*
                                      - attribute: entries
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                          - sensor.nhl_wildcard
                                          - sensor.nhl_wildcard_standings
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: Western
                                      - entity: sensor.nhl_west_*
                                      - attribute: entries
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                          - sensor.nhl_wildcard
                                          - sensor.nhl_wildcard_standings
                            - attributes:
                                label: Overall
                              card:
                                type: custom:decluttering-card
                                template: nhl_settings
                                variables:
                                  - title: Overall
                                  - entity: sensor.nhl_*_*
                                  - attribute: entries
                                  - excluded_entities:
                                      - sensor.nhl_starting_goalies
                                      - sensor.nhl_wildcard
                                      - sensor.nhl_wildcard_standings
                                  - sort: >-
                                      x.stats.find(y=>y.shortDisplayName ==
                                      'PTS').value
                            - attributes:
                                label: Wildcard
                              card:
                                type: custom:stack-in-card
                                mode: vertical
                                cards:
                                  - type: markdown
                                    content: |
                                      <h2>Eastern Conference</h2>
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: Atlantic Leaders
                                      - entity: sensor.nhl_wildcard_standings
                                      - attribute: east_atlantic_top
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: Metropolitan Leaders
                                      - entity: sensor.nhl_wildcard_standings
                                      - attribute: east_metropolitan_top
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: Wildcards
                                      - entity: sensor.nhl_wildcard_standings
                                      - attribute: east_wildcard
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: In The Hunt
                                      - entity: sensor.nhl_wildcard_standings
                                      - attribute: east_hunt
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: Eliminated
                                      - entity: sensor.nhl_wildcard_standings
                                      - attribute: east_eliminated
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                  - type: markdown
                                    content: |
                                      <h2>Western Conference</h2>
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: Central Leaders
                                      - entity: sensor.nhl_wildcard_standings
                                      - attribute: west_central_top
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: Pacific Leaders
                                      - entity: sensor.nhl_wildcard_standings
                                      - attribute: west_pacific_top
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: Wildcards
                                      - entity: sensor.nhl_wildcard_standings
                                      - attribute: west_wildcard
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: In The Hunt
                                      - entity: sensor.nhl_wildcard_standings
                                      - attribute: west_hunt
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                  - type: custom:decluttering-card
                                    template: nhl_settings
                                    variables:
                                      - title: Eliminated
                                      - entity: sensor.nhl_wildcard_standings
                                      - attribute: west_eliminated
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                    - attributes:
                        label: Schedule
                        icon: mdi:calendar-blank
                      card:
                        type: custom:decluttering-card
                        template: sos_settings
                        variables:
                          - title: NHL Strength of Schedule
                          - entity: sensor.hockey_strength_of_schedule
                          - attribute: sos.dataRows
                    - attributes:
                        label: Pregame
                        icon: mdi:blood-bag
                      card:
                        type: custom:decluttering-card
                        template: game_stats
                        variables:
                          - sport: NHL
                          - status: PRE
                    - attributes:
                        label: Live
                        icon: mdi:hockey-puck
                      card:
                        type: custom:decluttering-card
                        template: game_stats
                        variables:
                          - sport: NHL
                          - status: IN
                    - attributes:
                        label: Postgame
                        icon: mdi:hockey-sticks
                      card:
                        type: custom:decluttering-card
                        template: game_stats
                        variables:
                          - sport: NHL
                          - status: POST
title: Sports Standings and Scores

That looks wrong. Do you have a sensor named that?

Plus this is doubled up:

                                    variables:
                                      - title: West Pacific
                                      - entity: sensor.nhl_west_pacific
                                      - attribute: entries
                                      - excluded_entities:
                                          - sensor.nhl_starting_goalies
                                          - sensor.nhl_wildcard
                                          - sensor.nhl_wildcard_standings
                                      - sort: >-
                                          x.stats.find(y=>y.shortDisplayName ==
                                          'PTS').value
                                      - excluded_entities:
                                          - sensor.nhl_starting_s
                                          - sensor.nhl_wildcard
                                          - sensor.nhl_wildcard_standings

You have excluded entities twice in the same template. Which could be an issue, I would imagine it is an error for same key twice, but even not if second wins and that sensor does not exist, then you would have issues. That section should not have the second excluded_entities

1 Like
  • sensor.nhl_starting_s is a bit of a mystery. I’m going to guess it’s left over from adding and removing the starting goalies page. At one point, I was on sensor_2 and annoyed. I often used find and replace and must have messed up.

The double exclusion could have happened from removing the other leagues and moving that section around.