My name is Aaron Tinsley

An eclectic collection of thoughts and projects on a variety of (mostly) tech topics.

[Tasker Tidbit] Tasker Sleep Timer for Android

Learn how to create a Tasker sleep timer!

Above photo by JD Hancock / Foter / CC BY

Introduction

I have a confession to make.  I’m a huge nerd.  Sometimes when I lay in bed at night, I have a tough time falling asleep because I’m dreaming up a new project or thinking of ways to improve an existing one.  Music helps me to take my mind off of these things and fall asleep, but if it continues to play through the night my wife will wake up.  That’s where my Tasker Sleep Timer comes in.  I start my music, tap a button, and the music will play for an hour before pausing.

Prerequisities

This is a pretty easy one.  All you’ll need is the Tasker app!  Optionally, you can add a widget to your notification shade using the Power Toggles app.  See below picture for an example.

Tasker Sleep Timer widget
The Power Toggles app allows you to create your own custom widgets in your notification shade. The far right toggle is for my Tasker sleep timer. The one next to it toggles Lollipop’s Battery Saver mode.

Click here to learn how to create my custom toggle for Lollipop’s Battery Saver mode.

Tasker Sleep Timer

Creating a sleep timer in Tasker is actually pretty easy.  At its most basic, we can boil it down to just 2 actions.  I’ll first show you how to create the most basic task, and then expand on it.  The first action we need is a Wait action.  I set it to 1 hour.  That means 1 hour after you run the task, your music will pause.  Feel free to adjust it based on your preferences.

The second action we need is a Media Control action.  You can find it under Media > Media Control.  When configuring the Media Control action, you want your command to be set to “Pause”.  You also want to check the “Simulate Media Button” checkbox.  Well, that’s it!  You just created a basic Tasker Sleep Timer!

Tasker Sleep Timer Task
A basic sleep timer is incredibly easy to create! You could stop here and just put a shortcut to this task on your home screen. Tap it and your music stops an hour later!

Potential Improvements

You can use Power Toggles to create a shortcut to this task in your notification shade.  Launch Power Toggles, click on Notification, and then go to Customize.  Click “Add Toggle”.  Then go to the Custom tab and find “Task Shortcut”.  After that, just find your Sleep Timer task!  When you click on the toggle in your notification shade, the Sleep Timer task will run.

Another potential improvement to your Tasker sleep timer is to add a notification that the sleep timer has been set.  Find the Notify action underneath the Alert category when adding a new action.  Check out the below picture for an example!

Tasker Sleep Timer notification
Get creative with your sleep timer! You can add a notification, make the timer adjustable, or do whatever you’d like! That’s the beauty of Android and Tasker!

Well, that’s it for now!  This was just meant to give you a quick introduction on how to create your own Tasker sleep timer.  As for how to improve it, that’s up to you!  My sleep timer is fancier than what I’ve shown here, but this is a good start!

 

Leave a Reply

Your email address will not be published. Required fields are marked *