163

The ability to use OR in the context!

Creating profiles that basicly do the same thing can take up alot of space. So I would like a way to put a OR in the context. Such as wifi connected OR  Bluetooth connected do this or that.

Or maybe even something in the task such as a if statement have a OR statement. I know there kind of is but would like to have that option alone in Tasker.

19 replies

+1   .. an OR for the conditions in a profile would make things much easier then these 'workarounds' described here!

Why can't I build the simplest condition for a single Profile, like "(Day [M,T,W,T,F] AND Time 06:00) OR (DAY [S,S] AND Time 07:00)" to trigger the same Task, and I have to use two similar Profiles to do that?!..

With some clever chicanery it can be done by regex-matching a time/date variable. You'd have to understand Regex pretty thoroughly, but it is doable. Alternately, create a single profile that fires on the desired days from time-x to time-y, repeating every z-minutes. Within the task insert an if block that only runs when you have the desired combination of day and time.

Actually, I recommend that everyone have a single, anonymous profile that executes EVERY day, from 7:00 to 22:00, repeating every 60 minutes. Every morning (time=7), re-initialize all volumes (ring, msg, sys, media, alarm) and screen brightness to your desired preferences. Maybe change your ring tone for the day. Then day~=^[MTWF], time=8, one might wish to have the phone go vibrate or use a work-acceptable ringtone until t=12, etc, etc. All of this happens based on if-blocks. After these interval blocks, you can have an if hour::even/odd block to say, check your email every two hours. Then, at 22:00, activate do-not-disturb until the next morning. It's a really useful profile to have  

Thanks for your comments guys,

Although I'm a programmer myself, It's been a very short time since I've involved to Tasker (shame to me!). I used to do my automations using a similar application, but I needed the extra power of Tasker. Proved that several simple contexts have to be done the hard way!

SS

@iamwoodruff And with the same method I can do each OR? If not, why such advice?

Use this tip and you can use ORs in your conditions :) 

https://www.reddit.com/r/tasker/comments/di56he/howto_protip_use_variables_for_states/

Thanks João for the pro tips!

@Joao Dias, I understand your concept of using the Variable Value context. I have been using that for quite a while. The problem is with Global Variables that are not dynamic and monitored, like %BATT, %CALTITLE, %CALDESCR, %CALLOC, %SMSRF, %SMSRN, %SMSRB, %MMSRS, %SMSRD, %SMSRT and %TIME. They cannot be included in a Variable Value context.

There are also State contexts that do not have an equivalent Global Variable. I use these contexts BT Connected, Call, DIsplay State, Dreaming, Mobile Network, Power and Wifi Connected. Some of these will need multiple variables like Calendar and SMS.

I counted a total of 22 State Contexts with a single variable and 8 with multiple variables.

This doesn't include all of the plug-ins with state contexts. Not sure how you could create a Global Variable from a plug-in.

Yes we can use the variable Value context, I'm already using them to do OR/XOR. There are significant limits to this tip.

KW

It isn't implemented because it presumably doesn't justify the effort. If it had been straightforward it would have been done years ago.

Tasker has to monitor all inputs for changes, and there are mechanisms for prioritising what gets monitored that keep the resource usage down. I suspect this is the obstacle, not the relatively easy provision of the user interface for it.

I think Joāo would like to close this, but he's too polite.

@Karl Wood:  hear hear!

 what I meant was using your own created Global Variables for the states :) Not built-in ones.

For example, I could (and do) create a variable called %LunchTime which is set when it's lunch time and unset when it's not. Then I can use that variable anywhere I like including a "Variable State" condition.

This way, yes, you can even use plugin conditions to create Global Variables and then use those in states.

I realize it's not the most straight-forward approach but actually makes it much simpler to handle in the long run.

Adding to João's comment, I created a project which I use exclusively to control my own custom "Global variables". For instance, I have in this project a profile to determine if I'm at home, which the only action is to set the variable %ImHome to "true" or "false" based on my wifi connectivity. I have several profiles which work similarly by setting custom variables to "true" or "false" for each situation, like if my headset is connected (%HeadSet), if my living room lamp is on (%LivingRoomLamp), etc. I also have in this same profile, other global variables that store more complex information, as for instance, the current weather (%Weather can be "raining", "sunny", etc), current temperature, if its day or night, which app is currently opened in my phone, etc. Although it might seem less straightforward to work this way, with all these custom global variables, I can then create very complex profiles very simply, by just using the "Variable" state and operators (including OR, AND, Greater than, equals to, regex, etc). The other advantage is that it is easy to tweak multiple tasks that depend on common conditions. For example, let's say you have 10 tasks that should only work when you are at home, and for some reason, you had to change the name of your wifi network. In the normal way, you would need to change all 10 profiles to be triggered based on the new Wifi name. By using this "custom global variables" approach, all you need to do is change the profile that controls the variable %ImHome, and all your tasks that are triggered by this variable will work perfectly. 

You can create profiles like:

If I'm home, and it's night, and no one else is home, and I am watching youtube on my TV, then turn off the lights of the living room (assuming you have a smart lamp and a smartTV that can work with tasker through plugins). 

By simply creating a profile:

If %ImHome == true AND %IsNight == true AND %NoOneIsHome == true AND %TVContent == youtube, than trigger action "Turn living room lamp off". 

I can only advise everyone to work with tasker in this way. It was a big game-changer for me. 

Yep, exactly Gabriel! :) I like to only use "Set" and "Unset" conditions though, so it's easier to remember :P That way I don't have to remember individual words so it's easier to setup.

For example, instead of a %Weather variable I would have %Rainy, %Sunny, %Foggy, etc variables and would check if they are set or not.

Saves me from writing "true" and "false" all the time and from having to remember what values the variables can have. :)

I realize this is more a matter of taste though! The beauty of Tasker is that you can use it whatever way you want 😁

Joao, we're still waiting......

Me too! 

V

+1  will be great.

This is not that easy to implement :) That's why it hasn't been implemented yet...

R

Although I voted for it, I'm not sure that this is the first priority for Tasker

KW

People demanding this feature need to learn the basics of Boolean algebra, De Morgan,, sum of products, etc  

Using one profile per product would work.

João might then be able to facilitate editing the group of profiles.

SD

+1 for this feature, major limitation of this app! 

I'm hoping Joao will reconsider implementing this as our profiles would be a lot easier to configure. 

still patiently waiting for this! 🙂

SM

This is a much needed feature, right now to do this i need to create multiple profiles with different contexts. But the problem is when oneprofile is satisfied and the task is running there might be another context that would satisfy and que the task next to it while with this feature the task will run once when one context is satisfied and won't que for other contexts untill all the contexts are exited. 

Similar thing with XOR too. 

M

This always bothered me too.

I'd love to see this.

SM

This is game changer for profiles based on states context, while for events based profile it could tide up the mess of creating different profiles, but for states this would introduce new possibilities.

Sorry for the confusion and misunderstanding that I caused. What I really meant was to have all of the logical operators for combining Contexts within a Profile. I misused the word Profile.

While all of the logical operators are available in a single Context, it is currently only possible to join two or more Connects with an AND operator. Joai is correct that we can invert the logic in the Contexts to use an AND operator instead an OR operator.

However, that makes Tasker more difficult to use for the average person. We need to simplify things to make the app more accessible.

Yes! It would make it tidier and you wouldn't need 12 same profiles (I'm exaggerating I know). 

Any boolean logic expression can be written as

(a1 and b1 and ...) or (a2 and b2 and ...) or ...

The same expression can also be written as

(x1 or y1 or ...) and (x2 or y2 or ...) and ...

BUT, in order to be able to do this, there MUST be available the flexibility to negate and repeat and combine predicates arbitrarily. What you mention is the second form, where each group of or operations is a "context" and they are all anded in the "profile". For that to work for any possible expression, the contexts must be repeatable (e.g. repeat a time or day context in multiple contexts) and single contexts would need to be able to combine multiple types (a special context of contexts one level deep with ORs?) and finally allowing more than 4 contexts per profile would be necessary for all but the most mundane refactors.

Since you don't seem to understand the request, don't say No to. This is not about individual profiles, but about joining the 4 profiles with anything other than an AND

YES! 

MO

Are you talking with me? Ok, but it's not really what OP asked as you can read in the title "the ability to use OR in the context!". Your request is totally different. You want to use more than 3 profiles together using all logic operator AND/NAND/XOR/OR.....

MO

This proposal doesn't make any sense, if you want an "or" just create more than one profile with the same task. No need to add anything to Tasker.

VM

Makes sense!

We wan't have 1000 Profiles.

AJ

Creating copies isn't an efficient way to program. It also isn't the same as an OR if you want to start a task only once by the first or the second condition. If you use a copy the task will start by the first condition and start again with the second condition regardless of whether the task is already running. 

X

Your post doesn't have any sense. All profile manager support AND/OR/XOR etc. 

Look at what Jim Becker said. 

MO

1000 profiles? Come on we need to be serious, if you want to join two profiles in or you just need 2 profiles and 1 task, if you want to sort your profiles/tasks you can use different projects. No copies at all since you can use ***exactly*** the same task with more than one profile, so no copies and no problems about task scheduling.

All profile manager support AND/OR/XOR? Guess what! Tasker too.

I read what Jim Becker said and it makes sense but it's a different proposal. The OP is asking for inclusive OR, nothing more.

As a workaround you invert all profile conditions and then set the task you want to run in the profile's exit task. :)

That only works to get an OR. And it loses the ability to have a real Exit task. How about including OR, XOR and all of the higher precedence versions.

Hope that your comment doesn't mean No. :-)

I'm waiting for this so much! 

CD

I was recently directed to this forum to make my suggestion when I found there already was one that just needed an up vote. So hopefully the most requested features is part of the project forecast. He obviously needs to consider feasibility and effort required to implement well. So hopefully it is being considered as this is one of the top 5 requested features and may be an easier request than others in the list.

W

Has the Dev indicated this may be happening?

Great idea. My only request is to have all the condition operators, AND, OR, XOR and the higher precedence versions.

X

It would be great!

love this! can't understand why wasn't it implemented from the start! :-)