My Tasker Night Mode Profile For Android
If there are two things that irritate me the most when I go to sleep, they are: Sync notifications going off and battery drained off in the morning (worst case being drained off before alarm time, making me late for work). I used to have a simple profile that turned off auto sync between 11 PM to 7 AM but it didn’t always work well because I work past 11 quite a lot and don’t usually have a fixed sleep time. Similarly I get up at different times. Sometimes I’m not even home and still the profile runs, making me lose sync.
(For the impatient, if you want to use it, I’ve uploaded my profiles to my github account.)
So, I set up and quick and simple but much better working night mode profile. It consists 3 different profiles actually as listed below:
Night Mode -> This actually turns on the night mode based on a host of different combinations listed later in the post.
Alarm Detection -> Detects when the alarm goes off
Unlock Detection -> Detects when the phone display is unlocked.
Home Detection -> Detects if I’m at home
The basic premise behind this night mode setup is:
The phone should detect that I’m sleeping by taking a combination of following scenarios:
The location should be at home (Done by home detection profile using “Cell Near”. I use this mostly because it is more accurate than network location and works indoors as well which GPS doesn’t do and is very light on battery as well)
Time should be between 11 PM to 7 AM (my likely sleep time)
Display should not have been unlocked in the last 30 minutes (i.e. make sure I’m not actively using the phone)
It’s dark in the room (Make sure that lights are turned off. Need to turn on ambient light sensor to work with screen off in tasker settings for this)
Once all the above conditions are established, my phone is fairly certain by now that I’m indeed sleeping :) and turns off auto sync
The night mode still has to check whether the conditions still exist after every half hour or so (e.g. I might not be sleeping yet but lights turned off to allow my wife to sleep and I didn’t fiddle with the phone for some time)
If I unlock the phone any time at night, it should tell my phone immediately that I’m not sleeping and it deactivates the night mode (for the next 30 minutes or so when night mode check kicks in again)
When the alarm goes off, night mode should be stopped since I’m obviously awake now
There are quite a few other checks and balances incorporated to make sure all these 4 profiles don’t go out of sync and also do as less as possible to preserve battery.
Tested this setup for past few weeks and it works pretty well. If you want to use it, I’ve uploaded my profiles to my github account.
Improvements/Changes:
Exchange sync still bypasses the auto sync turn off settings. So need to either buy “Synker” to control exchange sync directly or figure out a way to connect droidwall to tasker to cut the internet connection for exchange app.
The home mode xml in the account does not have anything in cell tower locations ;), so you need to open it in tasker and scan for your own cell towers
I just turn off auto sync for me in night mode (want to receive sounds for other notifications, texts etc), you can edit the profile to suit your other needs
You can change the timings as well as per your needs
I have some prints done to a file in these profiles, mainly for debugging. You can remove those once you are certain the setup works well for you.
Let me know if you can think of any other ways to make this more robust. I’ll post the rest of my tasker profiles as well soon.