Boolean variable query in IFTTT

Here you’ll find a step-by-step example that shows you how to use queries applied to boolean variables: we’ll check if the garage door is closed before turning a light on. We’ll need two applets for this: one that checks if the gate is closed. The other one has the filter code to query whether the gate is actually closed.

Example: turn light off if the garage gate is closed

I have two sensors for my garage gate and my garage door. I also have a smart light bulb in my garage.

Applet 1 (regular applet)

  • If my garage gate opens
    • Trigger service: any door sensor that works with IFTTT
    • Trigger: is open
  • Update an Apilio variable to open:true
    • Action service: Apilio
    • Action: update a boolean variable ‘gate’ to true

Applet 2 (applet with query and filter code)

  • If I close the garage door
    • Trigger service
    • Trigger: is closed
  • And but only if garage gate is closed
    • Query service: Apilio
    • Query: History of boolean variable ‘gate’
  • Filter code: Only turn off the garage lights if ‘gate’ == true, else skip the action
let gate = Apilio.booleanVariableHistory[0].Value; 
if (gate == "false"){ Hue.turnOnAllHue.skip('The door is still open');
}
  • Turn off garage lights
    • Action service: any smart light service that works with IFTTT
    • Action: turn on (we have used Hue here as an example in the filter code)