How to use variables and triggers

One of the main advantage of ImSmart is that it holds values or states of your devices or processes. It’s the memory that IFTTT does not have. As you might know, IFTTT is just “fire and forget”. As soon as the action is triggered, it’s over and there is no trace of what happened except in the Activity log. ImSmart can keep 3 types of values: Boolean, Numeric and String. Although you’ll probably find that you mostly need Boolean variables there is provision for more whenever you need it. A Boolean variable holds one of 2 states: True or False, just like a light switch (with no dimmer) it’s either ON or OFF. A Numeric variable holds a number, so it could be the dimmer value between 0 and 100. It can hold decimal values (e.g. 23.456) as well as negative values. A String variable can hold any string, like “Sunny” or “Cloudy”.

Each type allows different operations on them.

Operations available on Boolean variables:

  • SetTrue : Sets the variable to True.
  • SetFalse : Sets the variable to False.
  • Toggle : Switches the value from True to False, and inversely.

Operations available on Numeric variables:

  • SetValue : Sets the variable value.
  • Increment: Increment value by 1 or by any value you provide.
  • Decrement: Decrement value by 1 or by any value you provide.

Operations available on String variables:

  • SetValue: Sets the variable value.

All variable types can check the value or the variable with operation GetValue. The value will be returned in XML format like:

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">1.234</string>

The XML tag will be <string> independently of the variable type.

All variable operations can be called in the form https://www.imsmart.tech/api/Values/<UserKey>/<VariableKey>/<Operation>/[Value]

Do not provide parameter Value on Boolean operations. Parameter Value is optional on Boolean Increment and Decrement operations, in which case it increments/decrements value by 1. Value is also optional on String SetValue operation, in which case it sets the value to empty.

Now that you know how to set your variables, let’s see how to use them. The heart of ImSmart (or brain) is in the triggers. Triggers allow you to execute actions based on your variables values. There are 2 parts to a trigger: a condition and a series of actions to execute if the condition is met. A condition can be very simple like:

Or it can a bit more complex, like:

The easiest way to understand how to build a condition is to play with it and look at the resulting formula. When you build your condition, you add a rule to an existing AND/OR group by clicking “Add rule” and you add a new group when the current group is not enough because you need to break a AND group with an OR (or vice-versa), like in the example above.

You switch a condition group from AND to OR by clicking  or  button. Click  to negate the condition group. Reorder condition rules and groups by clicking and dragging  icons.

By default, as soon as one of the variables that are part of your condition is updated, the trigger condition will be evaluated. When evaluated positively actions where result is True are executed, and when evaluated negatively actions where result is False are executed. For example, the following trigger

will call TurnOnLights as soon as you arrive home and call TurnOffLights as soon as you leave home.

Actions are in the form of calls to IFTTT or to specific URLs you specify. Using IFTTT you enter a Maker Event Name that leads to the actual action you wish to execute on your device. Using a custom URL you enter your URL in which you can insert variable values using {{variable}} format.

Even more options 

By clicking the Additional options button you open a panel that is less-often used but contains some very powerful options.

The first option is a delay that can be added to the action. When you select “Delay execution”, you also enter a delay. Option “Reset timer” is used to reset the timer each time the same condition is evaluated positively. For example you have a trigger that is delayed 30 minutes. If the same trigger is evaluated positively before the 30 minutes is over, the initial scheduled action is canceled and the timer restarts for another 30 minutes. Option “Re-Evaluate condition” is used to recheck the condition before executing the action when the delay expires. Using this option it’s possible that the action is not executed if the condition changed when the delay expired.

Options “value1”, “value2” and “value3” are used to specify a variable value to pass back to IFTTT Maker. Leave blank if you’re not using any.

Leave a Reply

Your email address will not be published. Required fields are marked *