Json sample file

Here is a sample of the json file. There are some comments in the sample. Please refer also to the dedicated documentation pages for all the json parts for more information.

Sample

Part of the json sample

# Here part of json declaration

    "device_types": {                                           # device type declaration who appears in user interface list to create device
        "fooplugin.device_name": {
            "id": "fooplugin.device_name",                          # device id for internal reference (no Xpl)
            "description": "A short description",
            "name": "The device type name",
            "commands": ["cmd_one", "cmd_two"],                     # link to list of commands
            "sensors": ["sensor_one", "sensor_two"],                # link to list of sensors
            "params": [                                             # parameters that are common to ALL xpl messages for this device type
                {
                    "key": "key1_devicetype",                       # key copied to the xpl messages, this a static key like device address
                    "description": "A short description",
                    "type": "string"                                # key appears in the xpl as : {key1_devicetype : this a string type}
                    "xpl": True                                     # if the params is in the xpl messages : True. For example, an interval will not be in a xpl message
                    "default": "A default value"                    # optionally a default value for this parameter
                },
                {
                    "key": "key2_devicetype",
                    "description": "A short description",
                    "type": "integer",
                    "max_value": 255,                               # depending on the type the are other possibilities
                    "min_value": 0,
                    "xpl": True                                     # if the params is in the xpl messages : True. For example, an interval will not be in a xpl message
                    "default": "A default value"                    # optionally a default value for this parameter
                }
            ]
        }
    },


    "commands": {                                                   # commands who are call by device_types, A command can be call by many device_types
       "cmd_one": {
           "name": "The cmd name",
           "return_confirmation": true,                             # at true a confirmation xpl message should be send at command return. It is strongly recommended to use confirmation
           "parameters": [                                              # parameters that are common to ALL xpl messages for this command
               {
                   "key": "key1_cmd_one",                           # key copied to the xpl messages, this a dynamic key that can be set in each Xpl message (dynamic)
                                                                    # key appears in the xpl as : {key1_cmd_two : dynamic value}
                   "data_type": "DT_Switch",                        # link to Domogik Type of Data used by widgets in UI.
                   "conversion": "from_DT_Switch_to_level"          # if needed define proper conversion function in file <plugindirectory>/conversion/<fooplugin>.py
                                                                    # conversion have utility when hard device receive a particular scale or data type who are not directly compatible with Domogik Types
               }
           ],
           "xpl_command": "xpl_cmd_one"                             # link to xpl_command format to use
        },
        "cmd_two": {
           "name": "The cmd name",
           "return_confirmation": false,
           "parameters": [
               {
                   "key": "key1_cmd_two",
                   "data_type": "DT_Scale",
                   "conversion": "from_DT_Scale_to_level"
               }
           ],
           "xpl_command": "xpl_cmd_two"
        }
    },

    sensors": {                                                     # sensors who are used by device_types, A sensors can be use by many device_types
        "sensor_one": {
            "name": "The sensor name",
            "data_type": "DT_Switch",
            "conversion": "from_level_to_DT_Switch",                # if needed define proper conversion fuction in file <plugindirectory>/conversion/<fooplugin>.py
                                                                    # conversion have utility when hard device send a particular scale or data type who are not directly compatible with Domogik Types
            "incremental" : false,                                  # does the sensor is about incremental values
            "timeout" : 120,                                        # value in seconds to indicate when a value is too old and so the device may be offline/broken/...
            "history": {                                            # how is managed the sensor history.
                "store": true,
                "duplicate": false,
                "max": 0,
                "expire": 0,
                "round_value": 0
            }
         },
        "sensor_two": {
            "name": "The sensor name",
            "data_type": "DT_Scaling",
            "conversion": "from_level_to_DT_Scaling",
            "incremental" : false,
            "timeout" : 0,
            "history": {
                "store": true,
                "duplicate": false,
                "max": 0,
                "expire": 0,
                "round_value": 0
            }
     },

    "xpl_commands": {                                               # declaration for linking commands to xpl schema and keys
         "xpl_cmd_one": {
            "name": "The xplCmd name",
            "schema": "fooplugin.basic",                            # schema that must respect the xpl-protocol
            "xplstat_name": "xplstat_name_one",
            "parameters": {                                         # parameters that are common to ALL xpl messages for this xpl_command
                "static": [                                         # key copied to the xPL message. Static keys will always be the same, whatever the device is
                    {
                        "key": "static_key1_xpl_cmd_one",           # key appears in the xpl as : {static_key1_xpl_cmd_one : static value}
                        "value" : "value_static_key1_xpl_cmd_one"
                    },
                    {
                        "key": "static_key2_xpl_cmd_one",
                        "value" : "value_static_key2_xpl_cmd_one"
                    }
                ],
                "device":                                           # key copied to the xPL message. Satic value defined on a per device basis (input is requested) in the user interface.
                                                                    # The device key is used for parameters that depend on a device, that require an input by the user,
                                                                    # but that do not change once the device is created, once the device is cerated these parameters
                                                                    # are static, but the value is requested during the device creation process.
                                                                    # an example of a device parameter is the datatype in knx, this can be different for xplstat and xplcommand,
                                                                    # but it will stay the same once the device is created


                    {
                        "key": "device_key1_xpl_cmd_one",           # key appears in the xpl as : {device_key1_xpl_cmd_one}
                        "description": "A description",             # A description that will be displayed in the admin interface
                        "type": "string"                            # The type of the field (used for the userinterface)
                        "default": "A default value"                # optionally a default value for this parameter
                    },
                    {
                        "key": "device_key2_xpl_cmd_one",           # key appears in the xpl as : {device_key1_xpl_cmd_one}
                        "description": "A description",             # A description that will be displayed in the admin interface
                        "type": "string"                            # The type of the field (used for the userinterface)
                        "default": "A default value"                # optionally a default value for this parameter
                    }
                ]
            }
         },
         "xpl_cmd_two": {
            "name": "The xplCmd name",
            "schema": "fooplugin.basic",
            "xplstat_name": "",
            "parameters": {
                "static": [
                    {
                        "key": "static_key1_xpl_cmd_two",
                        "value" : "value_static_key1_xpl_cmd_two"
                    }
                ],
                "device": [
                    {
                        "key": "device_key1_xpl_cmd_two",           # key appears in the xpl as : {device_key1_xpl_cmd_one : static value}
                        "description": "A description",             # A description that will be displayed in the admin interface
                        "type": "string"                            # The type of the field (used for the userinterface)
                        "default": "A default value"                # optionally a default value for this parameter
                    }
                ]
            }
         }
    },

    "xpl_stats": {                                                  # declaration for linking stats to xpl schema and keys.
       "xplstat_name_one": {
            "name": "The xplstat name",
            "schema": "sensor.basic",                               # schema that must respect the xpl-protocol
            "parameters": {                                         # parameters that are common to ALL xpl messages for this xpl_stats
                "static": [                                         # key copied to the xPL message. Static keys will always be the same, whatever the device is
                    {
                        "key": "static_key1_xplstat_one",           # key appears in the xpl as : {static_key1_xplstat_one : static value}
                        "value" : "value_static_key1_xplstat_one"
                    }],
                "device": [
                    {
                        "key": "device_key1_xpl_cmd_two",           # key appears in the xpl as : {device_key1_xpl_cmd_one}
                        "description": "A description",             # A description that will be displayed in the admin interface
                        "type": "string"                            # The type of the field (used for the userinterface)
                        "default": "A default value"                # optionally a default value for this parameter
                    }
                ],
                "dynamic": [                                        # key copied to the xPL message. keys which are values for the sensors. They are stored in the sensor history table.
                    {
                         "key": "dynamic_key1_xpl_xplstat_one",     # key appears in the xpl as : {dynamic_key1_xpl_xplstat_one : dynamic value}
                         "ignore_values": "",
                         "sensor": "sensor_one"                     # link to sensor type to set Domogik Data Type and optimal conversion
                    },
                    {
                         "key": "dynamic_key2_xpl_xplstat_one",
                         "ignore_values": "",
                         "sensor": "sensor_two"
                    }
                ]
            }
       }
    }

An xpl command for cmd_one with confirmation

Command:

xpl-cmnd
{
    hop1 = 1
    source = xpl-rest.domogik
    target = *
}
fooplugin.basic
{
    key1_devicetype_one = static-value_string                   # ex : {"deviceaddr" : "x0103"}
    key2_devicetype_one = static-value-integer                  # ex : {"channel" : "a1"}
    key1_cmd_one = dynamic-value-DT_Switch                      # ex : {"command" : "on"}
    static_key1_xpl_cmd_one = value_static_key1_xpl_cmd_one     # ex : {"zone" : "bedroom"}
    static_key2_xpl_cmd_one = value_static_key2_xpl_cmd_one     # ex : {"timer" : 15}
    device_key1_xpl_cmd_one = value_device_key1_xpl_cmd_one     # ex : {"bauds" : 40000}
    device_key2_xpl_cmd_one = value_device_key2_xpl_cmd_one     # ex : {"sleep" : 2}
}

The confirmation message:

xpl-trig
{
    hop = 1
    source = domogik-fooplugin.foomachine
    target = *
}
sensor.basic
{
    key1_devicetype = static-value_string                                   # ex : {"deviceaddr" : "x0103"}
    key2_devicetype = static-value-integer                                  # ex : {"channel" : "a1"}
    static_key1_xplstat_one = value_static_key1_xplstat_one                 # ex : {"zone" : "bedroom"}}
    device_key1_xpl_xplstat_one = value_device_key1_xpl_xplstat_one         # ex : {"bauds": 40000
    dynamic_key1_xpl_xplstat_one = dynamic-value-sensor-one-DT_Switch       # ex : {"state" : "on"}
    dynamic_key2_xpl_xplstat_one = dynamic-value-sensor-two-DT_Scaling      # ex : {"battery" : 80}
}

An xpl command for cmd_two without confirmation

Note

This case should not happen! xPL protocol tell us that a trigger (xpl-trig) message should be sent after each successfully processed command (xpl-cmnd) received!

Command:

xpl-cmnd
{
    hop1 = 1
    source = xpl-rest.domogik
    target = *
}
fooplugin.basic
{
    key1_devicetype_one = static-value_string
    key2_devicetype_one = static-value-integer
    key1_cmd_two = dynamic-value-DT_Scale
    static_key1_xpl_cmd_two = value_static_key1_xpl_cmd_two
    device_key1_xpl_cmd_two = value_device_key1_xpl_cmd_two

}

There is no confirmation message