homeenfeaturesrules

Rules

Rules define what actions are to be performed in response to events related
with the transmission of
new data. If the data meets the conditions specified in the rules,
a message of a
of a specific type.

Rules can be defined for:

  • a selected device,
  • a selected group of devices,
  • all devices with a specific tag,
  • all devices belonging to a selected location (path) in the organizational structure.

Defining Rules

A rule can be active or inactive.

An incoming data analysis rule is defined for:

  • devices with a selected identifier (EUI),
  • groups,
  • devices tagged with a specific tag name and value.

You can limit the analysis to data no older than a specified number of minutes.

Hysteresis is taken into account when analyzing changes in values.

If the data meets the rule’s conditions, the system generates a notification with the selected severity level:

  • Info
  • Warning
  • Alert
  • Critical
  • Emergency

The notification is sent to the selected list of users.
Optionally, if the rule is no longer met (the data values return to the expected range), the system generates a notification sent to the specified list of users.

Data analysis conditions are defined by:

  • selecting options in the form,
  • defining a script to analyze the data.

Selecting options

If the “script” checkbox is not selected on the form, the conditions can be defined by filling out the form fields that appear and specifying:

  • the name of the measurement being analyzed,
  • the comparison condition (less than, greater than, equal to, not equal to),
  • the value to compare against.

You can define several such conditions.

Python Script

By defining conditions using a script, you can check more relationships than by selecting options from a form. For example, you can compare different measurements with each other.

The script must define a function ` checkRule() ` that returns a result by calling either ` conditionsNotMet() ` or ` conditionsMet()`.

Example:

def checkRule():
    v1 = getValue("temperature1")
    v2 = getValue("temperature2")
    if v1 is None or v2 is None:
        return conditionsNotMet()
    if v2 - v1 > 10:
        return conditionsMet("temperature2", v2)
    return conditionsNotMet()

Variables in Rule Messages

When creating message content, you can use the following variables:

  • {target.eui} - the EUI of the device to which the rule applies (if applicable to a device)
  • {target.name} - the name of the device to which the rule applies
  • {tag.name} - the name of the device tag to which the rule applies
  • {tag.value} - the value of the device tag (named {tag.name}) to which the rule applies
  • {device.eui} - the EUI of the device for which the rule was triggered
  • {device.name} - the name of the device for which the rule triggered
  • {var} - the name of the measurement for which the rule was triggered
  • {measurement} - the name of the measurement for which the rule triggered
  • {value} - the measurement value that satisfies the rule
  • {info} - if present, this is used to separate the message subject from its body
  • {device.owner} - the username of the user who owns the device
  • {device.team} - a list of usernames of users who are part of the device’s team
  • {device.admins} - a list of usernames of users who are administrators of the device

Example used in the message:

This is the notification subject{info}Attention! The {value} value of the {measurement} parameter for the device
{device.name} ({device.eui}) is above the target.

© 2023-2025 Grzegorz Skorupa