How to use macros in the text of a notification

Introduction

To increase the information content of notifications, users can use macros. Macros help to define which information is sent to the user about the triggered event.

At the time of sending the notifications, macros will be replaced with the corresponding information: Time of the event, sensor name that triggered an alert, the value of this sensor, name of the logic scheme, a verbal description, the state of the elements, the ID of the sensor, and other.

http://www.connexit.biz

The macros are indicated by the percent sign and the number corresponding to the contained information.
the

The following macros are available:

Macros

Specification

Illustration sample

Macros

Specification

Illustration sample

%1

A verbal description of the triggered logic.

if

    'Onboard Temperature' (id=201001) in state 'high alarm';

and    'Onboard Voltage DC' (id=203001) in state 'high alarm';

then

    'Power-1' (id=304001) changes to state 'on' immediately, once;

    'Simple_Mail' (id=601001) changes to state 'on' immediately, once;

%2

The state of the logic scheme elements included in the IF conditions, at the time when the logic is triggered.

'Onboard Temperature' (id=201001) in state 'high alarm';

'Onboard Voltage DC' (id=203001) in state 'high alarm';

%3

Trigger time of the logic scheme.

11:32:28 2017/06/13

%4

Name of the logic scheme.

'Logic_Temp_01'

%5

The name of the sensor, the change in the state of which led to the activation of the logic. Here is displayed the name of the sensor, from which the logic is triggered.

'Onboard Temperature'

%6

The state of the sensor that triggered the logic scheme.

'high alarm'

%7

The sensor value or its logic level at the time of the triggering of the logic scheme.

'27.60'

%8

The ID of the sensor that triggered the logic scheme.

'201001'

%9

Units of measurement, if the sensor has such a parameter.

°C

%A

The sensor value or its logic level at the time of the triggering of the logic scheme. No quotation marks.

27.60

Macros parameterization

Macros %5, %6, %7, %9, %A have the option of parameterization by ID of the element {id}. Those. For these macros, it is possible to specify an element for which the macro will be calculated.

The element ID is passed as the parameter that defines the element. ID is placed in curly brackets {id} immediately after the name of the macro.

Example of computing macros:

Macro

Description

Example

Macro

Description

Example

%5{id}

The name of the sensor with the given id.

%5{201999} will give the sensor name: 'Onboard Temperature'

%6{id}

Status of the sensor with the given id.

%6{201999} will issue a sensor state: 'normal'

%7{id}

The measured value of the sensor with the given id.

%7{201999} will give the sensor value: '26.50'

%9{id}

Units of measurement, if the sensor has such a parameter.

%9{201999} will give the string: °C

%A{id}

The measured value of the sensor with the given id without quotation marks.

%A{201999} will give the sensor value: 26.50

If an element with the specified id is not found, a string is inserted into the message text — 'id=xxxx not found'.

In case the {id} parameter is not set, the value of the element that triggered the logic scheme will be inserted into the message text.

Detail macro of the module, group, and system

The macro %8 can be used to determine the ID of the sensor when the logic scheme is triggered by a change in the state of the group, module, or system. This macro can be used as an identifier parameter in macros %5, %6, %7 and %A.

An example of using a macro for processing a module.

Let's create such a logical scheme:

When the 'Alarm' state of the 'Autodetect' module is activated, the relay will be managed and a message sent to the e-mail.

Module, group and system state

The module (group, system) goes into the 'Alarm' state if at least one of the connected sensors (analog or discrete) is in the 'Alarm', 'High alarm' or 'Low alarm' state.

The module (group, system) goes into the 'Warning' state if at least one of the connected sensors (analog or discrete) is in the 'Warning', 'High warning' or 'Low warning' state and the module is not in the ' Alarm '.

The module (group, system) goes to the 'Normal' state if all еру connected sensors are in the 'Normal' state.

Consider what information you can get with the help of macros.

Macro

Result of the macro

Explanation

Macro

Result of the macro

Explanation

%1

if

    module 'Autodetect' (id=2021) in state 'alarm';

then

    'Power-1' (id=304001) changes to state 'on' immediately, once;

    'Power-2' (id=304002) changes to state 'off' immediately, once;

    'Simple_Mail' (id=601001) changes to state 'on' immediately, once;

Verbal description of the triggered logic. When the 'Autodetect' module is switched to the 'alarm' state, the 'Power-1' relay is turned on immediately (and once, without repeats), the 'Power-2' relay is turned off and the 'Simple_Mail' notification is sent. The module goes into the 'alarm' state if at least one of its elements is in the 'alarm' state.

%2

module 'Autodetect' (id=2021) in state 'alarm';

The state of the elements of the logic scheme included in the IF conditions at the time when the is triggered. The module that triggered the logic and its state are described.

%3

16:14:41 2017/06/13

The response time of the logic scheme.

%4

'Logic_Analog_Sensors'

The name of the logical scheme.

%5

'Autodetect'

The name of the sensor (module), the change in the state of which led to the activation of the logic scheme.

%6

'alarm'

The state of the sensor (module) that initiated the triggering of the logic scheme.

%7

%A

'not supported'

Measured sensor value or its logic level at the time when the logic is triggered. The module does not have this field, so 'not supported' is displayed here.

%8

'107002'

The id of the sensor that triggered the logic scheme. Here is the sensor ID, which is contained in the module and which caused the module to operate, is indicated. In this case, it is a water leakage sensor. Using this macro as a parameter allows you to determine the sensor that has worked inside the module.

%5{%8}

'Analog-2-WATER'

The name of the sensor by ID. We request it by the id of the sensor from which the module is triggered.

%6{%8}

'alarm'

Sensor status by id. We request it by the id of the sensor from which the module is triggered.

%7{%8}

%A{%8}

'1'

1

The sensor value by id. We request it by the id of the sensor from which the module triggered.

%5{201002}

'Analog-1-TEMPERATURE'

The name of the sensor by ID. We request one of the arbitrary sensors, in this case, it is a temperature sensor.

%6{201002}

'high warning'

Sensor status by id. We request one of the arbitrary sensors, in this case, it is a temperature sensor.

%7{201002}

%A{201002}

'28.50'

28.50

The value of the sensor by ID. We request one of the arbitrary sensors, in this case, it is a temperature sensor.


From this information, it is seen that the water leakage sensor 'Analog-2-WATER' has acted in the 'alarm' state, it has transferred the 'Autodetect' module to the 'alarm' state, which triggered the logic scheme and sent the notification.

Macros in group notifications

If it is necessary to monitor the state of elements, it is preferable to use not a mechanism of logic schemes, but group notifications. Because with a large number of observed elements, group notifications can significantly reduce the number of logic schemes (since they do not use them) and simplify device configuration. Logic schemes are reasonable to use when complex reactions to events, for example when controlling an external relay.

You can read more about creating groups and group notifications here: Using group notifications.

For example, create a group of elements that includes all temperature sensors in the system.



Let's set a notification that will be sent when the group switches to the 'Normal' and 'High alarm' states.

 

Such information can be obtained using macros in the text of the notification.

Macro

Macro result example

Comment

Macro

Macro result example

Comment

%1

do not use this macro for group notifications

Because the logic is not used here, then this macro does not make sense.

%2

do not use this macro for group notifications

Because the logic is not used here, then this macro does not make sense.

%3

16:14:41 2017/06/13

The response time corresponds to the moment of transition of the group to the observed state.

%4

'Group_Temperature_Only'

Group name.

%5

'vt470-0192-temperature'

The name of the sensor (or module) that initiated the state change. Changing the state of this sensor has led to a change in the state of the group and sending a notification.

%6

'high alarm'

The state of the sensor (or module) that initiated the state change.

%7

%A

'27.30'

27.30

The value is measured by the sensor or its logical level at the time of operation.

%8

'201003'

The identifier of the sensor that initiated the state change. Here, it is the sensor identifier that is indicated, a change in the state of which led to a change in the group state and sending a notification.

%5{%8}

'vt470-0192-temperature'

Sensor name by ID. We are requesting the sensor ID from which the group notification worked. In this case, the macro is similar to %5.

%6{%8}

'high alarm'

Sensor state by ID. We are requesting the sensor ID from which the group notification worked. In this case, the macro is similar to %6.

%7{%8}

%A{%8}

'27.30'

27.30

Sensor value by ID. We are requesting the sensor ID from which the group notification worked. In this case, the macro is similar to %7.

%5{201002}

'Analog-1-TEMPERATURE'

Sensor name by ID. We request one of any sensors, in this case, it is a temperature sensor. The macro allows for example to display the data of any sensors of the group.

%6{201002}

'high warning'

Sensor state by ID. We request one of any sensors, in this case, it is a temperature sensor. The macro allows for example to display the data of any sensors of the group.

%7{201002}

%A{201002}

'28.50'

28.50

Sensor value by ID. We request one of any sensors, in this case, it is a temperature sensor. The macro allows for example to display the data of any sensors of the group.