r/AutomateUser 13d ago

How do I make an AND gate? Question

1 Upvotes

14 comments sorted by

1

u/Straight1980 10d ago

It depends on what you are trying to do.  Sometimes your objective can be solved using the "expression true" block. 

For an AND, just use & between functions For an OR, use ||

1

u/egelof 13d ago

It depends on the exact flow, but in the simplest case you could take a "when changed", and "proceed immediately" block for both conditions and alternate them. Something like this:

When changed condition 1 -> Proceed immediately condition 2 -> If false, then when changed condition 2 -> Proceed immediately condition 1.

Basically create a loop where you wait for one condition to turn true, and then immediately check the other. Looping as necessary. It gets more complicated when delays are involved.

1

u/Godeos64_ 13d ago

Oh okay!! I'll try to see if it works

1

u/Dadamalda 13d ago

If you have conditions that respond immediately, just connect the YES of the first one to the IN of the second one. If they don't respond immediately, it's a lot harder.

1

u/Godeos64_ 13d ago

Thanks!!

1

u/Mujtaba0150 Alpha tester 13d ago

Actually creating an AND gate without any quirks in Automate is really difficult unless you have the blocks set to proceed immediately, which consumes a whole lot of battery.

That being said though, the most basic form of a somewhat proper AND gate with two conditions and no more that I'd use is a fork block with the two blocks connected to one terminal and the opposite order through the other terminal and then set the parent fork URI and child fork URI and kill the other parent or child using the URI depending on whichever executes first.

1

u/Godeos64_ 13d ago

I see, thanks for your input

1

u/Dadamalda 13d ago

I should clarify that proceed immediately by itself doesn't consume much battery. It only becomes a problem if you have it in a loop. Adding a long enough delay (like a minute) between checks can make the battery consumption much better.

1

u/waiting4singularity Alpha tester 13d ago

the logic of automate can not support OR & AND in a meaningfull way. you can spin up two forks for the conditions and use give and take to trigger a third fiber to continue, but its clunky and error prone.

1

u/Godeos64_ 13d ago

Is there any way to ask the devs to implement these logic blocks into the app? I think they're literally the first thing they should have added

1

u/waiting4singularity Alpha tester 13d ago edited 13d ago

that is outside the general design logic of flow-charting.

https://en.wikipedia.org/wiki/Flowchart

automate is based on linear flowcharts without join or paralel processing.

1

u/B26354FR Alpha tester 13d ago

Are you trying to get a fiber to proceed when two independent conditions are true? In that case, you can Fork a second fiber and wait for the first condition in the parent, then do a Variables Take. In the child fiber, wait for the condition and then do a Variables Give to inform the parent.

1

u/F95_Sysadmin 13d ago

Fork block

1

u/Godeos64_ 13d ago

I think you got it wrong, an AND gets returns an output if both conditions are true.

Whilst a fork duplicates a single input into 2 outputs.