Calls a service of a specified device.


Table 1. Request parameters
Parameter Type Description
params dict The request parameter object. For more information, see the table Parameter descriptions of params.
Table 2. Parameter descriptions of params
Parameter Type Description
productKey String The key of the product to which the device belongs. It is a unique identifier issued by IoT Platform for the product.
deviceName String The name of the device. The device name is generated when the device is created.
service String

The identifier of the service that is called.

Log on to the IoT Platform console. On the Define Feature tab of the product details page, click TSL Model to view the identifier of each service.

payload String|Bytes

The identifiers and values of the input parameters for the specified service.

You can click TSL Model to view the values of the identifier parameter and other parameters.

Table 3. Response parameters
Parameter Type Description
return dict If the call is successful, the service value is returned. Otherwise, the error message reported by the driver is returned.

Sample requests

The following example calls the turn service for device lightdev2.

# -*- coding: utf-8 -*-
import lecoresdk

lesdk = lecoresdk.IoTData()

def handler(event, context):
  get_params = {"productKey": "a1ZJTVs****", # Please replace it with your Product Key.
                "deviceName": "LightDev2",   # Please replace it with your Device Name.
                "service":"turn",            # The service defined in the Product TSL.
                "payload": {"LightSwitch": 1}}
  res = lesdk.callThingService(get_params)
  return 'OK'