delzear / hass-formulaoneapi

Formula One API Integration Into Home Assistant
53 stars 10 forks source link

Flag of USA not working in "Next Race" Lovelace card #48

Closed thewolf-oz closed 2 years ago

thewolf-oz commented 2 years ago

Great work! Have just added this through HACS

One point of note is the country returned for US GP is "USA" while Countries of the World use "United-States-of-America" is used in the image URL

I've injected an extra IF statement to allow for this:

{% set nr = states.sensor.formula_one_sensor_races.attributes.next_race %} {% if not(nr == None) %} {% if nr.Circuit.Location.country == "USA" %}

  {{ nr.round }} : {{ nr.raceName }}

{% else %}
  <h2><img height="25" src="https://www.countries-ofthe-world.com/flags-normal/flag-of-{{nr.Circuit.Location.country | replace(" ","-")}}.png">&nbsp;  {{ nr.round }} :  {{ nr.raceName }}</h2>
{% endif %}
marcokreeft87 commented 2 years ago

Thnx for the headsup. Ive put this in the card we have https://github.com/marcokreeft87/formulaone-card. I think at a certain point we need to stop with support on the markdown because its not part of the integration