Rules using Lua scripts

Expand all | Collapse all

The function in a rule's Lua script described in the Lua language is called whenever the value of any tag used in the function is changed. The function is first called when all values of tags used in the function are received.

You can change functions in Lua scripts when performing the following actions:

Tags are described in the function code by an expression in the following format:

X = tag'tag_name'[.R/.W/.RW],

where the following modifier values are used: .R – tag is intercepted when reading the tag from the device, .W – tag is intercepted when writing the tag to the device, .RW – any most recent value of the tag. You are not required to specify a modifier. If a modifier is not specified, any most recent tag value is used.

When creating a rule using a Lua script, you can use additional variables with a user-defined name and value.

The following function is used to add a variable:

_AddEventParam('parameter_name', parameter_value)

You can use the added variable in the settings of custom event types. The added variable may be used in the format $extra.<parameter_name>.

You can use functions for adding a record to the process log in which the Lua script is executed (this is normally a process whose name starts with the word Filter). A record defined by an argument of the function (variable or constant) is added to the log:

Records are not created in the log if the level of the record is lower than the log level set for the process in the Settings of Server and sensors window.

Page top