Quick Tasker tip: Trigger a profile with any of several contexts

As most Tasker users will know, the relationship between contexts in multi-context profiles is that of AND, not OR. This means all contexts have to be fulfilled to trigger the profile, rather than just some of them. A recent thread in the Tasker section of Reddit talks about how to achieve the OR relationship instead, allowing a profile to be triggered with one of several contexts, and since the methods suggested there can cause some issues, I wanted to address this problem in a post.

It’s natural to think that the easiest way to have one of several contexts trigger a profile is to simply create several profiles that use the same tasks. That’s not necessarily the case. It might work if the contexts are mutually exclusive, so that one is never active when the other is, but if both can be active at the same time, you’ll might have some trouble. Depending on the task, you’d have two or more profiles changing and reverting the same settings independently of one another, potentially screwing up everything. If you for instance had a work profile that’s activated either based on meetings in your calendar or specific times, you’d risk that the time context reverted settings in the middle of a meeting.

The other method that’s suggested in the original thread (at the time of this writing) is to use the built-in variable %PACTIVE – which lists currently active profiles – to check for the other profile(s) at the beginning of a task. That’s a better solution, but still not without its issues. First off you’d need to cross reference every profile that’s part of the system so that they take all the others into account, which becomes more complicated the more profiles you have. Second, you’d still have multiple profiles doing the work that should be limited to only one to avoid interference with reverting settings and such. Bottom line though, the biggest problem is that it’s simply a complex solution to a simple problem.

So, how should you do it? Well, there are several ways of going about it. The one I think is the most straight forward is as follows:

First, create individual profiles for each of the contexts you want, e.g. time and calendar entry in the example above. Tie them to tasks that simply have a Wait action for a second or so in them- don’t really need a task at all, but Tasker needs one to function. Give the profiles names that are complex enough so that they’ll never be part of another profile’s name (e.g. “home” is a bad name if you have a profile called “home theater mode”). Finally, use this method to make the profiles invisible from the notification drop-down.


Next, create a new profile, and find the Variable Value context under State. Set it to %PACTIVE matches *profilename1*/*profilename2/*profilename3*/etc, where the profile names are the names of the profiles you created above. If you for instance made a profile called “OfficeTime” and “OfficeMeeting”, you would input *OfficeTime*/*OfficeMeeting* in the Value field, as shown in the screenshot. For the tasks connected to this context, put whatever you want the profile to actually do.

So how does this work? Well, when any of the dummy profiles are active, their name will be added to the %PACTIVE variable. By using wild cards (*) and OR operators (/) we can check that variable to see if any of the dummy profiles are active, and trigger our main profile based on that. In the example, Tasker understands “%PACTIVE matches *OfficeTime*/*OfficeMeeting*” as “if the list of active profiles contains any mention of OfficeTime or OfficeMeeting”.

This method allows you to have a single profile that actually performs the tasks you need, and just uses the other profiles as dummy profiles in order to separate the contexts. This means you won’t have interference problem, and you don’t need to cross reference the profiles with one another. You can add as many dummy profiles as you want, and all you need to do is add them to the value field in the context for the main profile.

tasker banner - for some reason we don't have an alt tag here

Pocketables does not accept targeted advertising, phony guest posts, paid reviews, etc. Help us keep this way with support on Patreon!
Become a patron at Patreon!

Andreas Ødegård

Andreas Ødegård is more interested in aftermarket (and user created) software and hardware than chasing the latest gadgets. His day job as a teacher keeps him interested in education tech and takes up most of his time.

Avatar of Andreas Ødegård