Alarms grouping
In this example, we will show you how to create alarm groups and use them.
Define static alarm groups using
group.alarmsfiles, with a fixed location via anINITIALfield generator.Configure parent-child group relationships and hide empty groups using
visibleIfNoChildren.Write a Lua pre-insertion rule to automatically assign new alarms to the correct group based on their location.
Block the
EDIT_LOCATIONaction on groups usingactionConfigurationswithON_NOBODY.
git checkout origin/osp-alarms-configuration .
git checkout origin/osp-web-configuration .
git checkout origin/osp-variables-configuration .
git checkout origin/example-alarms-basic-grouping .
Steps
1. Create the groups
root/buildings/corminboeuf/group.alarms
{
"moduleId": "modules.alarms.alarms-1",
"name": "building_corminboeuf",
"fieldConfigurations": [
{
"name": "location",
"generator": {
"type": "INITIAL",
"value": "Corminboeuf"
}
}
],
"actionConfigurations": [
{
"action": "EDIT_LOCATION",
"actionBehavior": "ON_NOBODY"
}
]
}
To create the static location, we first override the default defaultGroupsFieldConfigurations define on module.alarms by defining fieldConfigurations with a generator INITIAL on the group.
To block the action EDIT_LOCATION, we also need to override the default defaultGroupsActionConfigurations define on module.alarms by defining actionConfigurations with a action behavior ON_NOBODY on the group.
root/buildings/corminboeuf/rooms/showroom/group.alarms
{
"moduleId": "modules.alarms.alarms-1",
"name": "building_corminboeuf_showroom",
"fieldConfigurations": [
{
"name": "location",
"generator": {
"type": "INITIAL",
"value": "Showroom"
}
},
{
"name": "parent",
"generator": {
"type": "INITIAL",
"value": "building_corminboeuf"
}
}
],
"actionConfigurations": [
{
"action": "EDIT_LOCATION",
"actionBehavior": "ON_NOBODY"
}
],
"visibleIfNoChildren": false
}
To join the group Corminboeuf, we set an INITIAL generator for the parent field with the name of the group.
For the room, we set visibleIfNoChildren to false to not display the group when it is empty.
2. Create a pre-insertion rule to add the alarm to the group
The following pre-insertion rule will automatically add the new alarm to the right group. This will be done purely statically inside the rule but it is also possible to extract the information from a collection.
root/pre-insertions/groups/pre-insert.alarms
{
"moduleId": "modules.alarms.alarms-1",
"priority": 1,
"scriptFile": "root/pre-insertions/groups/script.lua",
"for": "match",
"thenExecute": "process"
}
root/pre-insertions/groups/script.lua
local LOCATION_MAP = {}
LOCATION_MAP["Corminboeuf"]="building_corminboeuf"
LOCATION_MAP["Showroom"]="building_corminboeuf_showroom"
function match(alarm)
for key,_ in pairs(LOCATION_MAP) do
if alarm.location == key then
return true
end
end
return false
end
function process(alarm, _, operations)
local newAlarm = operations:create()
newAlarm.parent = LOCATION_MAP[alarm.location]
end
3. Generate alarms
We will generate the following alarms (the order is not important) :
Serial |
Severity |
Summary |
Source |
Location |
|---|---|---|---|---|
fire |
600 |
Fire on the elevator |
Fire detection |
Corminboeuf |
door |
500 |
The main door is blocked |
Onvif |
Corminboeuf |
air-cond |
400 |
Cold loop is out of order |
Modbus |
Showroom |
lighting |
300 |
One lamp need to be replaced |
Technician |
Showroom |
After the insertion, the group will have the following state :
Serial |
Severity |
Summary |
Source |
Location |
|---|---|---|---|---|
building_corminboeuf |
600 |
Fire on the elevator |
Fire detection |
Corminboeuf |
building_corminboeuf_showroom |
400 |
Cold loop is out of order |
Modbus |
Showroom |