A mix of Wait, Variable Search and If-Else should suffice here.
Tasker maintains a variable named Profiles Active, denoted by %PACTIVE
.
Profiles Active (dynamic)
%PACTIVE
A comma-separated list of the currently active, named profiles in activation order. Duplicate names will appear on the list only once. The list always starts and ends with a comma to make matching easier, if it's not empty.
(Emphasis mine)
You can use Wait action to wait for N amount of time and then check whether your profile is active or not. If not active, exit out of the task, else, continue.
You may begin your task with these actions:
- Task → Wait → configure it
Variables → Variable Set:
- Name:
%ActiveProfiles
- To:
%PACTIVE
Variables → Variable Search Replace:
- Variable:
%ActiveProfiles
- Search:
,PROFILE_NAME,
- tick Ignore Case
- Store Matches In:
%CurrentProfile
Replace PROFILE_NAME
with the name of your profile. A profile's name must be setup manually.
- Task → If:
%CurrentProfile1
Isn't Set
Task → Stop
Alternatively, put any action that notifies you that the profile deactivated in the mean time.
- Task → Else
- Setup the actions you want be executed if the profile remains active after N amount of time.