HomeTaskerEmulating sunsets and sunrises with Tasker and Yeelight

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.

Buy Yeelight RGB smart bulb

Buy it using these links to support NotEnoughTech.

Tasker and Yeelight Sunset and Sunrise behaviour

Tasker and Yeelight

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.

Twilight Sunrise/Sunset
Profile: Sunlight Day 
	State: Twilight [ Configuration:From SUNRISE to SUNSET at Device location. ]
Enter: Sunlight Operator+ 
	A1: Variable Set [ Name:%Sunlight To:day 
            Recurse Variables:Off Do Maths:Off Append:Off ] 
	
Profile: Sunlight Night 
	State: Twilight [ Configuration:From SUNSET to SUNRISE at Device location. ]
Enter: Sunlight Operator- 
	A1: Variable Set [ Name:%Sunlight To:night 
            Recurse Variables:Off Do Maths:Off Append:Off ]

Sunset

Tasker and Yeelight

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

TASKER PROFILE - Sunset
Profile: Sunset 
	State: Orientation [ Is:Face Down ]
	State: Wifi Connected [ SSID:FASTBERRY MAC:* IP:* Active:Yes ]
	State: Variable Value  [ %Sunlight ~ night ]
Enter: Sunset 
	A1: Yeelight Device [ Configuration:Device: lamp, Action: SCENE, Param: 70 Timeout (Seconds):0 ] 

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.

Sunrise

Tasker and Yeelight

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

TASKER TASK - Alarm
Alarm 
	A1: AutoTools Dialog [ Configuration:Dialog Type: Date And Time
		Pick Time: true
		Time Picker Title: Set alarm
		Format: HH:mm
		Date Format Separator: , Timeout (Seconds):60 ] 
	A2: Variable Set [ Name:%Sunrise1 To:%atdatetimeseconds-300 	
		Recurse Variables:Off Do Maths:On Append:Off ] 
	A3: Variable Set [ Name:%Sunrise2 To:%atdatetimeseconds-300 
		Recurse Variables:Off Do Maths:On Append:Off ] 
	A4: Variable Split [ Name:%atdatetime1 Splitter:: Delete Base:Off ] 
	A5: Set Alarm [ Hours:%atdatetime11 Minutes:%atdatetime12 
		Label:With lamp Sound: Vibrate:Default Confirm:Off ] 
A2,A3

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

A5

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. 

TASKER PROFILE - Sunrise
Profile: Sunrise 
	Time: From %Sunrise1 Till %Sunrise2
	State: Variable Value  [ %Sunlight ~ night ]
Enter: Sunrise 
	A1: Yeelight Device [ Configuration:Device: lamp, 
		Action: SCENE, Param: 68 Timeout (Seconds):0 ] 

Conclusion

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.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

7 awesome Bluetooth keyboard shortcuts for Android

0
7 unique Android shortcuts that you can add to any Bluetooth keyboard.

Smart overnight charging with Tasker

0
Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

0
It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

Charge Test – Tasker charger performance tool

0
Turning Tasker into productive tool for monitoring chargers

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

0
It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

0
Keep your Tasker tidy!

A better way to store Tasker credentials

0
The more clever way of managing credentials

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

0
Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

0
Who wants a piece of the pie (chart)?