Lately I’ve gotten in the habit of listening to music via some bluetooth speakers before I fall asleep. I setup a very simple tasker profile that would turn the music off at a certain time but, really, that isn’t sufficient.
I don’t always go to bed at the same time and thus I don’t always want the music to turn off at the same time. Basically, I want the music to turn off thirty minutes after I get in bed. So, how can I get tasker to do that?
I’m pretty sure this is the last update I’m going to provide for this. I’ve settled on a single profile that starts when you launch the music app of your choice. The task that it fires off waits to do anything else until it is after 9:45pm. At which point it sets the future shut off time of 30 minutes. Thus, if i start my music every night before 9:45 my shut off time will always be around 10:15pm. The task then waits until that future time is passed then it shuts off the music app.
- create a task called “Sleep to Music”
- Create an Action to determine if it is late enough at night to do auto turn off the music.
- pick “task”
- pick “if”
- set the left side of the condition to %TIMES
- set the operator to maths: greater than
- set the right side of the condition to 21.59 for 9:59pm. It uses military time with a decimal instead of colons to represent time.
- finish
- Create an Action to determine if the music app is turned on.
- pick “task”
- pick “if”
- set the left side to %PlayMusicOn
- set the operator to maths: equals
- set the right side to 1
- finish
- Create an Action to define the 30 minute threshold
- pick “variables”
- pick “variables set”
- set name to “%ShutOffMusicTime”
- set to as %TIMES + (60*30) – 60 seconds, 30 minutes.. %TIMES is the number of seconds since some date in 1970 so we are computing 30 minutes worth of seconds beyond the current moment.
- check “Do Maths”
- finish
- Create an Action that will occassionally poll to see if the 30 minute threshold has been reached.
- pick “task”
- pick “wait”
- set the “seconds” to 10
- set the until (at the very bottom) values
- left side to %ShutOffMusicTime
- operator to maths: less than
- right side to %TIMES
- finish
- Create an Action to kill the music app
- pick “app”
- pick “kill app”
- pick your music app
- finish
- Create an Action to reset the 30 minute treshold
- pick “variables”
- pick “variables set”
- set name to “%ShutOffMusicTime”
- set to as 999999999 which represents some impossible time in the future..
- finish
- Create an Action to reset the music playing flat
- pick “variables”
- pick “variables set”
- set name to “%PlayMusicOn”
- set to 0 (zero) which indicates the music app isn’t running
- finish
- Create an Action to close out the first IF check
- pick “task”
- pick “End If”
- finish
- Create an Action to close out the second IF check
- pick “task”
- pick “End If”
- finish
- Create an Action to determine if it is late enough at night to do auto turn off the music.
- Create a new Profile
- pick “App”
- pick “your music app”
- Attach the “Start Music App” task
- Create a new Profile
- Select “Event”
- Select “Display”
- Select “Display Off”
- Attach the “Sleep to Music” task
Bada Bing, Bada Boom - the two tasks will work in harmony to turn off your music when you want it to. Customize it for your needs and hopefully you’ll fall asleep o the soothing sounds of your favorite music without worrying about it waking you up during the night.
This is the third version of this - the prior two wouldn’t work when the screen turned off and the phone went to sleep. Hopefully you’ll have good success converting this for your needs.