Formula One Card

0.3.3 Did not fix it for me (tried complete reinstall of the card as well, including several reboots)

      - type: custom:formulaone-card
        card_type: next_race
        # sensor: sensor.formula_one_sensor_races
        title: Volgende race
        date_locale: nl
        image_clickable: true

      - type: custom:formulaone-card
        card_type: last_result
        # sensor: sensor.formula_one_sensor_last_result
        title: Laatste race

      - type: custom:formulaone-card
        card_type: driver_standings
        # sensor: sensor.formula_one_sensor_drivers
        title: Stand coureurs
        standings:
          show_flag: true
          show_team: true

      - type: custom:formulaone-card
        card_type: constructor_standings
        # sensor: sensor.formula_one_sensor_constructors
        title: Stand constructeurs

      - type: custom:formulaone-card
        card_type: schedule
        # sensor: sensor.formula_one_sensor_races
        title: Volgende races
        date_locale: nl
        previous_race: hide

Let me know if I can help testing - you can find me at Discord (official HA channel or the two major NL channels, Dutch Domotics / Home Assistant Addicts)

edit:

in the source of the compiled package, the error is still defined. Did the compile go well?

Recompiled it and new version released

1 Like

Always using the latest version…
EDIT: Yes, now is working…
So we don’t need anymore the - platform: formulaone_api in sensor.yaml?

Works!

1 Like

Indeed and you can uninstall the integration in hacs

1 Like

For who used the data from the API for notifications for example.
I use a REST sensor.

The rest sensor:

- platform: rest
  scan_interval: 86400
  resource_template: https://ergast.com/api/f1/{{ now().strftime('%Y') }}.json
  sensor:
    - name: "F1 Schedule"
      json_attributes_path: "$.MRData"
      value_template: "OK"
      json_attributes:
        - "total"
        - "RaceTable"

The sensor for exposing the data:

platform: template
sensors:
  formula_one_next_race:
    friendly_name: 'Formula One Next Race'
    unique_id: 'formula_one_next_race'
    attribute_templates:
      data: >-
        {% set data = namespace(found=False) %}
        {% for race in state_attr("sensor.f1_schedule", "RaceTable").Races if data.found == false -%}  
          {% set datetime = ((race.date + 'T' + race.time) | as_datetime) -%}
          {%- if datetime > now() -%}
            {{ race }}
            {% set data.found = true %}
          {%- endif %}
        {%- endfor %}
      race_name: >-
        {%- if 'data' in this.attributes -%}
          {{ this.attributes.data.raceName }}        
        {%- endif %}
      race_start: >-
        {%- if 'data' in this.attributes -%}     
          {{ ((this.attributes.data.date + 'T' + this.attributes.data.time) | as_datetime) }}        
        {%- endif %}
      first_practice: >-
        {%- if 'data' in this.attributes -%}
          {{ ((this.attributes.data.FirstPractice.date + 'T' + this.attributes.data.FirstPractice.time) | as_datetime) }}        
        {%- endif %}     
      second_practice: >-
        {%- if 'data' in this.attributes -%}
          {{ ((this.attributes.data.SecondPractice.date + 'T' + this.attributes.data.SecondPractice.time) | as_datetime) }}        
        {%- endif %}
      third_practice: >-
        {%- if 'data' in this.attributes -%}
          {{ ((this.attributes.data.ThirdPractice.date + 'T' + this.attributes.data.ThirdPractice.time) | as_datetime) }}        
        {%- endif %}
      qualifying: >-
        {%- if 'data' in this.attributes and 'Qualifying' in this.attributes.data -%}
          {{ ((this.attributes.data.Qualifying.date + 'T' + this.attributes.data.Qualifying.time) | as_datetime) }}          
        {% else %}
          -
        {%- endif %}
      sprint: >-
        {%- if 'data' in this.attributes and 'Sprint' in this.attributes.data -%}
          {{ ((this.attributes.data.Sprint.date + 'T' + this.attributes.data.Sprint.time) | as_datetime) }}          
        {% else %}
          -
        {%- endif %}
    value_template: >-
      on

Most of the if statements are to prevent warnings when HA boots. The sensor isnt available from the start

6 Likes

Other option, it’s a faster option, is to use ics_calender integration and use calendar automations

Is there an option to reduce the size of the track image?

I tried this

style: |
         img {
          width: 35%;
        }

But also effects the flag image

No build in option no, does image:first help?

Thanks for the tip. I used the follow CSS and it works!

style: |
        img:nth-child(2){
          width: 35%;
         }
1 Like

is the API going to be dismissed?

I do not maintain the API. But as I have mentioned earlier. The card isnt dependent on the API anymore

3 Likes

didn’t realize, thanks for that: implemented today and didn’t go through the whole thread :sweat_smile:

Like most people do haha. Its ok :slight_smile:

But it’s now fetching from a site, isn’t that also shutting down now?
Api integration will go away , but the backing service too if i read this well, or is the source for this card now completely different ( then I missed something completely)

I use the source of the API directly. So no caching of the API in between :slight_smile:
This wont only make the card independent, it will also open up the possibility for more functionality :partying_face:

the ergast.com API does not mention anything about shutting down. I think it is… some elaborate wording of the custom_component owner talking about servers etc.

TL;DR; Nothing to worry.

Exactly! :smiley:

Ok, I’ll shut up then :smiley:

There is a new kind of card available : Results.
Check it out!

3 Likes