Automate Sleep with Tasker or Automate

What is Tasker / Automate?

Tasker is a total automatization tool for Android. You can catch events that happen on your phone (e.g. alarm has been dismissed) and trigger actions (e.g. send someone SMS that you’re awake). You can choose from many events and actions, but to add them for 3rd party apps, there has to be a plugin that connects the app to Tasker.

Sleep as Android has a Tasker plugin integrated in itself, for free!

Automate is a very similar app that uses the same pipeline as Tasker, so we support it too! Automate is different in that you set up your rules using graphical diagrams.


Tasker setup to create a profile using Sleep events:
Start Tasker > Profile > (+) button > (give a name to your profile) > Event > Plugin > Sleep > Configuration (pencil) > [your chosen event] > 2x Back > Select the task that should be run when the event happens

You can use any of these events from Sleep as Android and link them to any actions on your phone:

  • Sleep tracking started
  • Sleep tracking stopped
  • Sleep tracking paused
  • Sleep tracking resumed
  • Snooze (alarm)
    • the user has snoozed a ringing alarm
  • Bedtime
    • the bedtime has just occured
  • Alarm started
  • Dismiss (alarm)
    • the user has dismissed a ringing alarm AND solved the CAPTCHA if present
    • this event will also be fired when alarm has been dismissed while snoozed
  • Snooze canceled
    • alarm has been dismissed while snoozed
  • ~REM
    • the REM phase has been detected. More on REM phase detection here.
  • Audio recognition
    • Sleep as Android has detected one of the supported sounds: snoring, talk, coughing, laughter, baby crying. The maximum frequency of the event is once per 30s. Audio recognition has to be active for this event to work.
  • Anti-Snoring
    • Sleep as Android has detected snoring and executed an anti-snoring action (vibration or tongue click or both). Anti-snoring has to be active for this event to work.
  • Smart period
    • fires 45 minutes before smart period starts (to gather data for the smart period)


Tasker setup to create a task using Sleep actions:
Start Tasker > Tasks > (+) button > (give a name to your task) > (+) button > Plugin > Sleep > Configuration (pencil) > [your chosen task] > 3x Back

You can take any events given by your phone and trigger Sleep actions with them. Sleep provides these actions:

  • Start sleep tracking
  • Start sleep tracking: Save battery (no graph, just time)
  • Stop Sleep tracking
  • Snooze (alarm)
  • Dismiss (alarm)
  • Play lullaby
  • Stop lullaby
  • Sleep tracking: ideal sleep time
    • to create a new alarm for an ideal sleep time (with alarm default settings) and start sleep tracking immediately

You can also add new alarm with System > Set Alarm action.

Tasker walkthroughs

Create an “Add alarm” widget with Tasker

Sleep as Android does not offer a widget to add an alarm directly.

How to create one in Tasker?

  1. Fire up Tasker, go to Tasks tab and add a new task (+) named Add alarm
  2. Tap + to add an action, select System > Send Intent
  3. In action, insert com.urbandroid.sleep.alarmclock.SetAlarm
  4. As package, set com.urbandroid.sleep
  5. As target, select Activity
  6. Go back to confirm
  7. Add an icon in the lower right corner
  8. Long press on your desktop and add a Shortcut > Task shortcut and select Add alarm (your new task)
  9. Don’t forget to enable Tasker!

Integrate Sleep with hueManic

You can use any of the Sleep as Android’s events in Tasker to start a service com.urbandroid.hue/.ProgramService with following extras:
to start a program
to stop a program.
EXTRA_PROGRAM needs to have one of the values:

See video tutorial here.

Tasker > Task > Add task > Choose a name > Plus button > System > Send intent

Package: com.urbandroid.hue
Class: com.urbandroid.hue.ProgramService
Extra: EXTRA_START:start
Target: Service

Tasker > Profile > Plus button > Event > Plugin > Sleep > Configuration > Alarm started > Back > Back > Choose your task
Now make sure Tasker is enabled, hueManic installed and the Disco program will start on your alarm.
Adapt the specific conditions to your needs.

MiBand : Get notification when alarm starts

How to have your Mi Band notify you with LED / Vibrations when your alarm ( Sleep as Android ) goes off.. ( Using Mi Band Tools )

  1. Tasker > Profile > Plus button > Event -> Plugin > Sleep > Configuration > Alarm Started.
  2. Create a task for this event.. Notify -> Select any title like ‘AlarmStarted’ which will send a notification in your status bar when alarm is triggered.
  3. Open Mi Band tools and set an alert for Tasker application and filter with the title used earlier, ‘AlarmStarted’ .

Many thanks to Pratik Jain!

Start sleep tracking at a fixed time automatically every day

Sleep as Android does not have automatic sleep tracking start, but you can easily implement that yourself using Tasker!

  1. Start Tasker and create a new profile using the plus button on Profiles tab > Time > Set From and To time to the same time (e.g. 10PM). Hit back.
  2. Select New task and give it a name. Add an action using the plus button > Plugin > Sleep > tap on the pencil button > select Start sleep tracking.
  3. Hit back three times. Make sure to activate Tasker (long press in the upper left corner > Enable)

Automate walkthroughs

Start sleep tracking with Automate

Download the flow here:
Thanks to Percherie!