There you go, just plug in that to your original. I think this:
{% set cteams = namespace(cteam=[]) %}
{% for team in state_attr('sensor.ncaaf_rank','rankings')[0]['ranks'] %}
{% set cteams.cteam = cteams.cteam + [team.team.abbreviation] %}
{% endfor %}
{{ cteams.cteam }}
Assuming you got the answers you wanted. I would play with that template and strip the spaces but it may not be required when adding them to the array. You could plug that into the template editor and see if you get an array with many items with each abbr.
Are ESPN API parameters standard or varied? I can pull the information I want from any sport as long as it’s from “/sport/league/scoreboard”. NHL for example, works perfectly for my needs.
When I try to replicate that for “sport/league/team…/schedule”, I always receive the full season.
As an example, 'd like to view only completed Dallas Stars games. I’ve read all the API sites I can find. I continue to receive the full season almost as if nothging after /schedule/seasontype=*/ responds.
Ok this is embarrassing but I have to come clean so others don’t pull out their hair. I was working on separating the templates and sensors into their own files as I mentioned earlier. I had broken out the sensors and they all work fine. In my configuration.yaml the code is:
sensor: !include_dir_merge_list sensors/
I tried doing the same thing with Templates and no matter what, I couldn’t get them to work. So I went back to the single template.yaml file but like the dummy I am I continued to work on the template.yaml file in the template directory while my config was pointed at the orignal template.yaml in the config.
So the file I was working on was never seen by HA which is why there were no entities.
Now on a positive note my original code works as expected as does @kbrown01 's.
@kbrown01 did the NHL standings resource change? My pre-season worked fine and shows the correct stats and rankings, but regular season is completely blank. There is data at that API endpoint though. Is this because the regular season just started?
I analyzed this and I believe it is a bug in flex-table. I will investigate a workaround and have a temporary solution for now.
The issue comes from the “Last Ten” (L10) field. It contains a displayValue and summary that are like “1-0-0” or “1-0-0, 2 PTS” and for some reason this errors in flex-table.
The quick solution is to just remove that column in the decluttering template for L10:
Just remove the three lines of L10 for now. Possibly I need to add forcing it to a string or something and I will test, but without L10, this will get you going.
Although … oddly enough HOME and AWAY fields work so possible its the name “L10”
Update, I have no idea why flex-table is throwing the error so I have posted here:
OK. more diagnosis and likely the solution:
It looks like the field L10 is not in the data for any team that has not yet played. This will go away in a few days or you can just remove that and re-add it. Or you can use the same code as CLINCH that ensures the field exists and if it doesn’t display whatever you wish.
Yep, that’s the same code I just added. Also fixed my overall standings tab. I had added some template sensors for pre-season and forgot to exclude the additional sensors in the decluttering card where I used a wildcard entity.
Hello all! Just wondering if anyone has any issues with the NBA tab for scores and the logos/names going off the cards. I think with the scores over 100 the characters are getting moved too much to the right? Wondering if i have something missing in my code. Thanks in advance for the help!
Also - I am just using the stock game-stats template @kbrown01 created. I change the cards for NCAAF because I like them smaller on the pages. This still is a work in progress but you get the drift.
I am running into the Template exceeding max size error with some of my NCAAF conference sensors now. Is there a way around this or do I just need to limit what I am grabbing?
Specifically the atlantic_coast_conference [1] and the big_ten_conference [3]
Here is the api I’m calling:
- platform: rest
scan_interval: 36000
name: College Football Standings
unique_id: sensor.college_football_standings
resource: https://site.web.api.espn.com/apis/v2/sports/football/college-football/standings?seasontype=2&type=0&level=3
value_template: "{{ now() }}"
json_attributes:
- children
and here is the code I using to create the sensor. Thanks for any ideas.
@kbrown01 I don’t think that that is it. The error that is shown above only appears with the sensors that grab the [1] and [3] child. I get the error shown and the sensor is not populated.
The logs show this specific error on only these 2. But what I don’t understand is that these values are beingin pulled from another sensor (sensor.college_football_standings) which clearly contains the values and doesn’t error out.
homeassistant.exceptions.TemplateError: Template output exceeded maximum size of 262144 characters
2024-10-12 07:09:55.782 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('Template output exceeded maximum size of 262144 characters') while processing template 'Template<template=({{ state_attr('sensor.college_football_standings','children')[1]['standings']['entries'] }}) renders=4>' for attribute 'entries' in entity 'sensor.atlantic_coast_conference'
2024-10-12 07:09:55.892 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({{ state_attr('sensor.college_football_standings','children')[3]['standings']['entries'] }}) renders=2>
Traceback (most recent call last):
Hello @23Phantom08. I am by no means the expert in efficient coding, but I’ll help however I can.
When looking at your code, you haven’t definded the cards or style you’re want to present. Using the basics of what @kbrown01 has shared previously and using as much of your code as possible, you’ll see the results in images below.
Also, have a look at your CSS values to ensure they are displaying what you’d like to see. 3rd child 20% width is a huge space on a laptop screen (I used 3% for the example). Also, some of the coloring, like “dimgrey” highlighting and “white” background are for my eyes as I use dark mode on just about everything.
The “Trend” column refers to x.current and x.previous. If you are pulling from the same ESPN API as I am, Rank “R” is offered, but Rank Change “RC” remains zero’s. I do not see Previous or Current values anywhere. Lastly, on the final row of the trend code snippet, you have extra characters after the closing " } " that is likely why you are not seeing any return on your screen.
Please note - These images are on my laptop with the browser window manually narrowed.
Thanks for your answer @ehcah. Could it be that I’m missing a value to retrieve in my config.yaml or that I haven’t configured the decluttering card correctly?I don’t know much about it either, so I’m asking.
Hello @23Phantom08 For troubleshooting, there are a number of things you should validate. These are in no particular order, but will all help ensure your code will display correctly.
In your configuration.yaml file. Make sure you include the sensor.yaml and template.yaml lines. A standard install would inlude the following, at minimum.
Assuming you replaced my sensor name with yours, in the code I shared above and you still aren’t seeing anyting. Use the HA Developer Tools to check the state of your sensor " sensor.bundesliga_tabelle ". You should be seeing something come back like this:
A note on my reference of “German” with Bundesliga. I used “english” for EFL, “french” for Ligue 1 etc… There is no intent behind my naming other than pointing towards a country or region for my own reference. I hope it’s obvious, but I don’t know who is reading and want to be clear.