From dda8a88ffff6f4b88614062f9a8857b37c8bdd1d Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Sat, 4 Apr 2026 17:15:32 -0400 Subject: [PATCH] Use new "entity_name" template function --- custom_templates/sports.jinja | 24 ++++++++++++------------ packages/presence.yaml | 2 +- packages/sports.yaml | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/custom_templates/sports.jinja b/custom_templates/sports.jinja index 34e9ce3..0a64a54 100644 --- a/custom_templates/sports.jinja +++ b/custom_templates/sports.jinja @@ -61,7 +61,7 @@ {% if is_state(team,'PRE') %} {% set date = state_attr(team,'date') | as_timestamp | timestamp_custom('%m-%d') %} {% if date == now().strftime('%m-%d') %} - The {{ state_attr(team,'friendly_name') }} will be playing today against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} at {{ state_attr(team,'venue') }}. + The {{ entity_name(team) }} will be playing today against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} at {{ state_attr(team,'venue') }}. {{ sports_str(team,'start') }} is at {{ state_attr(team,'date') | as_timestamp | timestamp_custom('%I:%M %p') }}. {% endif %} {% endif %} @@ -82,26 +82,26 @@ {% set yday = (as_timestamp(now()) - (24*3600)) | timestamp_custom('%m-%d') %} {% if date == now().strftime('%m-%d') %} {% if state_attr(team,'clock') in ['postponed','Postponed'] %} - The {{ state_attr(team,'friendly_name') }} had their game postponed today, and it will be played at a later date. + The {{ entity_name(team) }} had their game postponed today, and it will be played at a later date. {% elif (state_attr(team,'team_score') | int) == state_attr(team,'opponent_score') | int %} - The {{ state_attr(team,'friendly_name') }} tied in their game today against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. + The {{ entity_name(team) }} tied in their game today against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. {% elif state_attr(team,'team_winner') == true %} - The {{ state_attr(team,'friendly_name') }} won their game today against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. + The {{ entity_name(team) }} won their game today against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. {% elif state_attr(team,'opponent_winner') == true %} - The {{ state_attr(team,'friendly_name') }} lost their game today against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} by a score of {{ state_attr(team,'opponent_score') }} to {{ state_attr(team,'team_score') }}. + The {{ entity_name(team) }} lost their game today against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} by a score of {{ state_attr(team,'opponent_score') }} to {{ state_attr(team,'team_score') }}. {% endif %} {% if state_attr(team,'clock') not in ['postponed','Postponed'] and state_attr(team,'team_record') != None %} This brings their record to {{ state_attr(team,'team_record') | replace("-"," and ") }} on the season. {% endif %} {% elif yday == date %} {% if state_attr(team,'clock') in ['postponed','Postponed'] %} - The {{ state_attr(team,'friendly_name') }} had their game postponed yesterday, and it will be played at a later date. + The {{ entity_name(team) }} had their game postponed yesterday, and it will be played at a later date. {% elif (state_attr(team,'team_score') | int) == state_attr(team,'opponent_score') | int %} - The {{ state_attr(team,'friendly_name') }} tied in their game yesterday against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. + The {{ entity_name(team) }} tied in their game yesterday against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. {% elif state_attr(team,'team_winner') == true %} - The {{ state_attr(team,'friendly_name') }} won their game yesterday against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. + The {{ entity_name(team) }} won their game yesterday against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. {% elif state_attr(team,'opponent_winner') == true %} - The {{ state_attr(team,'friendly_name') }} lost their game yesterday against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} by a score of {{ state_attr(team,'opponent_score') }} to {{ state_attr(team,'team_score') }}. + The {{ entity_name(team) }} lost their game yesterday against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} by a score of {{ state_attr(team,'opponent_score') }} to {{ state_attr(team,'team_score') }}. {% endif %} {% if state_attr(team,'clock') not in ['postponed','Postponed'] %} This brings their record to {{ state_attr(team,'team_record') | replace("-"," and ") }} on the season. @@ -109,11 +109,11 @@ {% endif %} {% elif is_state(team,'IN') %} {% if (state_attr(team,'team_score') | int) == (state_attr(team,'opponent_score') | int) %} - The {{ state_attr(team,'friendly_name') }} are currently tied in their game against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} with a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }} {{ sports_clock(team) }}. + The {{ entity_name(team) }} are currently tied in their game against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} with a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }} {{ sports_clock(team) }}. {% elif (state_attr(team,'team_score') | int) > (state_attr(team,'opponent_score') | int) %} - The {{ state_attr(team,'friendly_name') }} are currently winning their game against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} with a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }} {{ sports_clock(team) }}. + The {{ entity_name(team) }} are currently winning their game against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} with a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }} {{ sports_clock(team) }}. {% else %} - The {{ state_attr(team,'friendly_name') }} are currently losing their game against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} with a score of {{ state_attr(team,'opponent_score') }} to {{ state_attr(team,'team_score') }} {{ sports_clock(team) }}. + The {{ entity_name(team) }} are currently losing their game against {% if state_attr(team,'league') != 'NCAAF'%}the{% endif %} {{ opponent_name }} with a score of {{ state_attr(team,'opponent_score') }} to {{ state_attr(team,'team_score') }} {{ sports_clock(team) }}. {% endif %} {% endif %} {% endmacro %} diff --git a/packages/presence.yaml b/packages/presence.yaml index 3e0b967..e100584 100644 --- a/packages/presence.yaml +++ b/packages/presence.yaml @@ -376,7 +376,7 @@ intent_script: speech: text: > {% set location = states(person) %} - {% set name = state_attr(person,'friendly_name') %} + {% set name = entity_name(person) %} {% if location in ['away','not_home'] %} {{ name }} is currently away from home {% elif location in ['unavailable','unknown'] %} diff --git a/packages/sports.yaml b/packages/sports.yaml index 5467cb4..b921866 100644 --- a/packages/sports.yaml +++ b/packages/sports.yaml @@ -181,7 +181,7 @@ intent_script: {% set inhibit = "binary_sensor." + team + "_inhibit" %} {% set sensor = "sensor." + team %} {% if is_state(inhibit,'on') %} - I do not have any information about the {{ state_attr(team,'friendly_name') }} at this time. + I do not have any information about the {{ entity_name(sensor) }} at this time. {% elif states(sensor) in ["NOT_FOUND"] %} They do not appear to have a game scheduled for today. {% else %}