HomeTaskerTasker - timers, how to do this correctly.

Tasker – timers, how to do this correctly.

Relax we have all the time we need

Yes, there is a Wait and Wait Until action available already, and you can get away using this for a while. Unlike before, these actions are no longer as CPU intensive as it’s used to be.  I will show you how to set up Tasker timers correctly. This way, you will be sure, that you take the most battery efficient approach possible. Interested? Read on!

If you have any issues with timer context not working for you please read this post.

Tasker timers, theory…

I write this as I was asked about how to terminate the incognito chrome browsing on mobile when the phone is no longer in use. Potentially, the person interested didn’t want to disclose their browsing habits. I get the lock screen arguments, but having such thing on is not always desired for many reasons. Motives apart I will use this, and turn off wifi if not connected to show you how to deal with timers correctly.

The idea is simple. I don’t want to start a timer. This may seem counter-intuitive at first but bear with me. The lowest CPU, and therefore battery condition are time-based. Your mobile is running a UNIX timer anyway, and we can hook up to it. Instead of telling Tasker to start counting till 300 (5min = 5 x 60sec=300)and perform an action, we can schedule an action to happen at the time which is 300sec away. This works as some sort of timer, can be easily canceled (unlike wait), changed or updated.

Tasker timers, practice…

These 2 profiles will show you how to deal with a tasker timer, how easy is to cancel it or update it. We will use AutoNotification (optional for timer routine alone) to give us short notification of what’s happening and intercept the incognito session in the 2nd profile. In 2 profiles I can contain all it takes to cancel, update or reschedule the timer. It is simple, and CPU efficient.

WI-FI OFF after 5 min if not connected

If you are not interested in any notifications for this profile the project looks very simple:

TASKER PROFILE: Turn OFF WiFi [spoiler]
Turn Off wifiSet The Timer
Profile: Turn Off wifi 
Time: From %WifiTimer Till %WifiTimer
Enter: Turn Off Wifi 
	A1: WiFi [ Set:Off ]
	A2: Variable Clear [ Name:%WifiTimer Pattern Matching:Off ]
Profile: Set The Timer 
State: Not Wifi Connected [ SSID:* MAC:* IP:* ]
Enter: Not Connected To Wifi
	A1: Variable Set [ Name:%WifiTimer To:℅TIMES+300 Do Maths:On Append:Off ]

Exit: Connected To Wifi
	A1: Variable Clear [ Name:%WifiTimer Pattern Matching:Off ]

If you wish to have timer giving you notifications, few additional steps are needed to create and discard the notifications as required.

TASKER PROFILE: Turn OFF WiFi - notifications [spoiler]
Turn Off wifiSet The Timer
Profile: Turn Off wifi
Time: From %WifiTimer Till %WifiTimer
Enter: Turn Off Wifi (41)
	A1: WiFi [ Set:Off ]
	A2: Variable Clear [ Name:%WifiTimer Pattern Matching:Off ]
	A3: AutoNotification Cancel [ Configuration:Id: 11
		Cancel All: false Timeout (Seconds):0 ]
Profile: Set The Timer
State: Not Wifi Connected [ SSID:* MAC:* IP:* ]
State: Variable Value [ %WIFI ~ on ]
Enter: Not Connected To Wifi (43)
	A1: Variable Set [ Name:%WifiTimer To:%TIMES+300 Do Maths:On Append:Off ]
	A2: Variable Convert [ Name:%WifiTimer Function:
            Seconds to Date Time Store Result In:%wifitermination ]
	A3: AutoNotification [ Configuration:Use HTML: false
	Title: WIFI will turn off shortly
	Text: I will turn off at %wifitermination
	Icon: android.resource:/hl_device_access_network_wifi
	Status Bar Icon: alerts_and_states_error
	Status Bar Text Size: 16
	Id: 11
	Is Group Summary: false
	Title Expanded: WIFI will turn off shortly
	Skip Picture Cache: false
	Text Expanded: I will turn off at%wifitermination
	Update Notification: false
	Only on Phone: false Timeout (Seconds):20 ]

Exit: Connected To Wifi (44)
	A1: Variable Clear [ Name:%WifiTimer Pattern Matching:Off ]
	A2: AutoNotification Cancel [ Configuration:Id: 11
	Cancel All: false Timeout (Seconds):0 ]

Close Chrome Incognito after 5 min if

Closing the chrome can be done in a similar manner. Root and AutoNotification are required for this to work correctly. We are going to kill the chrome app, as only incognito browsing sessions will perish, our other chrome tabs will load on next chrome launch. AutoNotification will be used to look for an incognito notification in one of our contexts, to make sure the chrome is only killed when incognito tabs are opened. There is no need for notifications really as profile will only work when the screen is off.

TASKER PROFILE: Close Chrome after 5 min [spoiler]
Set Chrome TimerClose Chrome
Profile: Set Chrome Timer
State: Display State [ Is:Off ]
State: AutoNotification Intercept [ Configuration:Event Behaviour: false
Persistency Type: Persistent Only
Has Reply Action: false
Notification Title: Chrome
Notification Text: Close all incognito tabs
Get All Fields : false
Get Internal Actions: false
Get Internal Actions Big: false ]
Enter: Set Chrome Timer
	A1: Variable Set [ Name:%ChromeTimer To:%TIMES+300 Do Maths:On Append:Off ]

Exit: Cancel Termination
	A1: Variable Clear [ Name:%ChromeTimer Pattern Matching:Off ]
Profile: Close Chrome
Time: From %ChromeTimer Till %ChromeTimer
Enter: Terminate Incognito
	A1: Run Shell [ Command:am force-stop com.android.chrome 
            Timeout (Seconds):0 Use Root:On 
            Store Output In: Store Errors In: Store Result In: ]
	A2: Variable Clear [ Name:%ChromeTimer Pattern Matching:Off ]

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How to wake on LAN computers and put it to sleep with Power Menu,...

0
How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

7 awesome Bluetooth keyboard shortcuts for Android

0
7 unique Android shortcuts that you can add to any Bluetooth keyboard.

Smart overnight charging with Tasker

0
Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

0
It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

0
It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

0
Keep your Tasker tidy!

A better way to store Tasker credentials

0
The more clever way of managing credentials

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

0
Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

0
Who wants a piece of the pie (chart)?