- name: NBA Eastern Atlantic
unique_id: sensor.nba_eastern_atlantic
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nba_standings','children')[0]['children'][0]['standings']['entries'] }}"
- name: NBA Eastern Central
unique_id: sensor.nba_eastern_central
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nba_standings','children')[0]['children'][1]['standings']['entries'] }}"
- name: NBA Eastern Southeast
unique_id: sensor.nba_eastern_southeast
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nba_standings','children')[0]['children'][2]['standings']['entries'] }}"
- name: NBA Western Northwest
unique_id: sensor.nba_western_northwest
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nba_standings','children')[1]['children'][0]['standings']['entries'] }}"
- name: NBA Western Pacific
unique_id: sensor.nba_western_pacific
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nba_standings','children')[1]['children'][1]['standings']['entries'] }}"
- name: NBA Western Southwest
unique_id: sensor.nba_western_southwest
state: "{{ now() }}"
attributes:
entries: "{{ state_attr('sensor.nba_standings','children')[1]['children'][2]['standings']['entries'] }}"
In what file is that snippet contained? And if separate, is it included? And above the first name entry do you have:
sensor:
In my setup I use includes so my main configuration yaml has:
template: !include template.yaml
Then this file would be:
sensor:
- name: NBA Eastern Atlantic
... rest of stuff here ...
That is in template.yaml.
Log says:
Invalid config for [template]: [name] is an invalid option for [template]. Check: template->name. (See /config/include/template.yaml, line 513).
Line 513 starts at
entries: "{{ state_attr('sensor.nba_standings','children')[0]['children'][0]['standings']['entries'] }}"
First line of template.yaml should be:
sensor:
Then the rest of the actual stuff you posted. Is the first line correct?
This means exactly what I am saying. HA sees …
template:
- name: ,,,,,,
not
template:
sensor:
- name: ,,,,
SO this is for the NFL? It is possible you have the old code maybe. Like this is the latest for the decluttering template for NFL:
nfl_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: 6%;'
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;
}
sort_by: entries-
entities:
include: '[[entity]]'
exclude: '[[excluded_entities]]'
columns:
- hidden: true
data: entries
modify: x.stats.find(y=>y.abbreviation == 'PCT').value.toFixed(2)
- name: C
data: entries
modify: >-
if(typeof x.stats.find(y=>y.abbreviation == 'CLINCH') !==
'undefined' ){x.stats.find(y=>y.abbreviation ==
'CLINCH').displayValue}else{'-'}
- name: Team
data: entries
modify: >-
'<div><img src="' + x.team.logos[0].href + '" style="height:
20px;vertical-align:middle;"> ' + x.team.displayName + '</div>'
- name: GP
data: entries
modify: >-
x.stats.find(y=>y.abbreviation == 'L').value +
x.stats.find(y=>y.abbreviation == 'W').value +
x.stats.find(y=>y.abbreviation == 'T').value
- name: W
data: entries
modify: x.stats.find(y=>y.abbreviation == 'W').value
- name: L
data: entries
modify: x.stats.find(y=>y.abbreviation == 'L').value
- name: T
data: entries
modify: x.stats.find(y=>y.abbreviation == 'T').value
- name: PCT
data: entries
modify: x.stats.find(y=>y.abbreviation == 'PCT').value.toFixed(2)
- name: HOME
data: entries
modify: x.stats.find(y=>y.shortDisplayName == 'HOME').displayValue
- name: AWAY
data: entries
modify: x.stats.find(y=>y.shortDisplayName == 'AWAY').displayValue
- name: DIV
data: entries
modify: x.stats.find(y=>y.shortDisplayName == 'DIV').displayValue
- name: CONF
data: entries
modify: x.stats.find(y=>y.shortDisplayName == 'CONF').displayValue
- name: PF
data: entries
modify: x.stats.find(y=>y.shortDisplayName == 'PF').displayValue
- name: PA
data: entries
modify: x.stats.find(y=>y.shortDisplayName == 'PA').displayValue
- name: DIFF
data: entries
modify: x.stats.find(y=>y.shortDisplayName == 'DIFF').displayValue
- name: STRK
data: entries
modify: x.stats.find(y=>y.shortDisplayName == 'STRK').displayValue
This was changed long ago to remove dependency on the position and use a lookup to find the proper column by its abbreviation. This solves issues when ESPN changes structures of the data.
And those would use this for NFL tab:
card:
type: custom:tabbed-card
styles:
'--mdc-theme-primary': green
'--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: 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_*_*
- excluded_entities:
- sensor.nfl_red_zone
- sensor.nfl_standings
- sensor.nfl_teams
- attributes:
label: Playoffs
card:
type: markdown
content: coming soon!
If you read here, this talks about the issue and resolution. I have not done all the sports. I guess I need to update the GITHUB so people do not grab the older code:
Updating the dashboard, yaml file seems to fixed NFL and MLB standings…not getting any live scores now…lol
This is an awesome piece of work though…I’m sure I’ll figure it out!
Thanks for the help and work!
If you just took my code verbatium I will guess at the issue.
You have no sensor named sensor.nfl_red_zone
You should remove the test for this sensor which I use to draw a red border in NFL live scores when a team goes into the red zone.
This is where I mean (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
Remove the “if” and “else/endif” for the red zone test. This is a generic template. What it does is loop through all teams in teamtracker for a particular sport. If the status in “IN” and the team is the home team then it will draw a card. If the team matches a team in the red zone list, the border is red, if not it is just regular. It will not break MLB, NHL, NBA because there is no such thing as “Red Zone” but it would break if you do not have that sensor.
If you do not have that sensor, details were posted above on it but I can report if you like … or you can just remove the test.
I was thinking of expanding the logic on that for MLB to draw red border when bases are loaded. MLB, NHL not much there but could do like overtime/shootout.
I will also note that this is why you see things like this:
variables:
- title: Overall
- entity: sensor.nfl_*_*
- excluded_entities:
- sensor.nfl_red_zone
- sensor.nfl_standings
- sensor.nfl_teams
Since those sensors (red zone, standings, teams) do not carry the standings they must be excluded from sensors used to draw the standings ( sensor.nfl_*_*
) or the standings will break.
A whole lot of red last night for my Detroit Lions!
A note to everyone. This weekend I am going to perform a major update to make things a bit easier to manage. I just did some testing and had no idea that decluttering templates can include a card that includes decluttering templates.
To start with, this will make things much easier to manage with Pre/Post/In game stats by using a decluttering template that can use card_mod in a more straghtforward edit and not trying to use jinja to make the cards with auto_entities.
as in this works:
decluttering_templates:
test1:
card:
type: vertical-stack
cards:
- type: custom:decluttering-card
template: test2
variables:
- teststring1: '[[teststring]] which is modified'
test2:
card:
type: markdown
content: '[[teststring1]]'
views:
- title: Home
cards:
- type: custom:decluttering-card
template: test1
variables:
- teststring: this is a test
title: Regular Playground
So the Teamtracker scoring built by auto-entities can just call appropriate decluttering templates for red zone, overtime, etc.
This may not work with filters and auto-entities. We shall see.
Hello @kbrown01 just wanted to say this is great. I’ve got this setup locally and also helped set it up for others. I know you mentioned about a major upgrade over the weekend. I went ahead and submitted a PR to you if you’d like. One of the things I thought was to make this easier to add a full sport and remove would be to use built in packages. I also did some updating to the dashboard as a lot of them were using index and not searching based off type which was causing wrong values to be displayed in the dash. Feel free to use what I’ve done in the PR if you’d like. The only other thing I made a change to was the ordering of the tabs to do Pre/In/Post. Again love this setup!
Thanks! I will take a look … packages are perfect. I did not get around this weekend to doing anything however I would note that it looks like you grabbed code prior to me updating it to use (mostly) named based lookups.
Things I would like to do:
- Implement something for Playoff NFL, NHL then MLB and NBA
- Figure out if it is possible to send a YouTube change channel command. Would be real cool to see Red Zone in the GUI, click and tune to that station (assuming of course the game is on YouTube). I can do it with my DirecTV integration and plan to implement that for local games and those on DirecTV channels.
- Red Zone-like implementation for MLB (Bases Loaded?), Hockey, Basketball (Overtime?)
- March Madness???
- Try to improve NHL Starting Goalies as it’s running key method isn’t working well
The change channel thing will be dependent on not just the service (YouTubeTV), but the device (Roku).
I use those examples because it is what we are using.
The Roku api does not allow for that granular control. You can change to a Roku Channel (service). But, cannot change the channel in that service. So, that part will be very specific to each users’ setup.
Agreed and understood. My huge DirecTV + Vizio TV integration has customized things just like that. I keep a JSON file around with station vs. number and do a favorites view where you click one to change the channel (sent through REST).
Now I am sure noting like that exists generically for YouTube (aka … REST command to pick the channel). Because I use Vizio and Vizio publishes every command to launch an app, I also wrote the App plugin:
Logo app … one click to get to a channel.
I could log key strokes or searches or maybe even Alexa stuff but yes, it would be custom.
Happy note. Am heading out to Sharks v Golden Nights so I checked the “Starting Goalies” tab to see whose in net and it is working! Maybe the grabbing of the ever-changing key works?
What’s the latest for NBA? I have scores showing but no standings in Divisional, conference, overall etc…
NBA is preseason. The current setup from @kbrown01 is for regular season.
With no changes to anything, they should start showing up when the season starts.
ah yes of course it’s pre-season! duh…my bad! Got excited when I saw games coming up!
You can change the REST query string for preseason. I am not in front of my computer to know which parameter it is.
Of course you would need to reload or create a set of sensors for that.