Dictionary

Dictionary defines a collection of data in the "key-value" or "key-array" format.

Dictionaries can be used to show stats in widgets in a more convenient and readable way, as well as store data that can be used in notifications, state change conditions, and state triggers.

Field Type Description

columns

Object

Names of key and values of a dictionary. Only included in the dictionaries with named columns.

Defined as a JSON object in the following format:

"columns": {
    "0": {
        "name": "key_name"
    },
    "1": {
        "name": "value 1 name"
    },
    "2": {
        "name": "value 2 name"
    },
    ...
},
You can skip values in this parameter and leave columns unnamed.

content

String

Dictionary’s key-value or key-array pair in the JSON format.

contentType

String

String containing data type of dictionary’s value. In the current implementation, always contains object.

description

String

Dictionary’s description.

id

String

Dictionary’s ID.

name

String

Dictionary’s name.

Examples

Single value

The example below shows a dictionary for the door sensor.

This example dictionary is meant to be used with a door sensor.The sensor sends values 0 and 1 that correspond with the door being closed and opened respectively. If you use the dictionary with a widget, it will show these values in a human-readable form.

Values and their replacements are specified as a JSON string in the content field.

{
    "name": "Door status",
    "content": "{\"0\":\"Closed\",\"1\":\"Open\"}",
    "description": "Transforms data from sensors in the human-readable form",
    "contentType": "object",
    "id": "66e40169029ed40f1105e599"
}

Multiple values

Example below shows a dictionary that has multiple values for each key. In this dictionary, every employee, has a name, an email address, and an encrypted password associated with them.

To create encrypted fields, add a name containing the word password to the columns (case insensitive).

You should also enable encryption in the encrypt field of the server configuration. If you don’t, these field will be hidden in the dictionaries interface, but not encrypted.

{
    "name": "Employees",
    "content": "{\"1\":[\"John Doe\",\"jdoe@example.com\",\"<<crypt:8E993700B6C8BE0CD3849016AF2EF808:0ECB4A66999D516BF80AF91042C7D577>>\"],\"2\":[\"Jane Doe\",\"jdoe@example.com\",\"<<crypt:704FBEF78BF89315840EAF72E9581508:9E984544669ACF7DBCD6C9455360CEB8>>\"]}",
    "description": "List of employees",
    "contentType": "object",
    "columns": {
        "0": {
            "name": "ID"
        },
        "1": {
            "name": "Name"
        },
        "2": {
            "name": "Email"
        },
        "0": {
            "name": "Password"
        }
    },
    "id": "66e411bf029ed40f1105e59a"
},