I recently watched this video and thought it was a great idea to use an LED strip as a visual timer. In the video, Paul says that it took forever to set up. He also only has fixed timers, and it looks like it’s done via an Alexa routine. In this article, I’d like to show you how you can create a visual Alexa timer with Home Assistant and WLED.
I’m not a fan of Alexa routines, as I find that the possibilities are quite limited, so I wanted to be able to control everything directly in Home Assistant.
What you need for this is:
- Alexa Media Player Integration
- LEDs (LEDs must be individually controllable)*
- WLED Controller*
- Adapter*
- Aluminium profile with diffuser (optional)*
I am only focusing on the Home Assistant Automation part here. You can find instructions on how to set up WLED everywhere on YouTube.
My requirements were:
- Must be controllable via Alexa
- No predefined timers
- Completely controlled via Home Assistant
- The last 10 seconds should be displayed separately
- When the timer ends, an effect should be displayed
Preparations in Home Assistant
First, you need 5 helpers. So click on ‘Settings – Devices & Services – Helpers – Create Helper’ in Home Assistant and create 5x the helper ‘Numeric Value Input’.
1. Helper for the percentage
- Name: Timer Progress
- Minimum value: 0
- Maximum value: 100
- Step size 1
- Unit of measurement: %
2. Helper for remaining time
- Name: Timer Remaining
- Minimum value: 0
- Maximum value: 3600
- Increment: 1
- Unit of measurement: s
3. Helper for remaining time (minus 10 seconds – optional)
- Name: Timer Remaining Offset
- Minimum value: 0
- Maximum value: 3600
- Step size: 1
- Unit of measurement: s
4. Helper for total time
- Name: Timer Starter
- Minimum value: 0
- Maximum value: 3600
- Step size: 1
- Unit of measurement: s
5. Helper for number of LEDs
- Name: Timer LEDs
- Minimum value: 0
- Maximum value: 28 (enter the number of your LEDs here)
- Step size: 1
- Unit of measurement: s
I use the maximum value of 3600 seconds because I don’t usually set timers that are longer than an hour. If that’s the case for you, feel free to adjust the value.
Now open your trusted Home Assistant File Editor and add the following lines to the configuration.yaml file (Github)
Replace the IP in the URL with the IP of your WLED controller. If you do not have white LEDs, you can omit the last section. Save the file and restart Home Assistant.
Create a preset in WLED with a solid effect in any colour. Also create a preset with the effect you want to display when the timer has expired.
Home Assistant Automation for Alexa Timer
Now create a new automation. Start the automation when the entity sensor.echo_show_next_timer changes from the status ‘Unknown’ to any other status. In other words: as soon as the timer is started. Please note: sometimes it takes a few seconds for this to be triggered. This delay also affects the total duration set, but in my case it is not a problem.
These steps are performed in the automation:
- Set helper ‘Timer LEDs’ to 1 (you can also set it to 0, but I want to have one LED switched on as soon as the timer starts)
- Set helper ‘Timer Progress’ to 0
- Set numerical value ‘Red’ (this was generated from the code we copied into configuration.yaml) to 255 to get a red progress bar
- Set numerical value ‘Green’ to 0
- Set the numerical value ‘Blue’ to 0
- Select your preset defined above (this is necessary to deactivate any effects that may still be active)
- Send the information to WLED via REST command
- The total duration of the timer is written to the helper ‘Timer Starter’
- The LED bar is switched on
We repeat the following steps until the value ‘Timer Remaining Offset’ is less than 1, i.e. the time has expired:
- Convert the current value of the timer into seconds and set this value in the helper ‘Timer Remaining’.
- Calculate the value for ‘Timer Remaining Offset’ from this and write it in the helper (optional).
- Using the total time and the current value of the timer, calculate the current percentage value and how much time has already elapsed. Write these values in ‘Timer Remaining’ and ‘Timer Progress’.
- Calculate how many LEDs need to be switched on based on the percentage and the number of my LEDs.
- Wait 1 second.
- Send an API command to WLED to switch on the corresponding number of LEDs.
Automation “Last Seconds” (Optional)
My last 10 seconds should be displayed with a green stripe instead of a red stripe. To achieve this, the same steps are taken as in the automation above. The only difference is that the trigger is activated when the ‘Timer Remaining’ helper is below 11, i.e. when the last 10 seconds are running. In addition, the ‘Timer Starter’ helper is set to 10.
The repeating condition runs until the ‘Timer Progress’ helper is above 100, i.e. the timer has expired.
Automation “Timer Finished”
When the ‘Timer Remaining’ helper is below 1, meaning the timer has expired, the preset for the desired effect is started and switched off again after 5 seconds.
Here is a video showing what it looks like at the end
You can find the code for all 3 automations here:







