Auto Sleep Mode (with exceptions)



At night you do not want to be disturbed when you sleep. So when you plug in your phone to charge the battery, you disable the sound to prevent any disturbance, or turn off the internet connection to prevent to be awoken by some junk mail. Both situations are not ideal, when you have all sound off people who may wake you (like your girlfriend) can not reach you. When you just disable the internet connection you may still be called by a (drunken) friend when you turned in early. The Tasker profiles described here provide the solution.

When you plug in your charger at night the phone will enter silent mode. When an incoming call is received from a prespecified number, the sound is turned on for 5 minutes so that you hear the call, and if you miss it, any text messages followed by it.


There are two ways to set-up the profile:

  1. Import it
  2. Set up your profile using the provided instructions.


First download the following files: SleepMode.prf.xml and SleepModeEmergencyNumbers.prf.xml. Then import them into Tasker.

Do not forget to add the exceptions to the Sleep Mode Emergency Calls Phone Ringing Event under Caller.


  1. Go into Tasker and look at the 'Sleep mode emergency numbers' profile.
  2. Press the 'Phone ringing event' and select 'edit'.
  3. Click the magnifying class next to the text 'caller' and select 'Match against a single contact'. Now select the contact you want to exempt.
  4. Redo this last step to add all the contacts you want to exempt.
  5. Now press 'Done' and 'Apply' and it should work.

Do it yourself

Just follow the instructions. You can of course enter your own values if you want when setting the Context Power Source or the Context Time.

Create Profile "Sleep Mode"

Add Context Power
    Source: AC    //You can also set this to all when you
                  //charge your phone using USB.

Add Context Time
    From: 22:00
    To: 07:00
    Repeat: Off

Add Start Task
1.  Silent Mode
    Mode: On
2.  Variable Set
    Name: %SLEEPMODE
    To: 1

Add Exit Task
1.  Silent Mode
    Mode: Off
2.  Variable Clear
    Name: %SLEEPMODE

Now your phone will silence when you plug in the charger at night. Now you have to create the exceptions for the emergency numbers.

Create profile "Sleep Mode Emergency Calls"

Add Event Phone Ringing
    Caller Number: Add all the numbers you want to get through.
                   Follow the steps in under the Import section to do this.

Add Start Task
1.  If
    %SLEEPMODE = 1    // Make sure you use the Maths: Equals (=),
                      // and not the Matches (~) to compare. We are
                      // dealing with numbers here :P.
2.  Silent Mode
    Mode: Off
3.  Wait
    Minutes: 5
4.  Silent Mode
    Mode: On
    If: %SLEEPMODE = 1// Here, we check if SLEEPMODE = 1 again, since
                      // we do not want to set Silent Mode to on again 
                      // if you took the call.
5.  End If

This page was contributed by: theHolyCow

QUESTION: How would I add an app as an exception? Specifically my alarm clock…that's on my phone. :)

Possible Answer: Instead of entering into Silent Mode you can, instead, change the Ringer and Notification volume to 0. I would advise storing the existing values in a variable ("NightModeRingerVol" etc.) so that it can be appropriately restored in the morning. If you do this and leave the Alarm volume up then your alarm should sound correctly.

QUESTION: I imported both of these profiles, If I call from a favorite number it doesn't ring, but if I call right back it does ring, so it is disabling the silent mode, but doesn't ring on the first call, any ideas?

QUESTION: Is there a way to send a auto templated text message to all people who are not on the emergency call group?

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License