Tasker – Smart sleep profile

Triggering the night profile only when you need it!

How do you sleep at night?

The unwritten rule of the household of mine is to keep your devices quiet once you get to bed. This would be a very simple profile, however:

  • I work nights
  • I don’t work your regular Monday to Friday
  • I’m not home during my workdays
  • Occasionally I stay up till late and home to work on stuff like this article and the tutorial

Tasker – Smart sleep profile allows above conditions to be included. I’m not sure how messed up is your sleep pattern and how much you need something like this. Sleep profile requires no plug-ins, or root, and shows you how to set this up for any circumstances. The profile can be improved with AutoNotification plug-in, however, for the sake of the beginners, I will keep it vanilla for now!

How does the Tasker sleep profile work?

I have a main profile to trigger silent times (or just disable WIFI and network up to your preferences). The profile is triggered by additional 2 profiles that are monitoring my location (HOME/NOTHOME) and whether I’m at work. Each day at 22:00 Tasker checks what’s going on and triggers the sleep profile in my project. At this stage, I get an hour warning message which allows me to cancel the sleep profile altogether, or postpone it.  While I’m away, Tasker skips the sleep profile when I’m at work, or gives me a notification only to enable the sleep now, cancel it for that night or,  set it in an hour.  If no action is taken the profile will won’t take any actions.

More detailed, written instructions are also available on pocketables.com so have a look if you want to read more, rather than watch the video.

Tasker sleep profile set up

Here is the profile description. Feel free to work with it or download the project file and edit it to your liking.

Warning At HomeSleep TimeWarning Outside
Profile: Warning At Home 
	Restore: no
	State: Variable Value [ %Home ~ 1 ]
	Time: 22:00
Enter: Enable Sleep 
	A1: Variable Set [ Name:%SleepTime To:23.00 
            Recurse Variables:Off Do Maths:Off Append:Off ] 
	A2: Profile Status [ Name:Sleep Time Set:On ] 
	A3: Notify [ Title:Sleep Profile Text:Profile will enable at 
            %SleepTime Icon:hd_ab_device_access_time Number:0 
            Permanent:Off Priority:3 Actions:(2) ]
Profile: Sleep Time 
	Restore: no
	Time: From %SleepTime Till 07:00
Enter: Sleep+ 
	A1: Flash [ Text:Sleep Long:On ] 
	A2: Notify Cancel [ Title:Sleep Profile Warn Not Exist:Off ] 
	A3: Notify [ Title:In Sleep Text:Your sleep mode is ON 
            Icon:hd_ab_aaa_ext_io Number:0 Permanent:Off 
            Priority:3 Actions:(1) ] 

Exit: Sleep- 
	A1: Flash [ Text:Wake up Long:On ] 
	A2: Perform Task [ Name:Cancel Priority:%priority 
            Parameter 1 (%par1): Parameter 2 (%par2): 
            Return Value Variable: Stop:Off ]
Profile: Warning Outside 
	Restore: no
	State: Variable Value [ %Home ~ 0 ]
	State: Variable Value [ %Work ~ 0 ]
	Time: 22:00
Enter: Enable Warning 
	A1: Notify [ Title:Sleep Profile 
            Text:Would you like to enable sleep? Icon:hd_aaa_ext_bulb 
            Number:0 Permanent:Off Priority:3 Actions:(3) ]