Parameters

Read and write configuration parameters, and report changes made on the device.

Configuration API are used to allow Things5 users to read and write configuration parameters (like set-points, durations, ...) from the device.

The other way around is also possible: the device can let Things5 know when parameters have changed using [Pub]Variables changed request

When the user goes to Device>Configuration the [Sub] Parameters read request will be sent to the device. When the user set his new parameters from the UI, the [Sub] Parameters write request will be sent to the device.

The main parameters of the communication are:

fieldtypedescription
namestringname of the variable
typestringvariable type. Value can be "string", "integer", "float"
TopicDirection
things5-production/v1/devices/{device_id}/cmd/read_variables_reqThings5 → device
things5-production/v1/devices/{device_id}/cmd/read_variables_resDevice → Things5
things5-production/v1/devices/{device_id}/cmd/write_variables_reqThings5 → device
things5-production/v1/devices/{device_id}/cmd/write_variables_resDevice → Things5
things5-production/v1/devices/{device_id}/event/variables_changed_reqDevice → Things5
things5-production/v1/devices/{device_id}/event/variables_changed_resThings5 → device

Things5 → device: cmd/read_variables_req

Subscribe to this topic to receive read variables requests.
Publish on read variables response to send the requested variables.

things5-production/v1/devices/<device-id>/cmd/read_variables_req

Payload

{
  "request_id": "UUID",
  "assets": ["configuration"],
  "filters": {
    "configuration": ["var_a","var_b"]
  }
}

Payload Parameters

typedescriptionexample
request_idthe request id to be sent back by the device when sending the response
assetslist of requested variables. Can be "configuration", "states", "metrics"["configuration", "states"]
filters (optional)an object with the list of fields to request per each asset

Expected response

📘

Response has to be sent into the read variables response:

Device → Things5: cmd/read_variables_res

things5-production/v1/devices/<device-id>/cmd/read_variables_res

Success payload

{
  "request_id": "UUID sent in the request",
  "assets": [{
    "name": "configuration",
    "values": [{
      "name": "minimum_setpoint",
      "value": "-20",
      "type": "integer"
    }, {
      "name": "power_on_delay",
      "value": "30",
      "type": "integer"
    }, {
      "name": "temperature_hysteresis",
      "value": "10.4",
      "type": "float"
    }, {
      "name": "appliance_type",
      "value": "visup_v2.3.0-beta",
      "type": "string"
    }]
  }]
}
{
  "request_id": "UUID sent in the request",
  "assets": [{
    "name": "metrics",
    "values": [{
      "name": "cabinet_probe",
      "value": "-10",
      "type": "integer"
    }]
  }]
}
{
  "request_id": "UUID sent in the request",
  "assets": [{
    "name": "states",
    "values": [{
      "name": "door",
      "value": "open",
      "type": "string"
    }]
  }]
}
{
  "request_id": "UUID sent in the request",
  "errors": [
    "invalid request"
  ]
}

Thee UUID in the response must match the one in the request; if the UUID in the response does not match any request the message will be discarded.

Things5 → device: cmd/write_variables_req

Subscribe to this topic to accept write variables requests. Only configuration variables can be written.
Publish on write variables response to send the requested variables.

things5-production/v1/devices/<device-id>/cmd/write_variables_req

Payload

{
  "request_id": "UUID sent in the request",
  "assets": [{
    "name": "configuration",
    "values": [{
      "name": "minimum_setpoint",
      "value": "-20",
      "type": "integer"
    }, {
      "name": "power_on_delay",
      "value": "30",
      "type": "integer"
    }, {
      "name": "temperature_hysteresis",
      "value": "10.4",
      "type": "float"
    }, {
      "name": "appliance_type",
      "value": "visup_v2.3.0-beta",
      "type": "string"
    }]
  }]
}

Payload Parameters

namedescriptionexample
request_idthe request id to be sent back by the device when sending the response
assetslist of assets to write. Currently only configuration assets can be written

: Response has to be sent into the write variables response:

Device → Things5: cmd/write_variables_res

things5-production/v1/devices/<device-id>/cmd/write_variables_res

Success payload

The assets variables with their updated value

{
  "request_id": "UUID sent in the request",
  "assets": [{
    "name": "configuration",
    "values": [{
      "name": "minimum_setpoint",
      "value": "-20",
      "type": "integer"
    }, {
      "name": "power_on_delay",
      "value": "30",
      "type": "integer"
    }, {
      "name": "temperature_hysteresis",
      "value": "10.4",
      "type": "float"
    }, {
      "name": "appliance_type",
      "value": "visup_v2.3.0-beta",
      "type": "string"
    }]
  }]
}

Asset error payload Representation

It is possibile to set errors for one or more asset fields if values are invalid

{
  "request_id": "UUID sent in the request",
  "assets": [
    {
      "name": "configuration",
      "values": [
        {
          "name": "minimum_setpoint",
          "value": "-20",
          "type": "integer",
          "errors": [
            "variable error message if any",
            "other variable error message if any"
          ]
        },
        {
          "name": "power_on_delay",
          "value": "30",
          "type": "integer"
        },
        {
          "name": "temperature_hysteresis",
          "value": "10.4",
          "type": "float"
        },
        {
          "name": "appliance_type",
          "value": "visup_v2.3.0-beta",
          "type": "string"
        }
      ]
    }
  ],
  "errors": [
    "service error message if any",
    "other service error message if any"
  ]
}

Generic error payload Representation

{
  "request_id": "UUID sent in the request",
  "errors": [
    "invalid request"
  ]
}

Device → Things5: event/variables_changed_req

Use this topic to let Things5 know when variables have been changed directly on the device. This applies only to configuration variables. A response will be published by things5 on variables changed response

things5-production/v1/devices/<device-id>/event/variables_changed_req

Payload

{
  "request_id": "generate a UUID that will be used for the response",
  "assets": [{
    "name": "configuration",
    "values": [{
      "name": "minimum_setpoint",
      "value": "-20",
      "type": "integer"
    }, {
      "name": "power_on_delay",
      "value": "30",
      "type": "integer"
    }, {
      "name": "temperature_hysteresis",
      "value": "10.4",
      "type": "float"
    }, {
      "name": "appliance_type",
      "value": "visup_v2.3.0-beta",
      "type": "string"
    }]
  }]
}

Payload Parameters

namedescriptionexample
request_idthe request id to be sent back by things5 when sending the response
assetslist of assets to write. Currently only configuration assets can be written

📘

Response has to be sent into the write variables response:

Things5 → device: event/variables_changed_res

Listen for messages to this topic for a confirmation that Things5 have correclty processed the variables changed request variables changed request

things5-production/v1/devices/<device-id>/event/variables_changed_res

Payload

{
  "request_id": "UUID generated by the request",
  "errors": []
}

Payload Parameters

namedescriptionexample
request_idthe request id to be sent back by things5 when sending the response
errorslist of errors. If empty no errors have occurred.["unexpected error"]

Device commands

The commands defined on the device model (Device commands) reach the device as a parameters write request: they are a predefined set of values to write.