How can I do this? Negative condition with timeout setting

I have a Logicblock that is triggered from IFTTT or Siri to close the garage door via Tuya actuator on the gate engine:

Logicblock: Close garage gate
Condition: Gate is open via door sensor
Positive result: 
* Send command to gate engine

Negative result:
* Nothing (gate was already closed)

Reason for the condition “Gate is open” is that the actuator on the gate engine is dumb so the command to open and close is the same. Without this check, gate would open if it was already closed, which is not desired.

So far so good… now this is where I need help.

If the gate is moving (opening or closing), the command halts the door wherever it is, which is very inconvenient if, for any reason, the logicblock is invoked twice in a very short timeframe. So I’d like to add another condition to this Logicblock:

Logicblock: Close garage gate (v2)
Condition: (Gate is open via door sensor) AND (GateIsMoving is FALSE)
Positive result:
* Send command to gate engine
* Set boolean variable GateisMoving to TRUE via an IFTTT applet (GateMoving is a boolean variable with a timeout of 15 seconds, which is the time it takes for the gate to fully open or close, so it becomes FALSE automatically)

Negative result: 
* Nothing

Since there are no negative conditions (GateIsMoving is FALSE) and delay settings only apply to TRUE values, I don’t know how to implement this.

1 Like

I think I could implement this by creating an additional LB that executes before LB Open Garage Door v1:

LB Check GateIsMoving:
Condition: GateIsMoving
Positive result:

  • Nothing

Negative result:

  • Invoke IFTTT applet to trigger the original LB Close garage gate (v1)

However, since a LB cannot trigger another LB, this means going through IFTT, which would add too much delay

Siri :arrow_right: LB Check GateIsMoving :arrow_right:Negative​:arrow_right: IFTTT :arrow_right: LB Close garage gate (v1)

1 Like

Thinking hard to find a way to achieve this without setting a variable as a result of the Logicblock, but I couldn’t figure it out yet.
Give me a bit more time :thinking:

1 Like

More or less I got it.

I discarded the idea of using timeout variables, so now I’ve defined a boolean variable called GateisNotMoving, which is a regular variable (no timeout). What I did is the following:

Logicblock: Close garage gate (v3)
Condition: (Gate is open via door sensor) AND (GateIsNotMoving is TRUE)
Positive result:
* Send command to gate engine
* Set boolean variable GateisNotMoving to FALSE via an IFTTT applet 
* Set boolean variable GateisNotMoving to TRUE via an IFTTT applet with a delay of 15 seconds (time for door to fully open or close)

It works quite well although, in the car, sometimes both CarPlay and Apple Watch listen to the “Close the garage” and both execute the same action with <1 second difference. That should not happen but sometimes it does…

When that happens, GateisNotMoving is set to FALSE by the first execution (e.g. invoked by CarPlay) but, since variable update it is done via IFTTT, it takes around 2 seconds for GateisNotMoving to be FALSE. The second execution (e.g. invoked by Apple Watch 0.5 sec later) still goes through, so the gate motor receives two commands: starts moving the gate and 0.5 sec later halts it

That could be avoided if a variable could be set to TRUE/FALSE directly with an Apilio action with zero delay instead of using IFTTT, as the second execution would find GateisNotMoving being already FALSE.

:pleading_face: I really look forward to Logicblocks being able to evaluate logicblocks and set variables…

1 Like

Me too! That will be a great day @pebneter