Skip to content

Instantly share code, notes, and snippets.

@JoppeDC
Created December 1, 2025 11:20
Show Gist options
  • Select an option

  • Save JoppeDC/7356c969513e411ab9892d08787a8cd5 to your computer and use it in GitHub Desktop.

Select an option

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' }}
@storbi81
Copy link
Copy Markdown

storbi81 commented Mar 3, 2026

How do I import this to my HomeAssistant?

@Snapdragon-Darling
Copy link
Copy Markdown

Snapdragon-Darling commented Mar 5, 2026

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

@Snapdragon-Darling
Copy link
Copy Markdown

Snapdragon-Darling commented Mar 5, 2026

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

@ctweber01
Copy link
Copy Markdown

how do I link this automation to my WLED light in home assistant?

@Snapdragon-Darling
Copy link
Copy Markdown

Snapdragon-Darling commented Mar 7, 2026

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)

  1. Navigate to Automations page
  2. click + Create Automation, new automation (top option)
  3. Under When, click + Add trigger
  4. Select Entity and State
  5. Add the 3 Entities that we need, Track Status, Session Status & Safety Car
image

Under Then do, click + Add action

  • Select tab Blocks
  • Select Choose

You are going to setup a lot of conditions by repeating these steps.

  1. Under Option 1
  2. Click + Add Condition
  3. Select Entity and State
  4. Select Entity Track Status and State RED
  5. Close
  6. Click + Add action
  7. Under Actions, select Select and Select
image
  1. Add target = WLED Controller Playlist or Preset (depends on you WLED setup - steps to follow)
  2. Select the available Playlist or Preset that is available
image
  1. Repeat for all Track Status: Red, Yellow, SC, VSC, CLEAR,

It should look something like this:

image
  1. 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.

@Snapdragon-Darling
Copy link
Copy Markdown

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:

image

You need to create Presets for each Track State:
image

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}]}

@Snapdragon-Darling
Copy link
Copy Markdown

Snapdragon-Darling commented Mar 7, 2026

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

@Snapdragon-Darling
Copy link
Copy Markdown

Snapdragon-Darling commented Mar 7, 2026

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:
      • action: select.select_option
        target:
        entity_id: select.wled_controller_playlist
        data:
        option: RedFlag
    • conditions:
      • condition: state
        entity_id: sensor.track_status
        state:
        • SC
          sequence:
      • action: select.select_option
        target:
        entity_id: select.wled_controller_playlist
        data:
        option: SC
    • conditions:
      • condition: state
        entity_id: sensor.track_status
        state:
        • VSC
          sequence:
      • action: select.select_option
        target:
        entity_id: select.wled_controller_playlist
        data:
        option: VSC
    • conditions:
      • condition: state
        entity_id: sensor.track_status
        state:
        • YELLOW
          sequence:
      • action: select.select_option
        target:
        entity_id: select.wled_controller_playlist
        data:
        option: YellowFlag
    • conditions:
      • condition: state
        entity_id: sensor.track_status
        state:
        • CLEAR
          sequence:
      • action: select.select_option
        target:
        entity_id: select.wled_controller_playlist
        data:
        option: GreenFlag
        default:
    • action: select.select_option
      target:
      entity_id: select.wled_controller_playlist
      data:
      option: IDLE
      mode: single
      `

@ctweber01
Copy link
Copy Markdown

@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.

@Snapdragon-Darling
Copy link
Copy Markdown

Snapdragon-Darling commented Mar 7, 2026

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

@ctweber01
Copy link
Copy Markdown

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?

@Snapdragon-Darling
Copy link
Copy Markdown

For IDLE, this goes in to the Default Action at the bottom of the Then Do section:

image

For CHEQ, you need to use Session Status > Finished (I hope this is right)

image

@Snapdragon-Darling
Copy link
Copy Markdown

we need to check that SC in the Track Status works - if it does then we can ignore Safety Car entity

@ctweber01
Copy link
Copy Markdown

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.

@ctweber01
Copy link
Copy Markdown

For IDLE, this goes in to the Default Action at the bottom of the Then Do section:

image For CHEQ, you need to use Session Status > Finished (I hope this is right) image

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.

@Snapdragon-Darling
Copy link
Copy Markdown

For IDLE, this goes in to the Default Action at the bottom of the Then Do section:
image
For CHEQ, you need to use Session Status > Finished (I hope this is right)
image

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

@jas-dec
Copy link
Copy Markdown

jas-dec commented Mar 28, 2026

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.

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

@ctweber01
Copy link
Copy Markdown

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.

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.
IMG_3107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment