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.