Invoke Device Services (Non-Passthrough)


EnOS Cloud publishes a message to the device topic to invoke the device services.


Downstream

  • Request TOPIC: /sys/{productKey}/{deviceKey}/thing/service/{tsl.service.identifier}
  • Reply TOPIC: /sys/{productKey}/{deviceKey}/thing/service/{tsl.service.identifier}_reply

Note

tsl.service.identifier is the identifier of the service that has been defined in the model.

Sample Request Format

{
    "id": "123",
    "version": "1.0",
    "params": {
        "Power": "on",
        "WindState": 2
    },
    "method": "thing.service.{tsl.service.identifier}"
}

Sample Response Format

{
    "id": "123",
    "code": 200,
    "data": {
        "parameter_1": 1.3,
        "parameter_2": 13
  }
}

Request Parameter Description​

Parameters Type​ Mandatory/Optional Description
id String Mandatory The message ID. It is a reserved parameter that is reserved for future use.
version String Mandatory The version of the protocol. The current version is 1.0.
params List Mandatory The parameters used for invoking device services.
Power String Optional The identifier of the service that you want to report. In this example, the service has the identifier Power. The value you set must match the data type defined for this parameter. For example, when the data type of this parameter is set to string in the model, the value here must be a string.
WindState Integer Optional The identifier of the service that you want to report. In this example, the service has the identifier WindState. Similar to the above, the value you set must match the data type defined for this parameter.​
method String Mandatory The request method.

Response Parameter Description

Parameter Type Description
id String The message ID.
code Integer The return code. “200” indicates that the request operation is executed successfully.
data Map (Key is of String type and the Value can be of String, Integer, Array or Object type) The service output fields defined in the model.

Error Codes

For the description of error codes, see Error Codes.