Sunday, October 22, 2017

Wake up Gently with the Yeelight Smart RGB LED Bulb and Tasker

It’s getting darker and gloomier here in the northern hemisphere, especially in the United Kingdom where natural light is out past 6 PM. Since these conditions are not going to improve anytime soon (at least not until Spring), let’s use Tasker and the Yeelight Smart RGB LED bulb to emulate a sunset and a sunrise on demand.

Sounds like a good plan! If you want to know more about the Yeelight Smart RGB bulb check out this post. In short, this WiFi light comes with Tasker integration, so there is no need for hacks. It supports Amazon Alexa and Google Assistant too! 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 the lights in your room.


Tasker and Yeelight Sunset and Sunrise behavior

Yeelight (Free, Google Play) →

AutoTools (Free+, Google Play) →

Locale/Tasker Twilight Plug-in (Free, Google Play) →

To save myself some hassle I’m using the Twilight app for its Tasker plugin which tells Tasker if it is day or night. I have a night and day trigger which sets the variable %Sunlight to the corresponding values. I’m going to use these to control the Tasker and Yeelight triggers.Tasker and Yeelight

 

TASKER PROFILE 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 behavior. The preset lasts 15 min and goes from warm orange/red through dim colors to finally 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 ] 

Tasker and YeelightIf 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 YeelightSunrise behavior is best combined with a set alarm. In my scenario, I turn on the light 5 minutes before the alarm would go off. The light stays dim at first, then changes color and brightness over next 15 minutes until it reaches the full intensity.

Tasker and Yeelight alarm

I used AutoTools to get the proper time picker dialog. If you would 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 and Yeelight

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 ] 

 

Tasker and Yeelight

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 any 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

Tasker and YeelightIt’s time (no pun intended) to set the context and trigger the Yeelight. The action is simple, pick the Yeelight action and 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 and Download

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 it will reduce some stress of getting up early. I have passed on feedback to the Yeelight team in regards to support for Tasker variables. It would be nice to have the brightness, color, and scenes accessible with the variables.

Download the Tasker Yeelight Gently Wake Project

Download the above ZIP file and extract the contents onto the internal storage of your Android device. Open up Tasker and disable “Beginner Mode” in Preferences. Then, go back to Tasker’s main page and long-press on the home icon in the bottom left corner. You will see an option to “import” a project. Tap that option then find the .prj.xml file you extracted earlier. Once imported, you will see a new tab at the bottom alongside the default home icon in Tasker. This contains the profiles and tasks of this helper project.

Follow the XDA-Developers Tutorials feed for more posts such as this. Also, check out our Tasker Tips & Tricks forum for the latest creations among the automation enthusiasts in our community.

HostGator Web Hosting

0 comments:

Post a Comment