r/tasker • • 27d ago

Tasker profile/task combination for periodically firing off a task when device is asleep?

I'm using Tasker version 6.7.9 under rooted Android 13. Can anyone suggest the most efficient and effective way to code the following logic in Tasker? ... probably a combination of one or more profiles and tasks.

whenever device has been asleep for X seconds
then
    invoke task named Y
    put the device back to sleep
endif

... where "X" and "Y" are configurable parameters. And my assumption is that the device will "wake up" when task "Y" is invoked. However, if that assumption is not correct, then preceding the "invoke task named Y" operation, I would also want there to be some sort of "wake up device" operation.

UPDATE: And I'm perfectly happy with the possibility that one or more "Code=>Run Shell" actions also might be used as part of the implementation of this logic.

0 Upvotes

12 comments sorted by

3

u/bliblabl812 27d ago

Define device asleep.

1

u/unselective-amnesia 26d ago edited 26d ago

By "asleep", I mean that the screen has gone blank and that I need to unlock the display after I cause the screen to re-appear.

2

u/bliblabl812 26d ago

Add the timestamp on Display off to %TIMES and store it in a variable. Then set a profile with time context to this variable, and then start your task y.

3

u/Exciting-Compote5680 26d ago

There is a 'Device Idle' state context you could try. But I can't help but think this might be one of those 'XY problem' cases.

1

u/unselective-amnesia 26d ago edited 26d ago

Thank you very much about pointing out "Device Idle". I'll explore that profile now.

And this is absolutely not an "XY" case. I specifically want to implement the EXACT (!!!) profile/task combination that I described in my initial message of this thread. I do not want to get into any discussions or debates or arguments about why I want to do this, nor to be told that I should try to accomplish something different from what I specifically have asked about.

This is a purely technical question concerning how to utilize Tasker and perhaps one or more auxililary shell scripts that are called by Tasker to accomplish what I have described in my initial message here. My reasons for wanting this are totally irrelevant.

Thank you very much.

2

u/DifficultyCrafty7623 27d ago

define wake up.

1

u/unselective-amnesia 26d ago

By "wake up", I mean that the screen is now visible and all user interaction is available.

1

u/DifficultyCrafty7623 26d ago

Yes an unlock is possible. The way I do it is using Turn On > AutoInput for the swipe/keypad/enter buttons, which gives me the phone unlocked.

1

u/sasreedit S22, GW5P 26d ago

I second the prev questions, tho I also wonder what is waking your phone? I think it would be best to figure out what's causing the 'wake' first before providing a bandaid?

1

u/unselective-amnesia 26d ago

I am not concerned about what is causing any "wake". I only mentioned waking because I want to make sure that when this desired profile/task combination launches the "Y" application after "X" seconds of the device having been "asleep" (as I have now defined the term "asleep" above), that the application appears on a non-blanked-out screen and is totally accessible.

If the launched application will indeed appear this way on a non-blanked out and accessible screen, then no explicit "waking" would be necessary.

1

u/nednednerb 26d ago

I think more relevant your use case is making sure the apps and processes involved in your tasks are not actively suppressed into "background tasks" and then terminated entirely, and also, not delayed by any "battery optimization".

Ultimately, though, first I'd create a profile based on Dispaly Off + regular time interval, and then just test if you have issues with your tasks. If something does not run all the time, then something is likely killing it \ pushing it out of memory.

1

u/unselective-amnesia 26d ago

Thank you. I forgot about "Display Off". I'll explore that now in detail.