NHL Standings using Flex-Table-Card and custom entity

Relatively new to Home Assistant and looking to create my own ‘standings’ dashboards. I know there’s already some out there, but I like learning how to do my own so that I can contribute to the community my own designs. Right now, I’m attempting to use flex-table-card to display NHL standings across all divisions, conference, and overall. The problem is… I can’t seem to figure out how to display the information, and I’m sure it’s something relatively silly.

The sensor itself is ‘sensor.nhl___division’ (so, sensor.nhl_east_atlantic_division, for example), and the modifications I made to pull the information into the sensor as a json table. The results from:

{{ state_attr('sensor.nhl_east_atlantic_division', 'standings' }}

returns

[
  {
    "place": 1,
    "team": "<img src='https://a.espncdn.com/i/teamlogos/nhl/500/fla.png' height='20' /> Florida Panthers",
    "games_played": 18,
    "wins": 12,
    "losses": 5,
    "otl": 1,
    "games_behind": "-",
    "points": 25
  },
  {
    "place": 2,
    "team": "<img src='https://a.espncdn.com/i/teamlogos/nhl/500/tor.png' height='20' /> Toronto Maple Leafs",
    "games_played": 19,
    "wins": 11,
    "losses": 6,
    "otl": 2,
    "games_behind": "1",
    "points": 24
  },
  {
    "place": 3,
    "team": "<img src='https://a.espncdn.com/i/teamlogos/nhl/500/tb.png' height='20' /> Tampa Bay Lightning",
    "games_played": 16,
    "wins": 9,
    "losses": 6,
    "otl": 1,
    "games_behind": "6",
    "points": 19
  },
  {
    "place": 4,
    "team": "<img src='https://a.espncdn.com/i/teamlogos/nhl/500/bos.png' height='20' /> Boston Bruins",
    "games_played": 19,
    "wins": 8,
    "losses": 8,
    "otl": 3,
    "games_behind": "6",
    "points": 19
  },
  {
    "place": 5,
    "team": "<img src='https://a.espncdn.com/i/teamlogos/nhl/500/ott.png' height='20' /> Ottawa Senators",
    "games_played": 17,
    "wins": 8,
    "losses": 8,
    "otl": 1,
    "games_behind": "8",
    "points": 17
  },
  {
    "place": 6,
    "team": "<img src='https://a.espncdn.com/i/teamlogos/nhl/500/buf.png' height='20' /> Buffalo Sabres",
    "games_played": 18,
    "wins": 8,
    "losses": 9,
    "otl": 1,
    "games_behind": "8",
    "points": 17
  },
  {
    "place": 7,
    "team": "<img src='https://a.espncdn.com/i/teamlogos/nhl/500/det.png' height='20' /> Detroit Red Wings",
    "games_played": 17,
    "wins": 7,
    "losses": 9,
    "otl": 1,
    "games_behind": "10",
    "points": 15
  },
  {
    "place": 8,
    "team": "<img src='https://a.espncdn.com/i/teamlogos/nhl/500/mtl.png' height='20' /> Montreal Canadiens",
    "games_played": 18,
    "wins": 6,
    "losses": 10,
    "otl": 2,
    "games_behind": "11",
    "points": 14
  }
]

Now, I have tried:

type: custom:flex-table-card
title: NHL Standings - East Atlantic Division
entities:
  include: sensor.nhl_east_atlantic_division
columns:
  - data: place
    name: Place
  - data: team
    name: Team
  - data: games_played
    name: GP
  - data: wins
    name: W
  - data: losses
    name: L
  - data: otl
    name: OTL
  - data: games_behind
    name: GB
  - data: points
    name: PTS

and other variants for data, such as data: standings.x.<field> or data: x.standings.<field> or data: <x|standings>.<field> all to no avail, leaving everything as undefined.

I’m out of options to what I should be using, and would appreciate any help.

Just found one ‘solution’, but it’s not a feasible one:

standings.0.<field>

will retrieve everything in the first nested table, so there’s that. Now I just need to figure out how to iterate through the table and display it in flex-table-card.

name: Place
data: standings
modify: x.place
....

Isn’t this related?

Yeah, I looked through flex-table-card and saw that, and… still returns undefined. It’s so weird. Maybe something isn’t structured properly? Could that be the issue? Considering that standings.0.place works, but not standings[0].place, which seems to indicate that the 0 is not numeric, but instead a string?

I wonder if that is the root of my issue, and if there is anything that can be done about it. For reference, this is a sample of the yaml file with the rest and templates:

rest:
  - resource: https://site.web.api.espn.com/apis/v2/sports/hockey/nhl/standings?seasontype=2&type=0&level=3
    scan_interval: 36000
    sensor:
      name: NHL Division Standings
      unique_id: nhl_division_standings
      value_template: "{{ now() }}"
      json_attributes:
        - children

template:
  - sensor:
      - name: NHL East Atlantic Division
        unique_id: sensor.nhl_east_atlantic_division
        state: "{{ now() }}"
        attributes:
          standings: >
            {% set entries = state_attr('sensor.nhl_division_standings', 'children')[0].children[0].standings.entries %}
            [
              {% for entry in entries %}
              {
                "place": {{ loop.index }},
                "team": "<img src='{{ entry.team.logos[0].href }}' height='20' /> {{ entry.team.displayName }}",
                "games_played": {{ entry.stats | selectattr('name', 'equalto', 'gamesPlayed') | map(attribute='value') | list | first }},
                "wins": {{ entry.stats | selectattr('name', 'equalto', 'wins') | map(attribute='value') | list | first }},
                "losses": {{ entry.stats | selectattr('name', 'equalto', 'losses') | map(attribute='value') | list | first }},
                "otl": {{ entry.stats | selectattr('name', 'equalto', 'otLosses') | map(attribute='value') | list | first }},
                "games_behind": "{{ entry.stats | selectattr('name', 'equalto', 'gamesBehind') | map(attribute='displayValue') | list | first }}",
                "points": {{ entry.stats | selectattr('name', 'equalto', 'points') | map(attribute='value') | list | first }}
              }
              {% if not loop.last %}, {% endif %}
              {% endfor %}
            ]

Maybe something in there is misconfigured?

It’s the same idea, but they have a full solution using the full API info whereas I’m creating a minimized version and having difficulty trying to understand why the flex-table-card is not processing it properly. And I suspect it may be a string vs number issue, though I may be way off base on it.

I based my feedback on the json output you sent, with me it works (for a totally different output but same structure)
Not sure if it is sensitive where the hyphen in pla`ced
I have

  - name:
    data:
    modify:

So very weird. I started modifying the dashboard config again, and attempted to use x.place and it suddenly popped up properly. But something was going strangely with HA, so I just rebooted the system rather than restarted HA. Since doing that, I am having zero issues now.

I’m baffled, but relieved. Thank you for verifying that it worked on your end!