Emulating sunsets and sunrises with Tasker and Yeelight

From Dusk till Dawn.

It’s getting darker and gloomier here in the northern hemisphere, especially in the UK where the natural light is out past 6 pm. Since these conditions are not going to improve anytime soon (until Spring) let’s use Tasker and Yeelight to emulate the Sunset and Sunrise on demand. Sounds like a good plan! If you want to know more about the Yeelight Smart RGB bulb check out this post. I’ll show you how to trigger an artificial sunset when the phone is flipped upside-down and how to create an alarm, that will gradually enable lights in your room.

Support NotEnoughTech
Buy Yeelight RGB LED bulb 

Tasker and Yeelight Sunset and Sunrise behaviour

To save myself a hassle I’m using Twilight plugin, which tells Tasker if it’s a day or night. I wrote about the plugin earlier on here. Go check it out if you want to know more. I have a night and a day trigger which set the variable %Sunlight to the corresponding values. I’m going to use these to control the Tasker and Yeelight triggers.Tasker and Yeelight

Twilight Sunrise/Sunset


Tasker and YeelightSince Yeelight app comes with pretty neat presets, we can use it to create the Sunset behaviour. The preset last 15 min and goes from warm orange/red through dim colours to a complete blackout.


If you want to extend/shorten the artificial sunset you can use the app to create a couple colour presets and mix it in Tasker using a combination of wait and brightness actions.

In my scenario, I used the WiFi information and value of %Sunlight to prevent the Yeelight smart bulb from switching the sunset mode accidentally. Feel free to assign another trigger or a voice command.


Tasker and YeelightSunrise behaviour is best combined with a set alarm. In my scenario, I turn on the light 5 min before the alarm would go off. The light stays dim at first, then changes colour and brightness over next 15 min until it reaches the full intensity.

Tasker and Yeelight alarm

I used AutoTools to get the proper time picker dialog. If you rather create a scene, feel free to do so. You could also link this to a voice command. Whatever suits you, it’s great as long as you get the time in the 15:43 format.


The time set via AutoTools is available in seconds,  we can use it directly to assign the values of %Sunrise1 and %Sunrise2 (we need this to create the time context and bypass the time issues).


To set the alarm, however, we will need the hours and minutes provided to us separately. We can split the existing variable %atdatetime1 with “:” as shown in A4. Once this is done, we have %atdatetime11 for hours and %atdatetime12 for minutes.

Sunrise Profile

It’s time (no pun intended) to set the context and trigger the Yeelight. The action is simple, pick the Yeelight action set the scene to Sunrise.  As per context, use time, and assign %Sunrise1 and %Sunrise2. 



As you can see Tasker and Yeelight are almost a match made in heaven. The light looks great when you go to sleep, and hopefully, will reduce some stress of getting up early. I have passed the feedback to the Yeelight in regards to support for Tasker variables. It would be nice to have the brightness, colour and scenes accessible with the variables.

Price: Free+
Price: Free
Support NotEnoughTech
A lot of time and effort goes into keeping NotEnoughTech alive! If my work helped you out, consider buying me a coffee or check out exclusive rewards available to Patreon supporters.