Can the flex-table-card do a sortby?
This could be a left field solution - but what about using Markdown?
resource: https://site.web.api.espn.com/apis/v2/sports/hockey/nhl/standings?type=0&level=4
sensor:
name: scoreboard_nhl
value_template: "{{ now() }}"
json_attributes:
- children
scan_interval: 3600
type: custom:vertical-stack-in-card
cards:
- type: grid
square: false
columns: 1
cards:
- type: custom:mushroom-template-card
primary: NHL (All Teams)
icon: mdi:hockey-puck
icon_color: green
- type: markdown
content: >-
{% for conf in state_attr('sensor.scoreboard_nhl', 'children') %} {% for
division in conf.children %}
### {{conf.name}}, {{division.name }}
|Team|Logo|GP|W|L|PD|Pts|
|:--|:--:|:--:|:--:|:--:|:--:|:--:|
{%- for team in division.standings.entries %}
|{{team.team.displayName}}|<img
src="{{team.team.logos[1].href}}">|{{team.stats[3].value|int}}|{{team.stats[10].value|int}}|{{team.stats[4].value|int}}|{{team.stats[8].value|int}}:{{team.stats[7].value|int}}|{{team.stats[6].value|int}}|
{%- endfor %}
{% endfor %}
{% endfor %}
card_mod:
style:
ha-markdown: |
ha-card.type-markdown { box-shadow: none; }
.no-header {padding-top: 0px !important; }
ha-markdown$: >
table { width: 100%; padding: 16px; border-collapse: collapse;
padding: 0px; }
thead th { height: 1em; }
tr td { padding-left: 0.5em; padding-right: 0.5em; }
th { padding-left: 0.5em; padding-right: 0.5em; }
tbody tr:nth-child(odd) { background-color:
var(--table-row-background-color); }
tbody tr:nth-child(even) { background-color:
var(--table-row-alternative-background-color); }
tbody tr td:nth-child(2) { width: 10%; }
th ha-icon { height: 1em; vertical-align: top; }
EDIT - this code can help you find the right column number
{% set ns = namespace(count = 0) %}
{% for x in states.sensor.scoreboard_nhl.attributes.children[0].children[0].standings.entries[0].stats %}
{{ ns.count }} {{x.name}} {{x.displayValue}}
{%- set ns.count = ns.count+1 %}
{%- endfor %}
No problem - perhaps someone else may benefit from the alternate approach
But of course! In fact if you look at the above I did say that Markdown can do it.
The issue though is that markdown was complex at best and would require a lot of card-mod/css styling to make it look decent, you have done a great job above for sure.
You approach could have another significant benefit that should be pointed out. Having all the data in one sensor by conference and division would allow you to have three markdown cards. One as you have done by division, one by conference and one overall with every team … all sorted by points and even a wild-card one by conference plus divisional leaders.
I was only hoping that all of that could be done with flex-table but alas, it does not seem that “flexy”.
As a side note I have that almost exact same “stat name finder” in my Developer tools. I did exactly that to figure out what all the stat names were and their index to plug in.
I thought I would post this here for everyone to use/comment/change as you please.
I created a Dashboard Side Panel that uses decluttering and tabbed cards for all NHL, MLB, NFL standings and PRE, IN and POST stat views (sorry NBA fans!)
It uses three main REST sensors to get the overall stats and then template sensors for each conference. Of course it uses teamtracker for individual teams for each of the sports, not posted here.
Some examples:
NHL Standings by Division:
NHL Standings Overall:
NHL Pregame:
The sensors are defines in my included sensor.yaml as follows. Note that I also set seasontype in the query to “2” to get the regular season. This is not built for pre-season although it could be easily done if you wanted pre-season stats.
###
### Divisional Stats
###
- platform: rest
scan_interval: 36000
name: NHL Standings
unique_id: sensor.nhl_standings
resource: https://site.web.api.espn.com/apis/v2/sports/hockey/nhl/standings?seasontype=2&type=0&level=3
value_template: "{{ now() }}"
json_attributes:
- children
- platform: rest
scan_interval: 36000
name: MLB Standings
unique_id: sensor.mlb_standings
resource: https://site.web.api.espn.com/apis/v2/sports/baseball/mlb/standings?seasontype=2&type=0&level=3
value_template: "{{ now() }}"
json_attributes:
- children
- platform: rest
scan_interval: 36000
name: NFL Standings
unique_id: sensor.nfl_standings
resource: https://site.web.api.espn.com/apis/v2/sports/football/nfl/standings?seasontype=2&type=0&level=3
value_template: "{{ now() }}"
json_attributes:
- children
The template sensors are defined in my included template.yaml as:
###
### MLB Divisions
###
- name: MLB American East
unique_id: sensor.mlb_american_east
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.mlb_standings','children')[0]['children'][0]['standings']['entries'] }}"
- name: MLB American Central
unique_id: sensor.mlb_american_central
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.mlb_standings','children')[0]['children'][1]['standings']['entries'] }}"
- name: MLB American West
unique_id: sensor.mlb_american_west
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.mlb_standings','children')[0]['children'][2]['standings']['entries'] }}"
- name: MLB National East
unique_id: sensor.mlb_national_east
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.mlb_standings','children')[1]['children'][0]['standings']['entries'] }}"
- name: MLB National Central
unique_id: sensor.mlb_national_central
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.mlb_standings','children')[1]['children'][1]['standings']['entries'] }}"
- name: MLB National West
unique_id: sensor.mlb_national_west
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.mlb_standings','children')[1]['children'][2]['standings']['entries'] }}"
###
### NHL Divisions
###
- name: NHL East Atlantic
unique_id: sensor.nhl_east_atlantic
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nhl_standings','children')[0]['children'][0]['standings']['entries'] }}"
- name: NHL East Metropolitan
unique_id: sensor.nhl_east_metropolitan
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nhl_standings','children')[0]['children'][1]['standings']['entries'] }}"
- name: NHL West Central
unique_id: sensor.nhl_west_central
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nhl_standings','children')[1]['children'][0]['standings']['entries'] }}"
- name: NHL West Pacific
unique_id: sensor.nhl_west_pacific
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nhl_standings','children')[1]['children'][1]['standings']['entries'] }}"
###
### NFL Divisions
###
- name: NFL AFC East
unique_id: sensor.nfl_afc_east
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nfl_standings','children')[0]['children'][0]['standings']['entries'] }}"
- name: NFL AFC North
unique_id: sensor.nfl_afc_north
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nfl_standings','children')[0]['children'][1]['standings']['entries'] }}"
- name: NFL AFC South
unique_id: sensor.nfl_afc_south
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nfl_standings','children')[0]['children'][2]['standings']['entries'] }}"
- name: NFL AFC West
unique_id: sensor.nfl_afc_west
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nfl_standings','children')[0]['children'][3]['standings']['entries'] }}"
- name: NFL NFC East
unique_id: sensor.nfl_nfc_east
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nfl_standings','children')[1]['children'][0]['standings']['entries'] }}"
- name: NFL NFC North
unique_id: sensor.nfl_nfc_north
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nfl_standings','children')[1]['children'][1]['standings']['entries'] }}"
- name: NFL NFC South
unique_id: sensor.nfl_nfc_south
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nfl_standings','children')[1]['children'][2]['standings']['entries'] }}"
- name: NFL NFC West
unique_id: sensor.nfl_nfc_west
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nfl_standings','children')[1]['children'][3]['standings']['entries'] }}"
And the whole dashboard is like this:
decluttering_templates:
nhl_settings:
card:
type: custom:flex-table-card
title: '[[title]]'
css:
table+: 'padding: 0px'
tbody tr td:first-child: 'width: 20%;'
tbody tr td:nth-child(n+2): 'width: 5%;'
tbody tr:hover: 'background-color: lightgreen!important;'
tbody tr td:nth-child(6): 'background-color: #E3F5D4;'
card_mod:
style:
$: |
.card-header {
padding: 12px 0px 8px 4px!important;
font-size: 16px!important;
line-height: 18px!important;
font-weight: bold!important;
}
entities:
include: '[[entity]]'
sort_by: entries-
columns:
- hidden: true
data: entries
modify: x.stats[6].value
- name: Team
data: entries
modify: x.team.displayName
- name: GP
data: entries
modify: x.stats[3].displayValue
- name: W
data: entries
modify: x.stats[10].displayValue
- name: L
data: entries
modify: x.stats[4].displayValue
- name: OTL
data: entries
modify: x.stats[11].displayValue
- name: PTS
data: entries
modify: x.stats[6].displayValue
- name: RW
data: entries
modify: x.stats[14].displayValue
- name: ROW
data: entries
modify: x.stats[15].displayValue
- name: SOW
data: entries
modify: x.stats[17].displayValue
- name: SOL
data: entries
modify: x.stats[16].displayValue
- name: HOME
data: entries
modify: x.stats[19].displayValue
- name: AWAY
data: entries
modify: x.stats[20].displayValue
- name: GF
data: entries
modify: x.stats[8].displayValue
- name: GA
data: entries
modify: x.stats[7].displayValue
- name: DIFF
data: entries
modify: x.stats[13].displayValue
- name: L10
data: entries
modify: x.stats[21].summary
- name: STRK
data: entries
modify: x.stats[9].displayValue
mlb_settings:
card:
type: custom:flex-table-card
title: '[[title]]'
css:
table+: 'padding: 0px'
tbody tr td:first-child: 'width: 20%;'
tbody tr td:nth-child(n+2): 'width: 5%;'
tbody tr:hover: 'background-color: lightgreen!important;'
tbody tr td:nth-child(6): 'background-color: #E3F5D4;'
card_mod:
style:
$: |
.card-header {
padding: 12px 0px 8px 4px!important;
font-size: 16px!important;
line-height: 18px!important;
font-weight: bold!important;
}
entities:
include: '[[entity]]'
sort_by: entries-
columns:
- hidden: true
data: entries
modify: x.stats[16].value
- name: Team
data: entries
modify: x.team.displayName
- name: GP
data: entries
modify: x.stats[7].displayValue
- name: W
data: entries
modify: x.stats[17].displayValue
- name: L
data: entries
modify: x.stats[9].displayValue
- name: T
data: entries
modify: x.stats[15].displayValue
- name: PCT
data: entries
modify: x.stats[16].displayValue
- name: GB
data: entries
modify: x.stats[6].displayValue
- name: PS
data: entries
modify: x.stats[10].displayValue
- name: HOME
data: entries
modify: x.stats[33].displayValue
- name: AWAY
data: entries
modify: x.stats[34].displayValue
- name: RS
data: entries
modify: x.stats[13].displayValue
- name: RA
data: entries
modify: x.stats[12].displayValue
- name: DIFF
data: entries
modify: x.stats[27].displayValue
- name: L10
data: entries
modify: x.stats[37].summary
- name: STRK
data: entries
modify: x.stats[14].displayValue
nfl_settings:
card:
type: custom:flex-table-card
title: '[[title]]'
css:
table+: 'padding: 0px'
tbody tr td:first-child: 'width: 2%;'
tbody tr td:nth-child(2): 'width: 20%;'
tbody tr td:nth-child(n+3): 'width: 6%;'
tbody tr:hover: 'background-color: lightgreen!important;'
tbody tr td:nth-child(7): 'background-color: #E3F5D4;'
card_mod:
style:
$: |
.card-header {
padding: 12px 0px 8px 4px!important;
font-size: 16px!important;
line-height: 18px!important;
font-weight: bold!important;
}
sort_by: entries-
entities:
include: '[[entity]]'
columns:
- hidden: true
data: entries
modify: x.stats[9].displayValue
- name: C
data: entries
modify: x.stats[0].displayValue
- name: Team
data: entries
modify: x.team.displayName
- name: GP
data: entries
modify: x.stats[10].value + x.stats[3].value + x.stats[8].value
- name: W
data: entries
modify: x.stats[10].displayValue
- name: L
data: entries
modify: x.stats[3].displayValue
- name: T
data: entries
modify: x.stats[8].displayValue
- name: PCT
data: entries
modify: x.stats[9].displayValue
- name: HOME
data: entries
modify: x.stats[16].displayValue
- name: AWAY
data: entries
modify: x.stats[17].displayValue
- name: DIV
data: entries
modify: x.stats[18].displayValue
- name: CONF
data: entries
modify: x.stats[19].displayValue
- name: PF
data: entries
modify: x.stats[6].displayValue
- name: PA
data: entries
modify: x.stats[5].displayValue
- name: DIFF
data: entries
modify: x.stats[1].displayValue
- name: STRK
data: entries
modify: x.stats[7].displayValue
game_stats:
card:
type: custom:auto-entities
unique: true
show_empty: false
card:
type: custom:layout-card
layout_type: masonry
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 }}},
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
exclude:
- entity_id: '*team_tracker*'
sort:
method: attribute
attribute: date
views:
- theme: Backend-selected
title: Sports
type: panel
icon: mdi:strategy
badges: []
cards:
- type: custom:tabbed-card
styles:
'--mdc-theme-primary': green
'--mdc-tab-text-label-color-default': gray
'--mdc-typography-button-font-size': 12px
tabs:
- attributes:
label: NHL Standings
icon: mdi:ballot
card:
type: custom:tabbed-card
styles:
'--mdc-theme-primary': green
'--mdc-tab-text-label-color-default': gray
'--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
- type: custom:decluttering-card
template: nhl_settings
variables:
- title: Eastern Metropolitan
- entity: sensor.nhl_east_metropolitan
- type: custom:decluttering-card
template: nhl_settings
variables:
- title: West Central
- entity: sensor.nhl_west_central
- type: custom:decluttering-card
template: nhl_settings
variables:
- title: West Pacific
- entity: sensor.nhl_west_pacific
- 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_*
- type: custom:decluttering-card
template: nhl_settings
variables:
- title: Western
- entity: sensor.nhl_west_*
- attributes:
label: Overall
card:
type: custom:decluttering-card
template: nhl_settings
variables:
- title: Overall
- entity: sensor.nhl_*_*
- attributes:
label: NHL Postgame
icon: mdi:hockey-sticks
card:
type: custom:decluttering-card
template: game_stats
variables:
- sport: NHL
- status: POST
- attributes:
label: NHL Live
icon: mdi:hockey-puck
card:
type: custom:decluttering-card
template: game_stats
variables:
- sport: NHL
- status: IN
- attributes:
label: NHL Pregame
icon: mdi:blood-bag
card:
type: custom:decluttering-card
template: game_stats
variables:
- sport: NHL
- status: PRE
- attributes:
label: MLB Standings
icon: mdi:ballot
card:
type: custom:tabbed-card
styles:
'--mdc-theme-primary': green
'--mdc-tab-text-label-color-default': gray
'--mdc-typography-button-font-size': 12px
tabs:
- attributes:
label: Divisional
card:
type: custom:stack-in-card
mode: vertical
cards:
- type: custom:decluttering-card
template: mlb_settings
variables:
- title: American League East
- entity: sensor.mlb_american_east
- type: custom:decluttering-card
template: mlb_settings
variables:
- title: American League Central
- entity: sensor.mlb_american_central
- type: custom:decluttering-card
template: mlb_settings
variables:
- title: American League West
- entity: sensor.mlb_american_west
- type: custom:decluttering-card
template: mlb_settings
variables:
- title: National League East
- entity: sensor.mlb_national_east
- type: custom:decluttering-card
template: mlb_settings
variables:
- title: National League Central
- entity: sensor.mlb_national_central
- type: custom:decluttering-card
template: mlb_settings
variables:
- title: National League West
- entity: sensor.mlb_national_west
- attributes:
label: Conference
card:
type: custom:stack-in-card
mode: vertical
cards:
- type: custom:decluttering-card
template: mlb_settings
variables:
- title: Americal League
- entity: sensor.mlb_american_*
- type: custom:decluttering-card
template: mlb_settings
variables:
- title: National League
- entity: sensor.mlb_national_*
- attributes:
label: Overall
card:
type: custom:decluttering-card
template: mlb_settings
variables:
- title: Overall
- entity: sensor.mlb_*_*
- attributes:
label: MLB Postgame
icon: mdi:baseball
card:
type: custom:decluttering-card
template: game_stats
variables:
- sport: MLB
- status: POST
- attributes:
label: MLB Live
icon: mdi:baseball-bat
card:
type: custom:decluttering-card
template: game_stats
variables:
- sport: MLB
- status: IN
- attributes:
label: MLB Pregame
icon: mdi:baseball-diamond
card:
type: custom:decluttering-card
template: game_stats
variables:
- sport: MLB
- status: PRE
- attributes:
label: NFL Standings
icon: mdi:ballot
card:
type: custom:tabbed-card
styles:
'--mdc-theme-primary': green
'--mdc-tab-text-label-color-default': gray
'--mdc-typography-button-font-size': 12px
tabs:
- attributes:
label: Divisional
card:
type: custom:stack-in-card
mode: vertical
cards:
- type: custom:decluttering-card
template: nfl_settings
variables:
- title: American Football Conference East
- entity: sensor.nfl_afc_east
- type: custom:decluttering-card
template: nfl_settings
variables:
- title: American Football Conference North
- entity: sensor.nfl_afc_north
- type: custom:decluttering-card
template: nfl_settings
variables:
- title: American Football Conference South
- entity: sensor.nfl_afc_south
- type: custom:decluttering-card
template: nfl_settings
variables:
- title: American Football Conference West
- entity: sensor.nfl_afc_west
- type: custom:decluttering-card
template: nfl_settings
variables:
- title: National Football Conference East
- entity: sensor.nfl_nfc_east
- type: custom:decluttering-card
template: nfl_settings
variables:
- title: National Football Conference North
- entity: sensor.nfl_nfc_north
- type: custom:decluttering-card
template: nfl_settings
variables:
- title: National Football Conference South
- entity: sensor.nfl_nfc_south
- type: custom:decluttering-card
template: nfl_settings
variables:
- title: National Football Conference West
- entity: sensor.nfl_nfc_west
- attributes:
label: Conference
card:
type: custom:stack-in-card
mode: vertical
cards:
- type: custom:decluttering-card
template: nfl_settings
variables:
- title: American Football Conference
- entity: sensor.nfl_afc_*
- type: custom:decluttering-card
template: nfl_settings
variables:
- title: National Football Conference
- entity: sensor.nfl_nfc_*
- attributes:
label: Overall
card:
type: custom:decluttering-card
template: nfl_settings
variables:
- title: Overall
- entity: sensor.nfl_*_*
- attributes:
label: NFL Postgame
icon: mdi:football-helmet
card:
type: custom:decluttering-card
template: game_stats
variables:
- sport: NFL
- status: POST
- attributes:
label: NFL Live
icon: mdi:football
card:
type: custom:decluttering-card
template: game_stats
variables:
- sport: NFL
- status: IN
- attributes:
label: NFL Pregame
icon: mdi:strategy
card:
type: custom:decluttering-card
template: game_stats
variables:
- sport: MLB
- status: PRE
title: Sports Scores
Big thanks to @Ildar_Gabdullin for assistance in this, sorry for pestering until I understod how things work in flex-table. And I have to say I am now in process of moving many things to use decluttering. That dashboard would have 20 times the lines of code without it.
I got the standings and stats working, however I can’t get the PRE, IN, and POST to show anything. Where did you define these sensors? I found the post here: Real-Time Sports Scores w/ TeamTracker and TeamTracker-Card (Beta) - #230 by kbrown01 but it’s still not showing me anything in the games tabs and I have a red circle exclamation mark with no text (sort of indicating an error in the dashboard code)
I fixed this. Not only was I missing the custom card layout-card
, there was also an incorrect double quote character around the custom:teamtracker-card
on line 237. Also the NFL Pregame tab was showing MLB Pregame because the decluttering card had MLB
for the sport.
Also, is there a way to make the table dynamic in size or allow horizontal scrolling? on the HA Mobile App the right columns (example: on NHL anything after ‘SOL’) get cut off and there’s no way to view anything after that.
Something like this for scrolling (partial snip from top of decluttering_templates for one of the flex tables):
decluttering_templates:
nhl_settings:
card:
type: custom:flex-table-card
title: '[[title]]'
css:
table+: 'padding: 0px; width: 1600px;'
tbody tr td:first-child: 'width: 20%;'
tbody tr td:nth-child(n+2): 'width: 5%;'
tbody tr:hover: 'background-color: lightgreen!important;'
tbody tr td:nth-child(6): 'background-color: #E3F5D4;'
card_mod:
style: |
ha-card {
overflow: auto;
}
$: |
.card-header {
padding: 12px 0px 8px 4px!important;
font-size: 16px!important;
line-height: 18px!important;
font-weight: bold!important;
}
So adding a fixed table width (you pick what you like for PC dashboard) and then adding overflow:auto
on the ha-card itself. This will allow you to scroll the table left/right.
As for the other issues, I will take a look and be sure all is good. I was creating a Git with all the sensors and dashboard view over the next day (while I added NBA too).
Hmmm, that didn’t work. The fixed width worked, but the overflow: auto
did not, I still can’t scroll horizontally. I’ll mess around with the code a bit and see if I can get it to scroll.
What platform? Works on my Windows PC in Chrome and Edge and my Android using Chrome.
Windows 10, chrome. Also tried on the HA mobile app for iOS. I did clear cache and refresh the page.
Not sure, works for me. Here is PC Window shrank which pops the scroll bar:
Here is view scrolled on my Android phone (only top table in multiple stats):
I have put everything I have out on GITHUB. You will find all the rest, template and teamtracker sensors for NFL, NHL, MLB and NBA along with the PRE, IN, POST views in a tabbed Dashboard.
Looking for someone that wants to help do the last missing piece! a PLAYOFF/WILDCARD type view under standings. I have yet to implement that yet.
Leave comments on GITHUB or here.
I don’t know why it didn’t work before, but I just copied the dashboard from your repo and horizontal scrolling is working.
One suggestion I might make is on the team tracker card, since most sports (at least the 4 major North American sports) list the home team on the right, add the option to do so where it generates the team tracker card. {{{"type": "custom:teamtracker-card", "entity": team, "home_side": "right" }}}
@kbrown01 Very nice work! This probably deserves its own thread with a link to it from here.
The questions and troubleshooting are different enough that separating them out will likely make both easier to follow. If you post the link to the thread here, I’ll include it in the Wiki as well.
I have install all extra cards in put the code in the sonsor.yaml and template.yaml.
But if I put the code into the dasboard, I got this error:
Configuration error detected:
No type specified.
I take the code from the dasboard.yaml from the github
What I make wrong?
Did you create an empty side dashboard? If yes then you need to manage the full YAML by selecting the “Raw configuration editor”.
That code should paste in there. It is important that you create an empty Dashboard and do not replace your main one. This would destroy your existing dashboard if you did wipe that out.
An empty dashboard is much easier to work with and would appear in your side bar.
I will do so, I just noticed an issue this AM not sure how to address. Because Boston already cliched a playoff sport, ESPN added a field to their entry called “clincher” which throws off all the indexes for their team only.
How dumb of ESPN. You would have thought they would have added that to every team, not just one. I will take a look at solving that first.
I will need to convert all the templates to use “find” as in:
- name: OTL
data: entries
modify: x.stats.find(y=>y.shortDisplayName == 'OTL').displayValue
This way, as long as they do not change the shortDisplayName, it will always pick the right data
perfect, now I don´t get an error
But if I click on “Devisional” the are only headlines:
I have the following code in my configuration.yaml:
- binary_sensor:
- name: NHL East Atlantic
unique_id: sensor.nhl_east_atlantic
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nhl_standings','children')[0]['children'][0]['standings']['entries'] }}"
- name: NHL East Metropolitan
unique_id: sensor.nhl_east_metropolitan
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nhl_standings','children')[0]['children'][1]['standings']['entries'] }}"
- name: NHL West Central
unique_id: sensor.nhl_west_central
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nhl_standings','children')[1]['children'][0]['standings']['entries'] }}"
- name: NHL West Pacific
unique_id: sensor.nhl_west_pacific
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nhl_standings','children')[1]['children'][1]['standings']['entries'] }}"
and in sensors.yaml:
- platform: rest
scan_interval: 36000
name: NHL Standings
unique_id: sensor.nhl_standings
resource: https://site.web.api.espn.com/apis/v2/sports/hockey/nhl/standings?seasontype=2&type=0&level=3
value_template: "{{ now() }}"
json_attributes:
- children
Did you reload entities?
Developer tools → YAML → Rest Entities
Then reload Template Entities.
It likely has not reached out for the stats yet unless you restart or reload.
Note I am looking at changes because ESPN changed the field order last night which broke NHL Standings for Boston only but throws off other things too