WLED Timer Progress Bar¶
This example demonstrates how to display timer progress on a WLED LED strip using Home Assistant automations. The LED strip acts as a visual progress indicator, lighting LEDs proportionally to the remaining time.
Overview¶
Artist's impression - actual display may vary based on your LED strip configuration.
- Active Timer: Green LEDs light proportionally to remaining time
- Paused Timer: Blue LEDs show the paused state
- Timer Finished: Pulsing red effect indicates alarm
- No Timer: LEDs turn off or show idle pattern
Prerequisites¶
- WLED device integrated with Home Assistant
- Timer entities configured (e.g.,
timer.kitchen) - Template sensor for timer progress (from the main installation)
Configuration¶
Home Assistant Automations¶
Add these automations to your Home Assistant configuration or create them through the UI.
Timer Progress Update Automation¶
This automation updates the WLED strip every second while a timer is running:
# file: home-assistant/automations/wled_timer_progress.yaml
# section: timer_progress_automation
automation:
- id: wled_timer_progress_update
alias: "WLED Timer Progress Update"
description: "Update WLED to show timer progress as LED fill"
mode: restart
trigger:
# Update every second when timer is active
- platform: time_pattern
seconds: "/1"
condition:
- condition: or
conditions:
- condition: state
entity_id: timer.kitchen
state: "active"
- condition: state
entity_id: timer.kitchen
state: "paused"
action:
- variables:
timer_entity: timer.kitchen
wled_entity: light.wled_kitchen_strip
total_leds: 30
timer_state: "{{ states(timer_entity) }}"
# Calculate remaining seconds
finish_time: "{{ state_attr(timer_entity, 'finishes_at') }}"
duration: "{{ state_attr(timer_entity, 'duration') | default('0:00:00') }}"
duration_seconds: >-
{% set parts = duration.split(':') %}
{{ (parts[0] | int) * 3600 + (parts[1] | int) * 60 + (parts[2] | int) }}
remaining_seconds: >-
{% if timer_state == 'active' and finish_time %}
{{ max(0, (as_timestamp(finish_time) - as_timestamp(now())) | int) }}
{% elif timer_state == 'paused' %}
{{ state_attr(timer_entity, 'remaining') | default('0:00:00') | regex_replace('^(\\d+):(\\d+):(\\d+)$', '\\1 * 3600 + \\2 * 60 + \\3') | int }}
{% else %}
0
{% endif %}
progress_percent: >-
{% if duration_seconds > 0 %}
{{ (remaining_seconds / duration_seconds * 100) | int }}
{% else %}
0
{% endif %}
leds_to_light: "{{ ((progress_percent / 100) * total_leds) | int }}"
# Set WLED segment effect based on timer state
- choose:
# Active timer - green progress fill
- conditions:
- condition: template
value_template: "{{ timer_state == 'active' }}"
sequence:
- service: wled.effect
target:
entity_id: "{{ wled_entity }}"
data:
effect: "Solid"
color: [0, 255, 0] # Green
intensity: 128
speed: 128
# Use segment to show progress
- service: light.turn_on
target:
entity_id: "{{ wled_entity }}"
data:
brightness: 200
effect: "Percent"
# Percent effect shows progress as filled LEDs
# Paused timer - blue progress fill
- conditions:
- condition: template
value_template: "{{ timer_state == 'paused' }}"
sequence:
- service: wled.effect
target:
entity_id: "{{ wled_entity }}"
data:
effect: "Solid"
color: [0, 100, 255] # Blue
intensity: "{{ leds_to_light * 255 // total_leds }}"
speed: 128
Timer Finished Automation¶
When the timer finishes, display a pulsing red alert:
# file: home-assistant/automations/wled_timer_progress.yaml
# section: timer_finished_automation
- id: wled_timer_finished_alert
alias: "WLED Timer Finished Alert"
description: "Flash WLED red when timer finishes"
mode: single
trigger:
- platform: state
entity_id: timer.kitchen
to: "idle"
from: "active"
action:
- service: wled.effect
target:
entity_id: light.wled_kitchen_strip
data:
effect: "Breathe"
color: [255, 0, 0] # Red
intensity: 255
speed: 200
# Stop after 30 seconds if not manually dismissed
- delay:
seconds: 30
- service: light.turn_off
target:
entity_id: light.wled_kitchen_strip
Timer Cancelled Automation¶
Return to normal state when timer is cancelled:
# file: home-assistant/automations/wled_timer_progress.yaml
# section: timer_cancelled_automation
- id: wled_timer_cancelled
alias: "WLED Timer Cancelled"
description: "Turn off WLED effect when timer is cancelled"
mode: single
trigger:
- platform: event
event_type: timer.cancelled
event_data:
entity_id: timer.kitchen
action:
- service: light.turn_off
target:
entity_id: light.wled_kitchen_strip
Alternative: Custom Effect with ESPHome WLED¶
For more precise control, you can create a custom WLED preset that reads the timer progress directly:
# file: home-assistant/automations/wled_timer_progress.yaml
# section: preset_automation
- id: wled_timer_set_preset
alias: "WLED Timer Set Preset Based on State"
description: "Switch WLED preset based on timer state"
mode: restart
trigger:
- platform: state
entity_id: sensor.kitchen_timer_remaining_seconds
attribute: timer_state
action:
- variables:
timer_state: "{{ state_attr('sensor.kitchen_timer_remaining_seconds', 'timer_state') }}"
- choose:
# Active timer - use progress preset (preset 1)
- conditions:
- condition: template
value_template: "{{ timer_state == 'active' }}"
sequence:
- service: select.select_option
target:
entity_id: select.wled_kitchen_strip_preset
data:
option: "Timer Progress"
# Paused timer - use paused preset (preset 2)
- conditions:
- condition: template
value_template: "{{ timer_state == 'paused' }}"
sequence:
- service: select.select_option
target:
entity_id: select.wled_kitchen_strip_preset
data:
option: "Timer Paused"
# Timer finished - use alert preset (preset 3)
- conditions:
- condition: template
value_template: "{{ timer_state == 'idle' }}"
sequence:
- service: select.select_option
target:
entity_id: select.wled_kitchen_strip_preset
data:
option: "Off"
WLED Presets Configuration¶
Create these presets directly in your WLED web interface:
Preset 1: Timer Progress (Green)¶
- Effect: Percent
- Color: Green (0, 255, 0)
- Speed: 128
- Intensity: Controlled by automation
Preset 2: Timer Paused (Blue)¶
- Effect: Solid
- Color: Blue (0, 100, 255)
- Speed: 0
- Intensity: 128
Preset 3: Timer Alert (Red Pulse)¶
- Effect: Breathe
- Color: Red (255, 0, 0)
- Speed: 200
- Intensity: 255
Advanced: Segment-Based Progress¶
For more visual appeal, use WLED segments to create a true progress bar effect:
# file: home-assistant/automations/wled_timer_progress.yaml
# section: segment_progress
- id: wled_timer_segment_progress
alias: "WLED Timer Segment Progress"
description: "Use WLED segments for precise progress display"
mode: restart
trigger:
- platform: time_pattern
seconds: "/1"
condition:
- condition: state
entity_id: timer.kitchen
state: "active"
action:
- variables:
total_leds: 30
progress: "{{ state_attr('sensor.kitchen_timer_remaining_seconds', 'progress_percent') | default(0) | float }}"
leds_lit: "{{ ((progress / 100) * total_leds) | int }}"
# Set segment 0 (lit portion) to green
- service: rest_command.wled_set_segment
data:
segment_id: 0
start: 0
stop: "{{ leds_lit }}"
color: [0, 255, 0]
effect: 0 # Solid
# Set segment 1 (unlit portion) to off
- service: rest_command.wled_set_segment
data:
segment_id: 1
start: "{{ leds_lit }}"
stop: "{{ total_leds }}"
color: [0, 0, 0]
effect: 0
Add this REST command to your Home Assistant configuration.yaml:
# file: home-assistant/configuration.yaml
# section: rest_command
rest_command:
wled_set_segment:
url: "http://wled-kitchen.local/json/state"
method: POST
content_type: "application/json"
payload: >-
{
"seg": [{
"id": {{ segment_id }},
"start": {{ start }},
"stop": {{ stop }},
"col": [{{ color }}],
"fx": {{ effect }}
}]
}
Multi-Area Support¶
To support multiple areas with separate WLED strips, create a script that accepts parameters:
# file: home-assistant/scripts/wled_timer_progress.yaml
# section: multi_area_script
script:
wled_update_timer_progress:
alias: "Update WLED Timer Progress"
description: "Update any WLED strip based on timer area"
mode: parallel
max: 5
fields:
area:
description: "The area name (e.g., kitchen, bedroom)"
required: true
selector:
text:
wled_entity:
description: "The WLED light entity"
required: true
selector:
entity:
domain: light
sequence:
- variables:
timer_entity: "timer.{{ area }}"
sensor_entity: "sensor.{{ area }}_timer_remaining_seconds"
timer_state: "{{ states(timer_entity) }}"
progress: "{{ state_attr(sensor_entity, 'progress_percent') | default(0) | float }}"
- choose:
- conditions:
- condition: template
value_template: "{{ timer_state == 'active' }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ wled_entity }}"
data:
brightness: "{{ (progress * 2.55) | int }}"
rgb_color: [0, 255, 0]
effect: "Solid"
- conditions:
- condition: template
value_template: "{{ timer_state == 'paused' }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ wled_entity }}"
data:
brightness: "{{ (progress * 2.55) | int }}"
rgb_color: [0, 100, 255]
effect: "Solid"
default:
- service: light.turn_off
target:
entity_id: "{{ wled_entity }}"
Then create automations for each area:
# file: home-assistant/automations/wled_timer_progress.yaml
# section: multi_area_automations
- id: wled_kitchen_timer_progress
alias: "WLED Kitchen Timer Progress"
trigger:
- platform: time_pattern
seconds: "/1"
condition:
- condition: or
conditions:
- condition: state
entity_id: timer.kitchen
state: "active"
- condition: state
entity_id: timer.kitchen
state: "paused"
action:
- service: script.wled_update_timer_progress
data:
area: kitchen
wled_entity: light.wled_kitchen_strip
- id: wled_bedroom_timer_progress
alias: "WLED Bedroom Timer Progress"
trigger:
- platform: time_pattern
seconds: "/1"
condition:
- condition: or
conditions:
- condition: state
entity_id: timer.bedroom
state: "active"
- condition: state
entity_id: timer.bedroom
state: "paused"
action:
- service: script.wled_update_timer_progress
data:
area: bedroom
wled_entity: light.wled_bedroom_strip
Testing¶
- Start a timer: "Set a 2 minute timer"
- Verify the WLED strip shows green LEDs proportional to remaining time
- Pause the timer: "Pause the timer"
- Verify the color changes to blue
- Resume and let the timer finish
- Verify the red pulsing alert effect activates
- Cancel the timer to verify cleanup
Tips¶
- Adjust
total_ledsto match your LED strip length - Use WLED's built-in "Percent" effect for smoother animations
- Consider adding a dimming schedule to reduce brightness at night
- The segment-based approach provides the most accurate visual representation