Using Logic Operators in Tasker

Tasker implements lots of different logic. One such instance are Logic Operators, specifically the AND Operator (&&) and OR Operator (||). We will start with the AND Operator, which will succeed if separate conditions are met simultaneously. For example, lets say we want to close Relay Output 3, but only if Relay Outputs 1 AND 2 are closed. To create this logic in Tasker, we’ll create an empty Task and add an If Statement to it, followed by adding a Close Relay 3 action inside the If Statement. Here we’ll enter the following:

rout[1].state == 1 && rout[2].state ==1

This statement evaluates as “If Relay Output 1 AND Relay Output 2 are closed, then close Relay Output 3”. Now if Relay Outputs 1 and 2 were closed when this Task runs, it will pass the If Statement condition and close Output 3.

&& goes between the two conditions that both need to be met

Next is the OR Operator which is less strict then the AND Operator, as its condition succeeds when at least one of multiple conditions are met. Lets use a similar example as before where we want to close Relay Output 3, but this time if EITHER Relay Outputs 1 and 2 are closed. We’ll do the same thing we did for the AND Operator by creating an empty task and adding an If Statement to it along with a Close Relay 3 action inside the If Statement. Here we’ll enter the following:

rout[1].state == 1 || rout[2].state ==1

This statement evaluates as “If either Relay Output 1 or Relay Output 2 are on, then close Relay Output 3”.

|| goes between the conditions where only one of them needs to be met

Lastly, a more advanced example can use both Operators in a logic statement at once. For example, lets say we want close Relay Output 3 if Relay Outputs 1 AND 2 are closer, OR if the time of day is past 2:00pm. We’ll add another if statement in an empty Task and add a Close Relay 4 action inside of it. Here we’ll enter the following:

(rout[1].state == 1 && rout[2].state == 1) || time.isAfter(“14:00”)

This statement evaluates as “If either Relay Output 1 and Relay Output 2 are on, or the current time is past 2:00pm, close Relay Output 3”.

() goes around the “rout[1].state == 1 && rout[2].state == 1” to group them together separately from the time function
By | Updated On November 3, 2023 2:07 pm | No Comments | Categories: | Tags: ,


INTEG Process Group, inc. © 2024

Real-Time
Mon - Fri, 8am - 4pm EST
P: 724-933-9350
PureChat
Always Available
Contact Form
sales@integpg.com
support@integpg.com

@integpg
@jniordev
4383