Skip to content

MXL - Meddle Expression Language

MXL (Meddle Expression Language) is a simple expression language used in Meddle connectors for defining conditions and logic.

Used in:

MXL expressions evaluate to boolean values (true/false) based on payload data.

field_name operator value
temperature > 80
pressure < 10
status == "active"
count != 0
OperatorDescriptionExample
>Greater thantemperature > 80
<Less thanpressure < 10
>=Greater than or equalhumidity >= 60
<=Less than or equalspeed <= 100
==Equal tostatus == "active"
!=Not equal tocount != 0
OperatorDescriptionExample
&&AND (both conditions must be true)temp > 80 && press < 10
``

Compare numeric values:

temperature > 25.5
pressure >= 101.3
count == 100
speed != 0

Compare string values (use double quotes):

status == "active"
mode != "manual"
error_code == "E001"

Compare boolean values:

enabled == true
fault != false

All conditions must be true:

temperature > 20 && temperature < 30
pressure > 100 && humidity < 80 && status == "running"

At least one condition must be true:

temperature > 80 || pressure > 150
status == "error" || status == "fault" || status == "stopped"

Use parentheses for grouping (if supported):

(temperature > 80 || pressure > 150) && status == "active"

Check if value is within range:

temperature >= 20 && temperature <= 30

Alert when value exceeds threshold:

temperature > 80
pressure > 150
vibration > 5.0

Check for specific status values:

status == "error"
status != "running"
mode == "manual"

Alert on multiple conditions:

temperature > 100 || pressure > 150 || vibration > 5

Ensure multiple conditions are met:

temperature > 50 && pressure > 100 && flow > 10
// High temperature warning
temperature > 80
// Temperature out of range
temperature < 15 || temperature > 35
// Critical temperature with pressure
temperature > 100 && pressure > 150
// Machine stopped unexpectedly
status == "stopped" && runtime > 0
// Error condition
status == "error" || status == "fault"
// Not in automatic mode
mode != "auto"
// Defect detected
defect_count > 0
// Out of specification
dimension < 9.9 || dimension > 10.1
// Multiple quality parameters
hardness < 50 || surface_finish > 2.0 || weight < 100
// Process out of control
temperature > 90 || pressure < 95 || flow < 50
// Stable operation
temperature >= 80 && temperature <= 85 && pressure > 100
// Emergency shutdown condition
temperature > 120 || pressure > 200 || vibration > 10
// Anomaly detected
is_anomaly == true
// High anomaly score
anomaly_score > 0.8
// Multiple indicators
vibration > 5 || temperature > 90 || anomaly_score > 0.7
// Good
temperature > 80
machine_status == "running"
// Avoid
t > 80
s == "r"
// For equality, use ==
status == "active"
// For inequality, use !=
count != 0
// Good - related conditions together
temperature > 80 && pressure > 150
// Good - alternative conditions
status == "error" || status == "fault"

AND (&&) has higher precedence than OR (||):

// This checks: (A && B) || C
temperature > 80 && pressure > 150 || humidity > 90
// Use parentheses for clarity
(temperature > 80 && pressure > 150) || humidity > 90

Test expressions with various input values to ensure they work as expected.

  • No arithmetic operations: Cannot do temperature + 10 > 90
  • No function calls: Cannot do abs(temperature) > 80
  • No nested field access: Cannot do sensor.temperature > 80
  • String comparison only: No regex or pattern matching

Check:

  1. Field names match payload exactly (case-sensitive)
  2. Data types match (number vs string)
  3. Operator is correct (== not =)
  4. String values use double quotes

Check:

  1. Logic is correct (AND vs OR)
  2. Threshold values are appropriate
  3. Field exists in payload

Common mistakes:

  • Using = instead of ==
  • Missing quotes around strings
  • Typos in field names
  • Wrong operator precedence
{
"type": "MeddleTrigger",
"config": {
"mode": "DirectDispatch",
"condition": "temperature > 80 && status == \"active\"",
"payload": {
"alert": "high_temperature"
}
}
}
{
"type": "MeddleAlert",
"config": {
"name": "Critical Alert",
"condition": "temperature > 100 || pressure > 200",
"minDuration": 10,
"cooldown": 300,
"notification": {
"type": "Email",
"toEmails": ["alerts@example.com"]
}
}
}