delzear / hass-formulaoneapi

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

Next race shows next race instead of upcoming race #21

Closed davidrustingha closed 2 years ago

davidrustingha commented 2 years ago

Right now it's sunday and the race hasn't begun yet. It still shows the next race being on the Jeddah Circuit.

evildonkey1 commented 2 years ago

Same here, and im not seeing the png's

robinwillems commented 2 years ago

I have the same problem. Next race instead of today and no images

austensmith commented 2 years ago

This fixes the image and logos. Both couldn't account for spaces.

 {% set nr = states.sensor.formula_one_sensor.attributes.next_race  %} {% if
  not(nr == None) %}  <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>

  <small>Local time : {{ as_timestamp(nr.date + ' ' + nr.time) |
  timestamp_custom("%H:%M on %y-%m-%D ") }}</small>

  <a target="_new" href="{{nr.Circuit.url}}">
    <img width="100%" src="https://www.formula1.com/content/dam/fom-website/2018-redesign-assets/Circuit%20maps%2016x9/{{nr.Circuit.Location.country | replace(" ","_")}}_Circuit.png.transform/7col/image.png">
  </a> <br> 

  Season: {{nr.season}}<br>

  Race: {{nr.round}}<br>

  Race name : {{nr.raceName}}<br>

  Circuit name : {{nr.Circuit.circuitName}}<br>

  Location: {{nr.Circuit.Location.country}}<br>

  Date : {{nr.date}}<br>

  Time : {{nr.time}}<br>  {% endif %}
robinwillems commented 2 years ago

{% set nr = states.sensor.formula_one_sensor.attributes.next_race %} {% if not(nr == None) %}

<img height="25" src="https://www.countries-ofthe-world.com/flags-normal/flag-of-{{nr.Circuit.Location.country | replace(" ", "-")}}.png">  {{ nr.round }} : {{ nr.raceName }}

Local time : {{ as_timestamp(nr.date + ' ' + nr.time) | timestamp_custom("%H:%M on %y-%m-%D ") }}

<img width="100%" src="https://www.formula1.com/content/dam/fom-website/2018-redesign-assets/Circuit%20maps%2016x9/{{nr.Circuit.Location.country | replace(" ","_")}}_Circuit.png.transform/7col/image.png">

Yes, this works perfectly for the images problem

evildonkey1 commented 2 years ago

Works like a charm. Thnx