-
-
Save JoppeDC/7356c969513e411ab9892d08787a8cd5 to your computer and use it in GitHub Desktop.
| alias: F1 Lamp - Sync With Race Flags | |
| description: "Sync the lamp with the flags" | |
| triggers: | |
| - entity_id: | |
| - sensor.f1_track_status | |
| - sensor.f1_current_session | |
| - binary_sensor.f1_safety_car | |
| trigger: state | |
| actions: | |
| - data: | |
| name: F1 Lamp Debug | |
| message: > | |
| session={{ current_session }}, track={{ track_status }}, active={{ | |
| session_active }}, sc={{ sc_active }} | |
| action: logbook.log | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ session_active and track_status == 'RED' }}" | |
| sequence: | |
| - target: | |
| entity_id: select.f1lamp_playlist | |
| data: | |
| option: "{{ playlist_red }}" | |
| action: select.select_option | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ session_active and sc_active }}" | |
| sequence: | |
| - target: | |
| entity_id: select.f1lamp_playlist | |
| data: | |
| option: "{{ playlist_sc }}" | |
| action: select.select_option | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ session_active and track_status == 'VSC' }}" | |
| sequence: | |
| - target: | |
| entity_id: select.f1lamp_playlist | |
| data: | |
| option: "{{ playlist_vsc }}" | |
| action: select.select_option | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ session_active and track_status == 'YELLOW' }}" | |
| sequence: | |
| - target: | |
| entity_id: select.f1lamp_playlist | |
| data: | |
| option: "{{ playlist_yellow }}" | |
| action: select.select_option | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ session_active and track_status == 'CLEAR' }}" | |
| sequence: | |
| - target: | |
| entity_id: select.f1lamp_playlist | |
| data: | |
| option: "{{ playlist_green_resume }}" | |
| action: select.select_option | |
| default: | |
| - target: | |
| entity_id: select.f1lamp_playlist | |
| data: | |
| option: "{{ playlist_idle }}" | |
| action: select.select_option | |
| mode: single | |
| variables: | |
| playlist_idle: IDLE | |
| playlist_yellow: YellowFlag | |
| playlist_sc: SC | |
| playlist_vsc: VSC | |
| playlist_red: RedFlag | |
| playlist_green_resume: GreenFlag | |
| playlist_finish: CHEQ | |
| track_status: "{{ states('sensor.f1_track_status') }}" | |
| current_session: "{{ states('sensor.f1_current_session') }}" | |
| session_active: | | |
| {{ current_session in [ | |
| 'Practice 1', 'Practice 2', 'Practice 3', | |
| 'Qualifying', 'Sprint Qualifying', 'Sprint', 'Race' | |
| ] }} | |
| sc_active: | | |
| {{ is_state('binary_sensor.f1_safety_car', 'on') | |
| or track_status == 'SC' }} |
Can you share the code for each playlist / Preset in WLED please. I can't work out which mode you use for the Safety Car flashing each segment
How do I import this to my HomeAssistant?
You need to open automations, create a new automation, select "Edit in YAML" (top right ...) and paste with the correct values for your WLED controller
how do I link this automation to my WLED light in home assistant?
how do I link this automation to my WLED light in home assistant?
I've now got this working. You need to create a new automation and add all the conditions and parameters. Here is a step by step guide that should help you - (the above script did not work for me)
- Navigate to Automations page
- click + Create Automation, new automation (top option)
- Under When, click + Add trigger
- Select Entity and State
- Add the 3 Entities that we need, Track Status, Session Status & Safety Car
Under Then do, click + Add action
- Select tab Blocks
- Select Choose
You are going to setup a lot of conditions by repeating these steps.
- Under Option 1
- Click + Add Condition
- Select Entity and State
- Select Entity Track Status and State RED
- Close
- Click + Add action
- Under Actions, select Select and Select
- Add target = WLED Controller Playlist or Preset (depends on you WLED setup - steps to follow)
- Select the available Playlist or Preset that is available
- Repeat for all Track Status: Red, Yellow, SC, VSC, CLEAR,
It should look something like this:
- Add a Default state, following steps above but for state IDLE
You can now test this under Developer > State. Change the Track Status to the available options and your WLED should now change
Hope this helps people.
WLED setup:
Open WLED and the correct lights or navigate to your URL for your controller:
You should have 3 Segments. Mine are setup like this:
You need to create Presets for each Track State:

You can paste these API Commands into each Preset if this helps and change the colour to whatever you want (I'm colour blind, so probably haven't selected the right colours for everyone)
CHEQ
{"on":true,"bri":255,"transition":7,"mainseg":1,"seg":[{"id":0,"start":0,"stop":10,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[255,255,255],[0,0,0],[0,0,0]],"fx":1,"sx":207,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":1,"start":10,"stop":20,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[255,255,255],[0,0,0],[0,0,0]],"fx":1,"sx":207,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":2,"start":20,"stop":30,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[255,255,255],[0,0,0],[0,0,0]],"fx":1,"sx":207,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0}]}
GreenFlag
{"on":true,"bri":255,"transition":7,"mainseg":2,"seg":[{"id":0,"start":0,"stop":10,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[8,255,0],[0,0,0],[8,255,0]],"fx":55,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":1,"start":10,"stop":20,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[8,255,0],[0,0,0],[8,255,0]],"fx":55,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":2,"start":20,"stop":23,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[8,255,0],[0,0,0],[8,255,0]],"fx":55,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0}]}
IDLE
{"on":true,"bri":255,"transition":7,"mainseg":1,"seg":[{"id":0,"start":0,"stop":10,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"col":[[255,200,0],[0,0,0],[0,0,0]],"fx":0,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":1,"start":10,"stop":20,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"col":[[255,200,0],[0,0,0],[0,0,0]],"fx":0,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":2,"start":20,"stop":30,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"col":[[255,200,0],[0,0,0],[0,0,0]],"fx":0,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0}]}
RedFlag
{"on":true,"bri":255,"transition":7,"mainseg":1,"seg":[{"id":0,"start":0,"stop":10,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[255,0,0],[0,0,0],[0,0,0]],"fx":0,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":1,"start":10,"stop":20,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[255,0,0],[0,0,0],[0,0,0]],"fx":0,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":2,"start":20,"stop":23,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[255,0,0],[0,0,0],[0,0,0]],"fx":0,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0}]}
SC
{"on":true,"bri":255,"transition":7,"mainseg":0,"seg":[{"id":0,"start":0,"stop":10,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[8,255,0],[0,0,0],[0,0,255]],"fx":1,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":false,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":1,"start":10,"stop":17,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[8,255,0],[0,0,0],[0,0,255]],"fx":1,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":false,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":2,"start":17,"stop":23,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[0,0,0],[8,255,0],[0,0,255]],"fx":1,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0}]}
VSC
{"on":true,"bri":255,"transition":7,"mainseg":1,"seg":[{"id":0,"start":0,"stop":10,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[8,255,0],[255,255,255],[254,252,255]],"fx":1,"sx":128,"ix":128,"pal":2,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":1,"start":10,"stop":20,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[8,255,0],[255,255,255],[254,252,255]],"fx":1,"sx":128,"ix":128,"pal":2,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":2,"start":20,"stop":30,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[8,255,0],[255,255,255],[254,252,255]],"fx":1,"sx":128,"ix":128,"pal":2,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0}]}
YellowFlag
{"on":true,"bri":255,"transition":7,"mainseg":1,"seg":[{"id":0,"start":0,"stop":10,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[8,255,0],[0,0,0],[0,0,0]],"fx":1,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":1,"start":10,"stop":20,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[8,255,0],[0,0,0],[0,0,0]],"fx":1,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},{"id":2,"start":20,"stop":30,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"n":"","col":[[8,255,0],[0,0,0],[0,0,0]],"fx":1,"sx":128,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0}]}
Here is a video on TikTok showing my setup and the lights working:
https://vm.tiktok.com/ZNRmKQVeL/
Hope this guide gets you up and running for the new session start
My HA code if anybody wants to copy it and adjust for their needs:
`alias: F1 WLED lamp
description: Sync the lamp with the flags
triggers:
- entity_id:
- sensor.track_status
- sensor.session_status
- binary_sensor.safety_car
trigger: state
actions:
- choose:
- conditions:
- condition: state
entity_id: sensor.track_status
state:- RED
sequence:
- RED
- action: select.select_option
target:
entity_id: select.wled_controller_playlist
data:
option: RedFlag
- condition: state
- conditions:
- condition: state
entity_id: sensor.track_status
state:- SC
sequence:
- SC
- action: select.select_option
target:
entity_id: select.wled_controller_playlist
data:
option: SC
- condition: state
- conditions:
- condition: state
entity_id: sensor.track_status
state:- VSC
sequence:
- VSC
- action: select.select_option
target:
entity_id: select.wled_controller_playlist
data:
option: VSC
- condition: state
- conditions:
- condition: state
entity_id: sensor.track_status
state:- YELLOW
sequence:
- YELLOW
- action: select.select_option
target:
entity_id: select.wled_controller_playlist
data:
option: YellowFlag
- condition: state
- conditions:
- condition: state
entity_id: sensor.track_status
state:- CLEAR
sequence:
- CLEAR
- action: select.select_option
target:
entity_id: select.wled_controller_playlist
data:
option: GreenFlag
default:
- condition: state
- action: select.select_option
target:
entity_id: select.wled_controller_playlist
data:
option: IDLE
mode: single
`
- conditions:
@Snapdragon-Darling
Thanks so much for this!! I worked through your guide and have it working!
I have a few questions;
When creating the automation I can't figure out how to add IDLE. Can you walk me through it in more detail? I tried manual editing YAML code also but apparently I still have a lot to learn.
My F1 Sensor doesn't have the Safety Car entity you show. It doesn't seem to have mattered as I don't think you used it?
I see in your code you chose WLED_Playlist rather than WLED_Preset? I don't think you created a playlist in your WLED? I chose preset and it works fine for me.
You created preset CHEQ, but you don't end up using it?
Lastly, you can backup your presets and playlist in WLED using backup found under configure. Makes it easy to restore or share. It is a json file.
Thanks again! Can't wait to show off during tonight's watch party.
One thing I really want to figure out is to maybe dedicate my last segment to indicate the current P1 driver.
If you don't see Safety Car, there is a bug in the latest release 4.0, you need to download the Beta version. But yes, I've stopped using it - just need to see if it still works during the race. If not I'll need to swap out the Entity State to Safety Car
Ah, didn't spotted that I hadn't used CHEQ - will need to add this to my Conditions
You can use either a Preset (easier) or a Playlist - You need a Preset for a Playlist to attach too - so just use Preset. I was showing a simple approach.
Not sure I understand what you mean to "indicate the current P1 driver"...
Enjoy your party.. I have loads of LEDs configured in HA, asked the wife if I can set these up to match too... not a chance... lol
If you don't see Safety Car, there is a bug in the latest release 4.0, you need to download the Beta version
I will look, I don’t see in your code that safety car is being used? Can you explain what functionality it is providing beyond akready getting SC and VSC from track status?
we need to check that SC in the Track Status works - if it does then we can ignore Safety Car entity
If you don't see Safety Car, there is a bug in the latest release 4.0, you need to download the Beta version. But yes, I've stopped using it - just need to see if it still works during the race. If not I'll need to swap out the Entity State to Safety Car Ah, didn't spotted that I hadn't used CHEQ - will need to add this to my Conditions
You can use either a Preset (easier) or a Playlist - You need a Preset for a Playlist to attach too - so just use Preset. I was showing a simple approach. Not sure I understand what you mean to "indicate the current P1 driver"...
Enjoy your party.. I have loads of LEDs configured in HA, asked the wife if I can set these up to match too... not a chance... lol
P1, so who ever is currently leading race, think there in an entity for top three or something.
For IDLE, this goes in to the Default Action at the bottom of the Then Do section:
For CHEQ, you need to use Session Status > Finished (I hope this is right)
So add that as default action at bottom of each option? Or is it its own option. Sorry, I’m just learning. This is pretty fun.
It's on its own if you look in the image
If you don't see Safety Car, there is a bug in the latest release 4.0, you need to download the Beta version. But yes, I've stopped using it - just need to see if it still works during the race. If not I'll need to swap out the Entity State to Safety Car Ah, didn't spotted that I hadn't used CHEQ - will need to add this to my Conditions
You can use either a Preset (easier) or a Playlist - You need a Preset for a Playlist to attach too - so just use Preset. I was showing a simple approach. Not sure I understand what you mean to "indicate the current P1 driver"...
Enjoy your party.. I have loads of LEDs configured in HA, asked the wife if I can set these up to match too... not a chance... lolP1, so who ever is currently leading race, think there in an entity for top three or something.
Did you ever figure this out? This is exactly what I want to do as well, have the 1-part of the logo indicate either P1 or P1-3. There is a seperate entity for P1, P2 and P3 I saw in the F1 Sensor docs, but I can't figure out how to add that to the automation
If you don't see Safety Car, there is a bug in the latest release 4.0, you need to download the Beta version. But yes, I've stopped using it - just need to see if it still works during the race. If not I'll need to swap out the Entity State to Safety Car Ah, didn't spotted that I hadn't used CHEQ - will need to add this to my Conditions
You can use either a Preset (easier) or a Playlist - You need a Preset for a Playlist to attach too - so just use Preset. I was showing a simple approach. Not sure I understand what you mean to "indicate the current P1 driver"...
Enjoy your party.. I have loads of LEDs configured in HA, asked the wife if I can set these up to match too... not a chance... lolP1, so who ever is currently leading race, think there in an entity for top three or something.
Did you ever figure this out? This is exactly what I want to do as well, have the 1-part of the logo indicate either P1 or P1-3. There is a seperate entity for P1, P2 and P3 I saw in the F1 Sensor docs, but I can't figure out how to add that to the automation
I ended up dedicating my F1 logo box to just race leader and I added lights behind TV for race status. Here is my code that changes logo to match P1. I have a preset for every driver on WLED named with first three of last names.





How do I import this to my HomeAssistant?