Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

IF/THEN Logic expressions and syntax

Write IF/THEN Logic expressions using the Navixy JEXL-based expression language. Expressions route data by evaluating to true or false, though a missing value can behave differently.

Expression fundamentals

The IF/THEN Logic node uses the Navixy IoT Logic Expression Language, based on Java Expression Language (JEXL). Expressions are meant to return true or false, but a missing value doesn't always follow that rule. Some operators route a missing value to THEN instead of ELSE, and some leave the stored attribute null rather than false. See Missing values and null routing before relying on a comparison to fail safely.

Expression evaluation: Expressions are evaluated from left to right, and you can use parentheses to control the order of operations.

Basic syntax example:

condition1 && (condition2 || condition3 > condition4)

Available operators

Comparison operators

Operator
Description

==

Checks if two operands are equal. If operands are of different types, JEXL converts them to one if possible

!=

Checks for inequality of two operands. Returns true if operands are not equal

<

Checks that the left operand is smaller than the right operand

<=

Checks that the left operand is smaller or equal to the right operand

>

Checks that the left operand is larger than the right operand

>=

Checks that the left operand is larger or equal to the right operand

For how missing values affect routing, see Missing values and null routing.

Logical operators

Operator
Description

&& or and

Logical AND - checks if two conditions are true. Returns true if both conditions are true

|| or or

Logical OR - checking for the truth of at least one of the two conditions

! or not

Logical NOT - converts the result of the condition to the opposite value

Pattern matching operators

Operator
Description

=~

Checks if the value of the left operand is in the set of the right operand. For strings, checks for regex pattern match

!~

Checks if the value of the left operand is not in the set of the right operand. For strings, checks for regex pattern mismatch

=^

Checks that the left string operand starts with the right string operand

!^

Checks that the left string operand doesn't start with the right string operand

=$

Checks that the left string operand ends with the right string operand

!$

Checks that the left string operand doesn't end with the right string operand

Geofence functions

Three functions evaluate a device's position relative to a named Navixy geofence, and a fourth one returns the name of the geofence the device is in. For usage instructions and examples, see Geofence functions.

Function
Parameter
Returns true when

inGeofence(id)

Geofence ID

The device is currently inside the geofence

enterGeofence(id)

Geofence ID

The device has just crossed into the geofence

leaveGeofence(id)

Geofence ID

The device has just crossed out of the geofence

Current position:

The geofence name appears as a comment for readability and has no effect on evaluation. The geofence picker inserts this format automatically.

Historical position:

The second parameter is the index of the data packet (0 for the current one, 1 for the previous one, up to 11), and the third is the validity filter, following the same convention as value(). Both are optional, and both apply to inGeofence() only. enterGeofence() and leaveGeofence() take the geofence ID and nothing else. Don't wrap a geofence function inside value(): the first parameter of value() is an attribute name, not an expression.

Expression examples

Basic condition examples

Equality checks:

Inequality checks:

Missing-value caution: != against a non-null literal routes missing values to THEN, not ELSE.

Safe: a presence guard limits the check to packets that carry the attribute.

Unsafe: this fires on temperature's first packets before it has any history, since != treats a missing value as unequal to any literal.

Numeric comparisons:

Temperature monitoring:

This expression triggers when temperature exceeds 75 degrees, useful for overheating alerts.

Speed violation detection:

This expression identifies when vehicles exceed 80 km/h speed limits.

Device health monitoring:

This expression detects low battery conditions requiring maintenance attention.

Fuel level alerts:

This expression identifies when fuel levels drop below 20%, enabling proactive refueling.

Logical operator examples

AND operations:

OR operations:

NOT operations:

Pattern matching examples

Set membership:

String pattern matching:

Complex multi-condition examples

After-hours speeding alert:

This combines speed monitoring with time-based conditions for enhanced safety oversight during night shifts.

Comprehensive device diagnostics:

This validates multiple device health parameters simultaneously to ensure reliable operation.

Driver safety monitoring:

This identifies unsafe driving behavior when the driver isn't properly identified in the system.

Equipment maintenance scheduling:

This triggers maintenance alerts when engine hours exceed thresholds and maintenance is overdue.

Temperature range compliance:

This detects when refrigerated cargo temperatures fall outside the acceptable range.

Expression complexity and parentheses

You can create complex expressions by combining multiple conditions with parentheses to control evaluation order:

Complex safety validation:

Multi-parameter equipment check:

Missing values and null routing

Common symptom: A condition fires on a device's very first packets, before the referenced attribute has ever arrived. This usually means the condition uses != (or a negated pattern operator) against a missing value. See Comparison operators with null operands and Logical operators with null operands for which operators are safe by default and which need a guard.

A referenced attribute resolves to null in four cases:

  • It has never been sent for this device.

  • It's absent from the current packet, but an earlier packet still holds a value.

  • The requested history index doesn't exist yet.

  • The device sent nothing for more than 30 days, so Navixy dropped its stored history.

JEXL treats all four the same way, as null, so an operator's behavior on a missing value doesn't depend on which of the four caused it. A never-sent attribute doesn't error the flow. For the 30-day retention of stored values, see Full syntax.

For why a missing value stops an expression, and for the comparison patterns that prevent it in both node types, see Missing values in expressions.

Every incoming message leaves the Logic node through exactly one branch, THEN or ELSE, even when the condition references missing data. If the condition's overall result is anything other than true (including null, or a value the node can't evaluate), the message routes to ELSE. The ELSE path therefore carries both "condition is false" and "condition could not be satisfied from available data."

Null-safe condition patterns

Presence guard (recommended when a condition must apply only to packets that carry the attribute). The stored attribute is a real true/false here, not null:

Explicit missing-data check: null literals are accepted in conditions.

|| chain ordering: Put the term that may be null last. Ordering helps only on packets where the left operand is true, so treat it as an improvement rather than a fix.

Unsafe: the null left operand routes to ELSE even though speed > 50 is true on the same packet.

Better: a true left operand short-circuits before the null right operand is evaluated. On a packet where the speed is 20, the null right operand is still evaluated, and the condition still routes to ELSE.

For a form that works on every packet, compare each term explicitly. See Compare a value explicitly.

Don't rely on !() to detect missing data: When x is null, both x > 5 and !(x > 5) route to ELSE.

'all' vs 'valid': value(attr, 0, 'valid') can return the last non-null reading from an earlier packet. The condition may still evaluate against a real value even when the current packet is missing it. Use 'all' when the condition must reflect the current packet only.

Comparison operators with null operands

Situation
Routes to
Stored attribute value

<, <=, >, or >= against a missing value

ELSE

null

!= against a missing value and a non-null literal (e.g., value('a', 0, 'all') != 1)

THEN

true

== against a missing value and a non-null literal

ELSE

false

== null against a missing value

THEN

true

!= null when the attribute is absent

ELSE

false

!= null when the attribute is present

THEN

true

=~ against a missing value and a string literal or a list

ELSE

false

!~ against a missing value and a string literal or a list

THEN

true

=^ or =$ against a missing value() result

ELSE

false

!^ or !$ against a missing value() result

THEN

true

=^, !^, =$, or !$ against a missing attribute referenced by name

ELSE

null

Logical operators with null operands

Situation
Routes to
Stored attribute value

!(x > 5) when x is missing

ELSE

null

Null operand in `

` evaluated before a true operand on the same packet

True operand in `

` evaluated before a null operand (short-circuits)

Null operand in && with a true operand, either order

ELSE

null

false operand in && evaluated before a null operand (short-circuits)

ELSE

false

false operand in `

` evaluated before a null operand

Order matters for both operators. Each one evaluates the left operand first and stops there when the left operand already settles the result. A false left operand settles &&, and a true left operand settles ||. In every other combination the null operand is evaluated, the condition resolves to null, and the message routes to ELSE.

A true operand can't short-circuit past a null one in &&, since AND still needs to know whether the null side would fail the condition. A false operand can, and the node then stores a real false rather than null. For the same rule applied to attribute formulas, and for the comparison patterns that avoid it, see Missing values in expressions.

Error handling scenarios

Scenario
Result
Flow Path
Attribute Value

Expression evaluates to true

Success

THEN connection

true

Expression evaluates to false

Success

ELSE connection

false

Referenced attribute is null and used alone, with no comparison operator

Resolves to null

ELSE connection

null

Missing value compared with <, <=, >, or >=

Resolves to null

ELSE connection

null

Missing value compared with == and a non-null literal

Evaluates to false

ELSE connection

false

Missing value compared with == null

Evaluates to true

THEN connection

true

Missing value compared with != and a non-null literal

Evaluates to true

THEN connection

true

Syntax error in expression

Resolves to null

ELSE connection

null

Practical implementation examples

Fleet temperature monitoring

Business requirement: Monitor refrigerated vehicles to ensure cargo temperature compliance

  • THEN path: Send immediate alerts to dispatch, log compliance violations, trigger corrective actions

  • ELSE path: Continue normal processing for compliant temperatures, update status dashboards

Driver safety enforcement

Business requirement: Identify unsafe driving patterns during active shift hours

  • THEN path: Generate driver coaching reports, send safety notifications, log incidents

  • ELSE path: Process normal driving behavior data, update performance metrics

Predictive maintenance alerts

Business requirement: Detect potential equipment failures before they occur

  • THEN path: Schedule maintenance appointments, send technician alerts, log diagnostic data

  • ELSE path: Continue routine monitoring, update equipment health dashboards

Geofence compliance monitoring

Business requirement: Ensure vehicles operate within authorized areas during business hours

This expression uses the inGeofence() function to check whether a device is inside a named geofence, combined with a business-hours attribute. The geofence boundaries are managed in the Navixy geofences interface, so no coordinate values need to be maintained in the expression.

The == true comparison keeps the condition working on packets where the geofence function can't decide, such as a packet that carries no position. Without it, one empty value stops the whole condition and the message routes to ELSE.

  • THEN path: Continue normal operations; device is in the authorized area during working hours.

  • ELSE path: Generate an unauthorized location alert, notify security, and log the violation.

To detect the moment a vehicle leaves the authorized area rather than checking continuously, use leaveGeofence() instead:

For the full reference on geofence functions including enterGeofence(), geofenceName(), and testing an earlier position with inGeofence(), see Geofence functions.

Last updated

Was this helpful?