Skip to content

Class

Each entity (object and link) belongs to a class. Class defines the following entity's defaults:

  • Default view (how to display Child Objects in SAYMON UI);
  • Dimensions of Objects in SAYMON UI;
  • SVG-background;
  • Properties;
  • State Change Conditions;
  • Alarm Generation Conditions;
  • Operations.

Warning

You can't change the Class of an entity later.

Class model

Field Type Description
id String
required
Class's ID.
name String
required
Class's name.
description String Class's description
category_id String Class's category ID. See a more detailed description below.
client_data String Class's client data. See a more detailed description below.
operations Array<Operation> An array of class's operations.
properties Array<Property> An array of class's properties.
triggers Array<Trigger> An array of class's custom triggers. See the Custom Triggers section for more information.

Client data

Client data is a set of fields that correspond to various class's UI settings. The fields are specified in the JSON format and stored on a server as a string. The table below contains a description of all fields from the set:

Field Type Description
columns Array<ClassColumn> An array of class's columns.
default_view String Class's default view. Available options: standard, geo-view, end-view, table-view, grid-view.
background String The ID of an image used as a class background.
defaultDim Array<Integer> A default dimension of objects belonging to this class. Should be specified as an array of two integers, where the first one corresponds to width, the second one to height.

Class column

Field Type Description
id String
required
The ID of a class column.
name String
required
The name of a class column.
type String The type of a class column.
hidden Boolean Whether to hide the column.
removable Boolean Whether it's possible to remove the column.

Category ID

The class's Category ID is used to group child objects. Child objects belonging to a class with the same category ID will be displayed on a parent object icon together. Child objects of classes with different category ID will be separated by a line.

This is how child objects look in the web interface:

Example of objects, separated by their category

Custom triggers

Server can execute scripts when you create or delete objects. Custom triggers define scripts that will be executed, their arguments, and when those scripts will be executed.

Custom triggers have the following fields:

Field Type Description
type String When does the trigger activate. Possible values are create and remove.
args Object JSON object that contains the set of key-value pairs with arguments that will be passed to the script.
customScriptId String Path to the script that will be executed.

You can pass the following variables into the script.

Field Type Description
{{body}} String Object's body in the JSON format.
{{class_id}} String Object's class ID.
{{client_data}} String Object's Client Data.
{{created}} Integer Timestamp of the object creation.
{{geoposition}} String Object's geoposition.
{{geopositionRadius}} String Object's geoposition radius.
{{id}} String Object ID.
{{entityId}} String Entity ID.
{{last_state_update}} Integer Timestamp of the last State update.
{{name}} String Object's name.
{{parent_id}} Array<String> List of parents' IDs.
{{state_id}} String ID of the object's State.
{{tags}} Array<Tag> Object Tags.
{{updated}} Integer Timestamp of the object update.

Example

This example contains two custom triggers. The first triggers when an object is created, the second — when an object is deleted.

"triggers": [
    {
        "type": "create",
        "args": {
            ";saymon-ctp-auto-id#0": "first var",
            ";saymon-ctp-auto-id#1": "second var"
        },
        "customScriptId": "test/class_trigger.sh"
    },
    {
        "type": "remove",
        "args": {
            ";saymon-ctp-auto-id#0": "pos var",
            "--name": "{{name}}",
            "--description": "Object was removed"
        },
        "customScriptId": "test/hello_world.sh"
    }
]