Sunday, May 12, 2013

[Tasker] Silent your phone after turning it face down for longer than 10 seconds


Amjan noticed (see comments below) that this task won't work if you have your "Proximity Sensor watching" not enabled in Tasker, therefore do the following before you start:
Press "menu key" while in Tasker -> "Preferences" -> "Monitor" tab -> Search for the label "Proximity Sensor" and select "Yes".

It is a very simple but also very effective Tasker profile is to silent your phone by turning it face down. Instead of turning it instantly into silent mode I want to show you a way to wait for a certain time before muting it. Therefore you reduce the chance to mute it by accident.

The trick is to create two Tasker profiles. The first one sets a global variable to 1 when the phone is turned face down and to 0 if its not in this state any more. The second profile is activated when the global variable is changed to 1. In the task the second profile launches there is a wait (f. e. 10 seconds) followed by a check if the global variable is still set to 1. If the check evaluates to true, then the phone is still in the face down state and it is turned silent.

Here is the complete code:

Profile: Display down

State: Orientation [ Is:Face Down ]
Enter: Display down on
A1: Variable Set [ Name:%SCRDWN To:1 Do Maths:Off Append:Off ]

Exit: Display down off
A1: Variable Set [ Name:%SCRDWN To:0 Do Maths:Off Append:Off ]
A2: If [ %TMPSILENT ~ 1 ]
A3: Silent Mode [ Mode:Off ]
A4: Variable Set [ Name:%TMPSILENT To:0 Do Maths:Off Append:Off ]
A5: End If

Profile: Turn silent

Event: Variable Set [ Variable:%SCRDWN Value:1 ]
Enter: Silent
A1: Wait [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ]
A2: If [ %SCRDWN ~ 1 ]
A3: If [ %SILENT ~ off ]
A4: Silent Mode [ Mode:On ]
A5: Variable Set [ Name:%TMPSILENT To:1 Do Maths:Off Append:Off ]
A6: End If
A7: End If 


  1. Thanks a lot for the code.
    I faced a problem in which my phone won't go through the profile unless it's plugged to the charger. Can you help me with it?

    I have an HTC one.

    1. You are right!!! You have to change the Tasker preferences to watch for orientation, when not connected to power. This is how to do it:

      Press "menu key" while in Tasker -> "Preferences" -> "Monitor" tab -> Search for the label "Proximity Sensor" and select "Yes".

      Now it should work! =D

  2. This comment has been removed by the author.

  3. Sorry. I'm a tasker luddiite. Can you step me through how to apply this code in Tasker (e.g., profiles, contexts, tasks, actions)?

  4. This comment has been removed by the author.

  5. I agree with Drew. There seems to be a missing link between your code listings and the Tasker user interface. For instance, I can create a Profile that sets a variable when the screen is down, but I don't see how to set up the exit task to unset it when the screen is not down.
    So: (1) how do I translate your listing into the actions I must perform on the Tasker user interface, and (2) how do I list a completed Profile in the form you are using? An answer would help enormously! I'm hoping there is a "cheat sheet" that I just haven't found.
    Thanks in advance -

  6. As of 4/2017 this code continues to run perfectly. I love having a "do not disturb" mode with the ease of simply setting the phone face down. Thank you very much for this Profile/Task combo.