#F1 Automatic Notifications

1 messages · Page 1 of 1 (latest)

tulip moth
#

https://github.com/Nicxe/f1_sensor

I seen this integration today and was wondering if anyone could help me setup an automation to have a notification sent 1 hour before the races start.

The "F1_next_race" entity has an attribute " Race start " that I assume I can setup as a trigger but I'm rather new to all this and haven't been able to figure it out.

GitHub

A Home Assistant Custom Integration that provides information about the next Formula 1 race and the full season calendar - Nicxe/f1_sensor

primal current
#

Create an automation that uses that entity as a trigger.

#

It does this

tulip moth
#

@primal current Yeah I've got that card setup on it's own page, it's pretty cool. I just wanted to make use of this F1 sensor one to trigger a notification before a race starts. I tried to setup that entity as a trigger but I got confused when trying to trigger it based on a time offset to that attribute.

primal current
#

Hi. I use node red for all of my automations. If you are open to that, I’d be happy to setup a flow that way tomorrow and share it with you, so you can import it. Indeed, if you are more of a visual person, you might prefer using node red. Here’s a good intro video, and if you search YouTube there’s a ton of great content. Lmk https://youtu.be/KXcwUdDqXXo?si=gCALDdGIFvm-1T2h

This video goes through installing the Node-RED add-on in Home Assistant and how to create your first few basic flows.

The key nodes for understanding how it works and testing your first flows are discussed, such as the inject and debug nodes.

If you would like to see a follow-up video with some more detailed examples then let me know in the c...

▶ Play video
tulip moth
#

I've never used it, I'll get it setup today

primal current
#

And have fun 😉

#

And in the meantime, cheer on Lewis Hamilton tomorrow !

primal current
#

Good morning . I should have an example flow for you when I can get to this in a few hrs or so

tulip moth
#

Yeah no rush, thanks

primal current
#

Hi. Check this out. Import it into a new flow. You’ll need to select your home assistant instance in the nodes.

#

Then in the function node, you can turn it into test mode, so you can manually set a next race time to ensure everything works before getting to the next race

#

Lmk how it works for you.

flint sluice
#

If you want to do this in HA without resorting to node red it is pretty simple. You have two options, the most straightforward is to create a new template sensor to copy out the race_start attribute into its own sensor.

Go to devices & services -> helpers -> template -> template a sensor. Name it whatever you want. For the ‘state template’ enter this: {{ state_attr('sensor.f1_next_race', 'race_start') }}

Then make sure for device class you choose timestamp. Everything else you can leave alone/unselected.

The create an automation, and for the trigger choose ‘time and location’ and then ‘time’. You can then select “value of a date/time helper” and then select the new sensor you created. You can offset it by an hour if you’d like also.

tulip moth
#

@primal current @flint sluice Thank you both!! I ended up going the helper template route. I've never used node red before and it was confusing me, thank you anyway tinkerer.

tulip moth
#

@flint sluice @primal current I do have a further question if it's not too much to ask.

I'm trying to add this to the notification

{{state_attr('sensor.f1_driver_standings', 'driver_standings')[0]['givenName']}}

It's not working, I'm getting this in my logs

Logger: homeassistant.helpers.template
Source: helpers/template.py:2917
First occurred: 14:02:52 (1 occurrences)
Last logged: 14:02:52

Template variable warning: 'dict object' has no attribute 'givenName' when rendering '** ** ** ** **F1 Race is starting in 30 minutes!** ** ** Season: {{state_attr('sensor.f1_next_race','season')}} ** ** Round: {{state_attr('sensor.f1_next_race', 'round') }} ** ** Circuit: {{state_attr('sensor.f1_next_race','circuit_name')}} {{state_attr('sensor.f1_next_race','circuit_url')}} ** ** Country: {{state_attr('sensor.f1_next_race','circuit_country')}} ** ** **Top 3** ** ** 1. {{state_attr('sensor.f1_driver_standings','driver_standings')[0]['givenName']}}'
flint sluice
#

The way to do this is to go to the template editor in developer tools -> template, and then you can try different things to make sure it is working. The best way to get help would be to put {{ state_attr('sensor.f1_driver_standings', 'driver_standings') }} in the editor and then copy the results and paste them in #1284966664357810196 to ask for help.

#

It’s hard to figure out what is going on from an image, but I think all the content is a dict under the driver key

#

So maybe this:

{{state_attr('sensor.f1_driver_standings', 'driver_standings')[0]['Driver']['givenName']}}

@tulip moth