Scene Service 2.0

更新时间:
复制 MD 格式

This service provides APIs for clients to create and configure automated scenes. These scenes execute tasks when specific conditions are met. For example, a device can automatically turn on at a set time.

Scene rule descriptions

Create, edit, delete, and query scenes

Triggers and actionsScene automation executionTimed scenesApp widgets

Home spaces and scenes

Scene rule descriptions

Scene rules describe the trigger that initiates a task (Trigger), the conditions that must be met (Condition), and the action to execute (Action). Two rule formats are supported: If This Then That (IFTTT) and Condition & Action (CA). IFTTT supports Trigger, Condition, and Action nodes. CA is a simplified version of IFTTT that merges the Trigger and Condition nodes into a single "condition" node.

IFTTT rules

The following example shows a typical scene rule. The scene is triggered (Trigger) when the value of the someone_exist property of the device sensor_01 equals 1. The system then checks if the current time is between 6:00 and 22:00 (Condition). If it is, the switch property of the device light is set to on (Action).

{
    "type":"IFTTT",
    "trigger":{
        "uri":"trigger/device/property",
        "params":{
            "iotId":"sensor_01_iotId",
            "propertyName":"someone_exist",
            "compareType":"==",
            "compareValue":1
        }
    },
    "condition":{
        "uri":"logical/and",
        "items":[
            {
                "params":{
                    "cron":"00 6-22 * * 1,2,3",
                    "cronType":"linux",
                    "timezoneID":"Shanghai"
                },
                "uri":"condition/timeRange"
            }
        ]
    },
    "action":[
        {
            "uri":"action/device/setProperty",
            "params":{
                "iotId":"light_iotId",
                "propertyName":"onOff",
                "propertyValue":"on"
            }
        }
    ]
}

The example above shows an IFTTT scene rule. The rule contains four nodes:

NameDescription
typeThe type of the scene rule. Valid values are IFTTT and CA.
triggerThe trigger for the scene, such as a specific time or a device property. A scene can have multiple triggers, which are evaluated with an OR logical relationship. A scene can also have no triggers. In this case, you can manually trigger the scene by calling an API.
conditionThe filter condition after the scene is triggered, such as a time range or a device property limit. A scene can have multiple filter conditions, which are evaluated with an AND logical relationship. A scene can also have no filter conditions. In this case, the action is executed directly after the scene is triggered.
actionThe action to execute when the scene is triggered and the filter conditions are met. Examples include setting a device property or executing another scene. A scene can have multiple actions. A scene must have at least one action.

The following example shows a scene rule with multiple triggers and multiple conditions. The logical/or node encapsulates multiple triggers, and the logical/and node encapsulates multiple conditions.

{
    "type":"IFTTT",
    "trigger":{
        "uri":"logical/or",
        "items":[
            {
                "uri":"trigger/device/property",
                "params":{
                    "productKey":"pk_sensor",
                    "deviceName":"sensor_01",
                    "propertyName":"someone_exist",
                    "compareType":"==",
                    "compareValue":1
                }
            },
            {
                "uri":"trigger/timer",
                "params":{
                    "cron":"0 0 10 * *",
                    "cronType":"linux"
                }
            }
        ]
    },
    "condition":{
        "uri":"logical/and",
        "items":[
            {
                "uri":"condition/device/property",
                "params":{
                    "productKey":"pkxxxxon",
                    "deviceName":"txxxxce",
                    "propertyName":"soxxxxrty",
                    "compareType":"<",
                    "compareValue":10
                }
            },
            {
                "params":{
                    "cron":"0 9-12 * * 1,2,3",
                    "cronType":"linux",
                    "timezoneID":"Asia/Shanghai"
                },
                "uri":"condition/timeRange"
            }
        ]
    },
    "action":[
        {
            "uri":"action/device/setProperty",
            "params":{
                "productKey":"pk_action",
                "deviceName":"test_device",
                "propertyName":"onOff",
                "propertyValue": "on"
            }
        },
        {
            "uri":"action/scene/trigger",
            "params":{
                "automationRuleId":"some_scene_id"
            }
        }
    ]
}

This rule means the scene is triggered at 10:00 every day or when the someone_exist property of the device sensor_01 equals 1. If the some_property property of the device test_device is less than 10 and the current time is between 9:00 and 12:00, the action is executed. The onOff property of test_device is set to on, and another scene is triggered.

CA rules

In addition to IFTTT rules, CA rules are also supported. A CA rule is a simplified version of an IFTTT rule. It contains type, mode, condition, and action nodes.

NameDescription
typeThe type of the scene rule. Valid values are IFTTT and CA.
modeThe mode of the CA rule. Valid values are any or all. any means the action is executed if any condition is met. all means the action is executed only when all conditions are met.
conditionThe trigger conditions for the scene, such as a specific time, a device property, or a time range. A scene can have multiple trigger conditions.
actionThe action to execute when the scene is triggered. Examples include setting a device property or executing another scene. A scene can have multiple actions. A scene must have at least one action.

The following is an example of a CA scene rule.

{
    "type":"CA",
    "mode":"all",
    "condition":[
        {
            "uri":"condition/device/property",
            "params":{
                "productKey":"pk_condition",
                "deviceName":"sensor_01",
                "propertyName":"some_property",
                "compareType":">",
                "compareValue":"300"
            }
        },
        {
            "uri":"condition/device/property",
            "params":{
                "productKey":"pk_condition",
                "deviceName":"sensor_02",
                "propertyName":"BarrierState",
                "compareType":"in",
                "compareValue":[
                    0,
                    1,
                    2
                ]
            }
        },
        {
            "uri":"condition/timer",
            "params":{
                "cron":"0 05 10 * *",
                "cronType":"linux"
            }
        }
    ],
    "action":[
        {
            "uri":"action/device/setStatus",
            "params":{
                "productKey":"pk_action",
                "deviceName":"test_device",
                "propertyName":"LightStatus",
                "propertyValue": 1
            }
        }
    ]
}

This rule means that when the some_property property of the device sensor_01 is greater than 300, the BarrierState property of the device sensor_02 is 0, 1, or 2, and the time is 10:05, the LightStatus property of the device test_device is set to 1.

Trigger component

The supported Trigger components include the following:

URLDescription
trigger/timerTimed trigger
trigger/device/propertyDevice property trigger
trigger/device/eventDevice event trigger

trigger/timer parameters

ParameterTypeDescriptionReference
cronStringCron expression.Cron expression format: http://crontab.org/
cronTypeStringThe expression type. Valid values are linux and quartz_cron.

linux: A 5-field crontab format. The year cannot be set.

quartz_cron: A 7-field Quartz cron format that supports the year. The minimum precision is minutes. The first field (seconds) must be 0.

Cron expression format: http://crontab.org/
timezoneIDStringThe time zone ID. This parameter is optional. It specifies the time zone for the cron expression. If not set, it defaults to the time zone of the IoT Platform service. We recommend that you set this parameter to specify a time zone.Example: Asia/Shanghai

Cron expression types and examples

Expression typeExpression structureExpression fieldsExpression example
linux${minute} ${hour} ${day of month} ${month} ${day of week}
  • minute 0-59
  • hour 0-23
  • day of month 0-31
  • month 0-12
  • day of week 0-7
1 3 * * *
Note Triggers at 03:01 every day.
quartz_cron${second} ${minute} ${hour} ${day of month} ${month} ${day of week} ${year}
Note You cannot use a time in the past.
  • second must be 0
  • minute 0-59
  • hour 0-23
  • day of month 0-31
  • month 0-12
  • day of week 0-7
  • year (optional, if omitted, it triggers every year)
0 * 14 * * ? 2019
Note Triggers every minute from 14:00 to 14:59 every day in 2019.

trigger/timer example

{
    "uri":"trigger/timer",
    "params":{
        "cron":"* * * * *",
        "cronType":"linux",
        "timezoneID":"Asia/Shanghai"
    }
}

trigger/device/property parameters

ParameterTypeDescription
productKeyStringProductKey of the device.
deviceNameStringName of the device.
propertyNameStringThe name of the device property to compare.
compareTypeStringThe comparison type, such as >, <, >=, ==, <=, !=, in, or like.
compareValueObjectThe value to compare.

trigger/device/property example

{
    "uri":"trigger/device/property",
    "params":{
        "productKey":"test_pk",
        "deviceName":"test_dn",
        "propertyName":"temp",
        "compareType":">",
        "compareValue":30
    }
}

trigger/device/event parameters

ParameterTypeDescription
productKeyStringProduct Key
deviceNameStringName of the device.
eventCodeStringThe event code of the device. This parameter is optional.
propertyNameStringName of the device property.
compareTypeStringThe comparison type, such as >, <, >=, ==, <=, !=, in, or like.
compareValueObjectThe value to compare.

trigger/device/event example

{
    "uri":"trigger/device/event",
    "params":{
        "productKey":"test_pk",
        "deviceName":"test_dn",
        "eventCode":"temp_warning",
        "propertyName":"temp",
        "compareType":">",
        "compareValue":30
    }
}

Condition component

The supported Condition components include the following:

URLDescription Logic
condition/timeRangeCompares whether the current time is within a specified range.
condition/device/propertyDevice property filter.

condition/timeRange parameters

ParameterTypeDescription
cronStringFor example, 20-25 11-23 * * 1,2,3 means the action can be executed between 11:20 and 23:25 on Mondays, Tuesdays, and Wednesdays.
cronTypeStringThe cron expression type. The value is linux.
timezoneIDStringExample: Asia/Shanghai

condition/timeRange example

{
    "params":{
        "cron":"00 9-12 * * 1,2,3",
        "cronType":"linux",
        "timezoneID":"Asia/Shanghai"
    },
    "uri":"condition/timeRange"
}

condition/device/property parameters

ParameterTypeDescription
productKeyStringProductKey
deviceNameStringName of the device.
propertyNameStringDevice property.
compareTypeStringThe comparison type, such as >, <, >=, ==, <=, !=, in, or like.
compareValueObjectThe value to compare.

condition/device/property example

{
    "uri":"condition/device/property",
    "params":{
        "productKey":"test_product",
        "deviceName":"test_device",
        "propertyName":"temp",
        "compareType":">",
        "compareValue":30
    }
}

Action component

The supported Action components include the following:

URLDescription
action/device/setPropertySet a device property.
action/device/invokeServiceInvoke a device service.
action/scene/triggerTrigger another scene. If the triggered scene contains a condition that is not met, the action of the triggered scene is not executed.
action/automation/setSwitchEnable or disable another scene setting.

action/scene/trigger parameters

ParameterTypeDescriptionExample
sceneIdStringScene ID.None

action/scene/trigger example

{
    "uri":"action/scene/trigger",
    "params":{
        "sceneId":"xxx"
    }
}

action/device/invokeService parameters

ParameterTypeDescriptionExample
iotIdStringDevice ID.None
serviceNameStringService name.None
serviceArgsJSONService parameters.{"warningStatus":"off","level":"init"}

action/device/invokeService example

{
    "uri":"action/device/invokeService",
    "params":{
        "iotId":"xxxx",
        "serviceName":"clearWarningStatus",
        "serviceArgs":{
            "warningStatus":"off",
            "level":"init"
        }
    }
}

action/device/setProperty parameters

ParameterTypeDescriptionExample
iotIdStringDevice ID.None
propertyNameStringThe name of the property to set.PowerSwitch
propertyValueObjectThe value of the property to set.1

action/device/setProperty example

{
    "uri":"action/device/setProperty",
    "params":{
        "iotId":"xxxx",
        "propertyName":"PowerSwitch",
        "propertyValue":1
    }
}

action/automation/setSwitch parameters

ParameterTypeDescriptionExample
automationRuleIdStringThe ID of the scene to enable or disable.None
switchStatusInteger0 indicates disable, and 1 indicates enable.1

action/automation/setSwitch example

{
    "uri":"action/automation/setSwitch",
    "params":{
        "automationRuleId":"xxxx",
        "switchStatus":0
    }
}

CaCondition component

The supported CaCondition components include the following:

URLDescription Logic
condition/timerTimer. The function and parameters are the same as the trigger/timer component in the IFTTT type.
condition/timeRangeTime range. The function is the same as condition/timeRange in the IFTTT type.

It can only be used in all mode and is ignored in any mode.

Note The parameter format for the condition/timeRange node in the CA type is different from the one in the IFTTT type.
condition/device/propertyDevice property. The function and parameters are the same as trigger/device/property in the IFTTT type.

condition/timeRange parameters

ParameterTypeDescription
formatStringThe time format, such as HH:mm.
timezoneIDStringThe time zone ID. This parameter is optional. It specifies the time zone for the time range check. If not set, it defaults to the time zone of the IoT Platform service. We recommend that you set this parameter to specify a time zone.
beginDateStringThe start time. It must match the specified format. For example, if format is HH:mm, you can set beginDate to 12:30.
endDateStringThe end time. It must match the specified format. For example, if format is HH:mm, you can set endDate to 13:30.
Note If beginDate is later than endDate, the time range is considered to cross over to the next day. For example, if beginDate is 22:00 and endDate is 6:00, the range is from 22:00 on one day to 6:00 on the next day.
repeatStringThe days of the week for repetition. It is a string of numbers from 1 to 7, separated by commas. This parameter is optional. If not specified, the action does not repeat. For example, 1,2,3 means repeat on Monday, Tuesday, and Wednesday.

condition/timeRange format values

ValueDescription
mm:ssMinutes and seconds
HH:mmHour:Minute
HH:mm:ssHour:Minute:Second
dd HHDay:Hour
dd HH:mmDay:Hour:Minute
dd HH:mm:ssDay:Hour:Minute:Second
MMMonth
MM-ddMonth-Day
MM-dd HHMonth-Day Hour
MM-dd HH:mmMonth-Day Hour:Minute
MM-dd HH:mm:ssMonth-Day Hour:Minute:Second
yyyy-MM-ddYear-Month-Day
yyyy-MM-dd HH:mm:ssYear-Month-Day Hour:Minute:Second

condition/timeRange example

{
    "uri":"condition/timeRange",
    "params":{
        "format":"HH:mm",
        "beginDate":"8:30",
        "endDate":"23:00",
        "repeat":"1,2,3,4,5"
    }
}

Rule limits

The following limits apply to scene rules:

  • A Trigger component is optional. If a trigger is not included, the scene is not automatically triggered and must be executed manually by calling the Execute a scene API. For example, a scene that contains only a condition/timeRange component without a trigger must be executed manually.
  • A Condition component is optional. If a condition is not included, the Action is executed immediately when the Trigger is activated.
  • An Action component is required.
  • A user can create a maximum of 200 scenes.
  • A rule can have a maximum of 10 Triggers.
  • A rule can have a maximum of 5 Conditions.
  • A rule can have a maximum of 10 Actions.
  • A device can be the target of an action in a maximum of 20 scenes.
  • A rule can have only one trigger/timer component.
  • A rule can have only one condition/timeRange component.
  • For CA rules, the condition/timeRange component is supported only when the mode is 'all'. The component is ignored when the mode is 'any'.

Create a scene

Description

PathVersionDescriptionLogon required
/scene/create1.0.5Create a scene.Yes

Request parameters

ParameterTypeRequiredDescription
groupIdStringYesUsed to classify scenes. For a manual scene, which contains only an Action, set groupId to 0. For an automation scene, which contains a Trigger and a Condition in addition to an Action, set groupId to 1.
enableBooleanYesSpecifies whether to enable the scene upon creation. true indicates enable, and false indicates disable.
nameStringYesThe name of the scene given by the user.
iconStringYesThe download link for the scene icon.
iconColorStringYesThe color of the scene icon, for example, #FFFFFF.
descriptionStringNoA description of the scene.
triggersObjectNoThe trigger object of the IFTTT rule.
conditionsObjectNoThe condition object of the IFTTT rule.
caConditionsJSON ArrayNoThe condition object of the CA rule.
actionsJSON ArrayYesThe action object.
sceneTypeStringNoThe scene rule type. Valid values are IFTTT and CA. The default value is IFTTT.
modeStringNoThe mode of the CA rule. Valid values are all and any. all means the action is executed only when all conditions in caConditions are met. any means the action is executed if any condition in caConditions is met.

Response parameters

ParameterTypeDescription
sceneIdStringThe ID of the created scene.

Examples

  • Example request to create a scene with a CA rule
    {
        "groupId":"1",
        "enable":true,
        "name":"ilopTestScene",
        "icon":"http://www.aliyundoc.com/***.png",
        "iconColor":"#FFFFFF",
        "caConditions":[
            {
                "params":{
                    "cron":"42 00 * * *",
                    "cronType":"linux",
                    "timezoneId":"Asia/Shanghai"
                },
                "uri":"condition/timer"
            },
            {
                "params":{
                    "compareValue":0,
                    "compareType":"==",
                    "propertyName":"PowerSwitch",
                    "productKey":"xxxx",
                    "deviceName":"xxxx"
                },
                "uri":"condition/device/property"
            }
        ],
        "actions":[
            {
                "params":{
                    "iotId":"xxxx",
                    "propertyName":"PowerSwitch",
                    "propertyValue":1
                },
                "uri":"action/device/setProperty"
            }
        ],
        "sceneType":"CA",
        "mode":"all"
    }
  • Example request to create a scene with an IFTTT rule (single trigger, single condition)
    {
        "sceneType":"IFTTT",
        "enable":true,
        "groupId":"1",
        "name":"TestScene",
        "icon":"http://www.aliyundoc.com/***.png",
        "iconColor":"#FFFFFF",
        "triggers":{
            "params":{
                "cron":"42 00 * * *",
                "cronType":"linux",
                "timezoneId":"Asia/Shanghai"
            },
            "uri":"trigger/timer"
        },
        "conditions":{
            "uri":"logical/and",
            "items":[
                {
                    "params":{
                        "cron":"20-25 11-23 * * 1,2,3",
                        "cronType":"linux",
                        "timezoneID":"Asia/Shanghai"
                    },
                    "uri":"condition/timeRange"
                }
            ]
        },
        "actions":[
            {
                "params":{
                    "iotId":"xxxx",
                    "propertyName":"PowerSwitch",
                    "propertyValue":1
                },
                "uri":"action/device/setProperty"
            }
        ]
    }
  • Example request to create a scene with an IFTTT rule (multiple triggers, multiple conditions)
    {
        "sceneType":"IFTTT",
        "enable":true,
        "groupId":"1",
        "name":"testScene",
        "icon":"http://www.aliyundoc.com/***.png",
        "iconColor":"#FFFFFF",
        "triggers":{
            "uri":"logical/or",
            "items":[
                {
                    "params":{
                        "cron":"42 00 * * *",
                        "cronType":"linux",
                        "timezoneId":"Asia/Shanghai"
                    },
                    "uri":"trigger/timer"
                },
                {
                    "params":{
                        "iotId":"testIotId",
                        "propertyName":"PowerSwitch",
                        "compareType":"==",
                        "compareValue":0
                    },
                    "uri":"trigger/device/property"
                }
            ]
        },
        "conditions":{
            "uri":"logical/and",
            "items":[
                {
                    "params":{
                        "cron":"20-25 11-23 * * 1,2,3",
                        "cronType":"linux",
                        "timezoneID":"Asia/Shanghai"
                    },
                    "uri":"condition/timeRange"
                },
                {
                    "params":{
                        "iotId":"testIotId",
                        "propertyName":"PowerSwitch",
                        "compareType":"==",
                        "compareValue":0
                    },
                    "uri":"condition/device/property"
                }
            ]
        },
        "actions":[
            {
                "params":{
                    "iotId":"testIotId",
                    "propertyName":"PowerSwitch",
                    "propertyValue":1
                },
                "uri":"action/device/setProperty"
            }
        ]
    }
  • Example of a successful response
    {
        "code": 200,
        "data": "sceneId",
        "message": "success"
    }

Update a scene

Description

PathVersionDescriptionLogon required
/scene/update1.0.5Update a scene.Yes

Request parameters

ParameterTypeRequiredDescription
groupIdStringYesUsed to classify scenes. For a manual scene, which contains only an Action, set groupId to 0. For an automation scene, which contains a Trigger and a Condition in addition to an Action, set groupId to 1.
Note The groupId is specified when the scene is created and cannot be modified afterward. You cannot change a manual scene to an automation scene by modifying the groupId.
sceneIdStringYesScene ID.
enableBooleanYestrue indicates enable the scene. false indicates disable the scene.
nameStringYesThe name of the scene.
iconStringYesThe URL of the scene icon.
iconColorStringYesThe color of the scene icon.
descriptionStringNoA description of the scene.
triggersObjectNoThe trigger object of the IFTTT rule.
conditionsObjectNoThe condition object of the IFTTT rule.
caConditionsArrayNoThe condition object of the CA rule.
actionsArrayYesThe action object.
sceneTypeStringNoThe scene rule type. Valid values are IFTTT and CA. The default value is IFTTT.
modeStringNoThe mode of the CA rule. Valid values are all and any.

Response parameters

ParameterTypeDescription
sceneIdStringUpdated Scenario ID

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.1",
            "iotToken": "token"
        },
        "params": {
        "enable" : true,
        "iconColor" : "#DE4545",
        "reBind" : true,
        "mode" : "any",
        "caConditions" : [
          {
            "uri" : "condition\/timer",
            "params" : {
              "cron" : "33 10 * * 1,2,3,4",
              "cronType" : "linux"
            }
          }
        ],
        "sceneType" : "CA",
        "icon" : "http:\\www.aliyundoc.com/***.png",
        "sceneId" : "2420d2xxxxf93c54fc4e",
        "groupId" : "1",
        "name" : "10:27 Mon Tue - Power Switch On",
        "actions" : [
          {
            "uri" : "action\/device\/setProperty",
            "params" : {
              "iotId" : "uumR5xxxx00101",
              "propertyName" : "PowerSwitch",
              "propertyValue" : 1
            }
          }
        ]
      }
    }          
  • Example of a successful response
    {
        "code": 200,
        "data": "bdc60bexxxxd617697",
        "message": "success"
    }
                        

Delete a scene

Description

PathVersionDescriptionLogon required
/scene/delete1.0.2Delete a scene.Yes

Request parameters

ParameterTypeRequiredDescription
sceneIdStringYesScene ID.

Response parameters

ParameterTypeDescription
sceneIdStringThe ID of the deleted scene.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.1",
            "iotToken": "token"
        },
        "params": {
            "sceneId": "0c965xxxx5306a6657",
            "groupId": null
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "data": "0c9653xxxx06a6657",
        "message": "success"
    }
                        

Query a list of scenes or automations

Description

PathVersionDescriptionLogon required
/scene/list/get1.0.5Query a list of scenes.Yes

Request parameters

ParameterTypeRequiredDescription
groupIdStringYes0 = Scene, 1 = Automation.
pageNoIntegerYesThe page number. Must be greater than or equal to 1.
pageSizeIntegerYesThe number of items per page. Must be between 1 and 50.

Response parameters

ParameterSub-parameterTypeDescription
totalIntegerTotal number of items.
pageNoIntegerThe page number, starting from 1.
pageSizeIntegerThe number of items per page.
scenesArrayReturns the entries for the current page.
scenes.idStringScene ID.
scene.statusIntegerThe runtime status of the scene: 1 - Scene is online. 2 - Scene is offline.
scene.enableBooleanThe scene switch (the switch in the app): true - Scene is on. false - Scene is off.
scene.iconStringThe link to the scene icon.
scene.iconColorStringThe color of the scene icon.
scene.nameStringScene name.
scene.descriptionStringScene description.
scene.validBooleanIndicates whether the scene is valid.
scene.groupIdStringType: null (Legacy scenario), 0 (Scenario), or 1 (Automation).

Examples

  • Example request
    {
      "id": "1509086454180",
      "version": "1.0",
      "request": {
        "apiVer": "1.0.1",
        "iotToken": "token"
      },
      "params": {
        "groupId": "1",
        "pageSize": 20,
        "pageNo": 1,
      }
    }
  • Example of a successful response
    {
      "code": 200,
      "data": {
        "pageNo": 1,
        "pageSize": 20,
        "scenes": [{
          "description": "Electric blanket-hy-Signal-to-noise ratio--127 ",
          "enable": true,
          "icon": "https://g.aliplus.com/scene_icons/default.png",
          "id": "260de82dxxxx691be22",
          "name": "Electric Blanket",
          "status": 2,
          "iconColor":"#19BBFF",
          "valid":false,
          "groupId":"1"
    
        }, {
          "description": "light-hy-LightSwitch-1, shuijin-hy-WiFI_SNR--127 ",
          "enable": true,
          "icon": "https://g.aliplus.com/scene_icons/default.png",
          "id": "45dc6fcxxxx6974e5f7",
          "name": "Liang Gong",
          "status": 1,
            "iconColor":"#19BBFF",
          "valid":true,
          "groupId":"1"
        }, {
          "description": "fan-hy-PowerSwitch-Off, light-hy-LightSwitch-1 ",
          "enable": true,
          "icon": "https://g.aliplus.com/scene_icons/default.png",
          "id": "3ce636xxxx1367f2dc88",
          "name": "Fan Light 0522",
          "status": 1,
           "iconColor":"#19BBFF",
          "valid":false,
          "groupId":"1"
        }, {
          "description": "light-hy-LightSwitch-1 ",
          "enable": true,
          "icon": "https://g.aliplus.com/scene_icons/default.png",
          "id": "5b4bdexxxx2612f81",
          "name": "Light 0522",
          "status": 2,
            "iconColor":"#19BBFF",
          "valid":false,
          "groupId":"1"
        }],
        "total": 4
      },
      "message": "success"
    }

Query lists of scenes and automations at the same time

Description

PathVersionDescriptionLogon required
/scene/list/all1.0.0Queries all scene information on the My Smart page, including scenes and automations.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
pageNoIntegerNoThe current page number. The default value is 1.
pageSizeIntegerYesThe page size. Must be greater than or equal to 1 and less than or equal to 30.

Response parameters

ParameterLevel 2 sub-parameterLevel 3 sub-parameterLevel 4 sub-parameterTypeDescription
dataStringList of scenes and automations.
scene0StringScene list information.
totalIntegerTotal number of scenes.
pageNoIntegerReturns the current page number.
pageSizeIntegerThe returned page size.
scenesStringScene list.
idStringScene ID.
nameStringScene name.
descriptionStringScene description.
enableBooleanThe scene switch (the switch in the app): true - Scene is on. false - Scene is off.
iconStringThe link to the scene icon.
iconColorStringThe color of the scene icon.
groupIdStringClassification. 0 indicates a scene. 1 indicates an automation.
validBooleanIndicates whether the scene is valid. When a device in a scene is detached, the automation becomes invalid, and this field is set to true.
scene1StringAutomation list information.
totalIntegerTotal number of automations.
pageNoIntegerThe returned page number.
pageSizeIntegerThe returned page size.
scenesStringAutomation list.
idStringAutomation ID.
nameStringAutomation name.
descriptionStringAutomation description.
enableBooleanThe automation switch (the switch in the app): true - Scene is on. false - Scene is off.
iconStringAutomation icon.
iconColorStringAutomation icon color
groupIdStringClassification. 0 indicates a scene. 1 indicates an automation.
validBooleanIndicates whether the automation is valid. When a device in an automation is detached, the automation becomes invalid, and this field is set to true.

Examples

  • Example request
    {
     "id": "1509086454180",
     "version": "1.0",
     "request": {
      "apiVer": "1.0.0",
      "iotToken": "token"
     },
     "params": {
     "pageNum": 1,
      "pageSize": 10
     }
    }
  • Example of a successful response
    {
     "code": 200,
     "data": {
        "scene0": {
            "total": 1,
            "scenes": [
                {
                    "id": "",
                    "name": "",
                    "description": "",
                    "enable": true,
                    "icon": "",
                    "iconColor": "",
                    "groupId": "0",
                    "valid": true
                }
            ],
            "pageNo": 1,
            "pageSize": 10
        },
        "scene1": {
            "total": 0,
            "scenes": [],
            "pageNo": 1,
            "pageSize": 10
        } 
      },
     "message": "success"
    }

Change the sort order of items in a scene list

Description

PathVersionDescriptionLogon required
/scene/list/reorder1.0.5Change the sort order of items in a scene list.Yes

Request parameters

ParameterTypeRequiredDescription
groupIdStringYes0 - Scene. 1 - Automation.
newOrdersArrayYesAn array of scenes with changed ordinal numbers.
newOrders.sceneIdStringYesScene ID.
newOrders.fromOrderIntegerYesThe ordinal number before the order change.
newOrders.toOrderIntegerYesThe new ordinal number.

Response parameters

ParameterTypeDescription
codeIntegerThe status of a successful operation.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.1",
            "iotToken": "token"
        },
        "params": {
            "groupId": null,
            "newOrders": [{
                "fromOrder": 1,
                "sceneId": "a596dexxxx9685d25",
                "toOrder": 2
            }, {
                "fromOrder": 2,
                "sceneId": "c1a8de4xxxxb473c3",
                "toOrder": 1
            }]
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "message": "success"
    }
                        

Execute a scene

Description

PathVersionDescriptionLogon required
/scene/fire1.0.2Execute a scene.Yes

Request parameters

ParameterTypeRequiredDescription
sceneIdStringYesThe ID of the scene to trigger.

Response parameters

ParameterTypeDescription
sceneIdStringThe ID of the triggered scene.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.1",
            "iotToken": "token"
        },
        "params": {
            "groupId": null,
            "sceneId": "debf2dxxxx51496c2"
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "data": "debf2dxxxx51496c2",
        "message": "success"
    }
                        

Get a scene log list

Description

PathVersionDescriptionLogon required
/scene/log/list/get1.0.2Get a scene log list.Yes

Request parameters

ParameterTypeRequiredDescription
pageNoIntegerYesThe requested page number. Must be greater than or equal to 1.
pageSizeIntegerYesThe number of items to pull at a time.
nowTimeLongYesThe start time for the log query (in milliseconds). Refer to the scene log query method.

To view logs from a different time period, you must start a new query. Specify the new time period, set pageNo to 1, and execute the query again. This method can query scene logs within a 15-day time range.

Response parameters

ParameterTypeDescription
pageNoIntegerThe requested page number. Must be greater than or equal to 1.
pageSizeIntegerThe number of items to pull at a time.
totalIntegerTotal number.
logsArrayThe log list, returned in descending order of time.
logs.timeLongLog time, a timestamp in milliseconds.
logs.iconStringScene icon.
logs.sceneIdStringScene ID.
logs.idStringLog ID.
logs.sceneNameStringScene name.
logs.resultIntegerExecution result: 0 - Failed. 1 - Successful.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.1",
            "iotToken": "token"
        },
        "params": {
            "pageNo": 1,
            "pageSize": 5,
            "groupId": null,
            "nowTime": 1527129084824
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "data": {
            "logs": [{
                "icon": "https://g.aliplus.com/scene_icons/default.png",
                "id": "0bc19f5d15xxxx56576d52bf",
                "result": 0,
                "sceneId": "d5edf3a8xxxx91b15e2028",
                "sceneName": "t time device",
                "time": 1527091200000
            }, {
                "icon": "https://g.aliplus.com/scene_icons/default.png",
                "id": "0bc19f5xxxx056577d52bf",
                "result": 0,
                "sceneId": "81eb22a2991xxxx2d0993ce",
                "sceneName": "t time",
                "time": 1527091200000
            }, {
                "icon": "https://g.aliplus.com/scene_icons/default.png",
                "id": "0bc19f5d15xxxx75d52bf",
                "result": 0,
                "sceneId": "3f522ebxxxx12336709",
                "sceneName": "test",
                "time": 1527091200000
            }, {
                "icon": "https://g.aliplus.com/scene_icons/default.png",
                "id": "0bc19fxxxx578d52bf",
                "result": 0,
                "sceneId": "32020xxxx757ee3",
                "sceneName": "t time device",
                "time": 1527091200000
            }, {
                "icon": "https://g.aliplus.com/scene_icons/default.png",
                "id": "0bc19f5xxxx14d52bf",
                "result": 1,
                "sceneId": "70d90fexxxx997188911",
                "sceneName": "light",
                "time": 1527054987000
            }],
            "pageNo": 1,
            "pageSize": 5,
            "total": 62
        },
        "message": "success"
    }
                        

Get failed log details

Description

PathVersionDescriptionLogon required
/scene/failedlog/get1.0.4Get failed log details.Yes

Request parameters

ParameterTypeRequiredDescription
logIdStringYesThe ID of the log to query.
sceneIdStringYesScene ID.
timeLongYesThe logs.time returned by /scene/log/list/get, in milliseconds.
pageNoIntegerYesThe requested page number. The first page is 1.
pageSizeIntegerYesThe number of items to pull at a time.

Response parameters

ParameterTypeDescription
totalIntegerTotal number.
pageSizeIntegerThe number of items to pull at a time.
pageNoIntegerThe requested page number. Must be greater than or equal to 1.
detailsArrayNone
details.productKeyStringA list of details for failed devices.
details.localizedProductNameStringLocalized product information.
details.deviceNameStringDevice name
details.aliasNameStringThe name given to the device by the user.
details.failedReasonStringError message. If the action is to set a property, the text rule is: {Product Name}-{Property Name}-{Property Value} execution failed. If the action is to call a service, the text rule is: {Product Name}-{Service Name} execution failed.
details.detailStringThe reason for the subscript annotation.
details.iconStringIcon.

Examples

  • Example request
    {
        "id": "150xxxx4180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.1",
            "iotToken": "token"
        },
        "params": {
            "pageNo": 1,
            "pageSize": 1000,
            "logId": "0bc19xxxx00056576d52bf",
            "sceneId": "d5edf3xxxx91b15e2028",
            "time": 1527091200000
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "data": {
            "details": [{
                "detail": "light-hy - NightLightSwitch - Off1 Set device parameters",
                "deviceName": "hyxxxxhy",
                "failedReason": "device in scene's action is unbind",
                "productKey": "b1xxxxrm"
            }],
            "pageNo": 1,
            "pageSize": 1000
        },
        "message": "success"
    }
                        

Get scene details

Description

PathVersionDescriptionLogon required
/scene/info/get1.0.5Get scene details.Yes

Request parameters

ParameterTypeRequiredDescription
sceneIdStringYesThe ID of the scene to query.
groupIdStringNoScene type:
  • 0: Scene
  • 1: Automation

Response parameters

ParameterTypeDescription
sceneIdStringScene ID.
enableBooleanThe status of the scene switch. Valid values:
  • true: On. The scene can be triggered and executed normally.
  • false: Off. The scene will not be executed even if the trigger conditions are met.
nameStringThe name of the scene given by the user.
iconStringScene icon.
iconColorStringThe color of the scene icon.
descriptionStringA description of the scene.
triggersJsonObjectThe JSON serialization of the complex object within the Trigger of an IFTTT rule. Used for frontend display.
conditionsObjectThe condition object of the IFTTT rule.
caConditionsJsonArraySince Scene Service 2.0. The JSON serialization of the complex object within the Condition of a CA rule. Used for frontend display.
actionsJsonStringThe JSON serialization of the complex object within the Action. Used for frontend display.
sceneTypeStringSince Scene Service 2.0. Scene rule: IFTTT or CA (default is IFTTT).
modeStringSince Scene Service 2.0. The mode of the CA rule: all or any.
validBooleanIndicates whether the scene is valid.

Enable and disable a scene

Description

PathVersionDescriptionLogon required
/living/scene/switch1.0.0Enable/disable a scene automation.Yes

Request parameters

ParameterTypeRequiredDescription
sceneIdStringYesScene ID.
enableBooleanYesThe status of the scene switch. Valid values:
  • true: On. The scene can be triggered and executed normally.
  • false: Off. The scene will not be executed even if the trigger conditions are met.

Response parameters

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.0",
            "iotToken": "token"
        },
        "params": {
            "sceneId": "0c96536xxxxc5306a6657",
            "enable": true
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "message": "success"
    }
                        

Get a list of devices that support trigger/condition/action configurations for the current user

Description

PathVersionDescriptionLogon requiredNotes
/scene/thing/list1.0.2Query for a list of devices that support T/C/A.Yes. The client SDK must enable identity authentication.Includes shared devices.

Request parameters

ParameterTypeRequiredDescription
flowTypeIntegerYesFlow type: 0 - trigger. 1 - condition. 2 - action.
pageNumIntegerYesThe page number for pagination, starting from 1.
pageSizeIntegerYesThe page size for pagination.

Response parameters

ParameterTypeDescription
pageNoIntegerThe page number, starting from 1.
pageSizeIntegerThe maximum number of items per page.
totalLongTotal number of records.
dataListDevice list.
Structure of the data list
ParameterTypeDescription
iotIdStringDevice ID.
deviceNameStringDevice name
productKeyStringProduct key
nickNameStringDevice nickname.
imageStringThe URL of the category icon.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.1",
            "iotToken": "token"
        },
        "params": {
            "flowType": 0,
            "pageNum": 1,
            "pageSize": 20
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "data": {
            "pageNo": 1,
            "pageSize": 20,
            "total":1,
            "data": [{
                "iotId": "45dc6xxxxf6974e5f7",
                "deviceName": "xxxx",
                "productKey": "xxxx",
                "nickName": "Test Device",
                "image": "https://g.aliplus.com/scene_icons/default.png"
            }]
        },
        "message": "success"
    }
                        

Get a list of functional properties that support trigger/condition/action configurations on a device

Description

PathVersionDescriptionLogon required
/iotid/scene/ability/list1.0.2Query for a list of features that support T/C/A on a device.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesDevice ID.
flowTypeIntegerYesFlow type: 0 - trigger. 1 - condition. 2 - action.

Response parameters

ParameterTypeDescription
nameStringFeature name.
identifierStringFeature identifier.
categoryTypeStringCategory name.
typeIntegerFeature type: 1 - Property. 2 - Service. 3 - Event.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.1",
            "iotToken": "token"
        },
        "params": {
            "iotId": "45dc6fxxxx29f6974e5f7",
            "flowType": 0
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "data": [{
                "name": "Switch",
                "identifier": "switch",
                "categoryType": "xxxx",
                "type": 1
        }],
        "message": "success"
    }
                        

Get the trigger, condition, or action feature list and TSL definition of a device

Description

PathVersionDescriptionLogon required
/iotid/scene/ability/tsl/list1.0.2Query for a list of features that support T/C/A on a device and the corresponding TSL information.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesDevice ID.
flowTypeIntegerYesFlow type: 0 - trigger. 1 - condition. 2 - action.

Response parameters

ParameterTypeDescription
simplifyAbilityDTOsListList of feature definitions.
abilityDslJSONObjectProduct feature TSL (for reference).
Structure of simplifyAbilityDTOs
ParameterTypeDescription
nameStringFeature name.
identifierStringFeature identifier.
categoryTypeStringCategory name.
typeIntegerFeature type: 1 - Property. 2 - Service. 3 - Event.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.1",
            "iotToken": "token"
        },
        "params": {
            "iotId": "45dc6fxxxx6974e5f7",
            "flowType": 0
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "data": {
          "simplifyAbilityDTOs":[{
                "name": "Switch",
                "identifier": "switch",
                "categoryType": "xxxx",
                "type": 1
           }],
          "abilityDsl": {}
        },
        "message": "success"
    }
                        

Create a scheduled timed scene

Description

PathVersionDescriptionUser identity authentication required
/scene/timing/create1.0.2Create a scheduled timed scene for a device.Yes. The client SDK must enable identity authentication.
Note Scheduled timed scenes are associated with devices and cannot be updated, enabled, or disabled using APIs such as /scene/update or /living/scene/switch. Instead, use the /scene/timing/update API. Additionally, these scenes do not support pushing messages to mobile phones as an action.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesDevice ID.
enableBooleanYestrue for on, false for off.
nameStringYesThe name of the scene given by the user.
iconStringYesScene icon.
descriptionStringNoA description of the scene.
triggersObjectNoThe trigger object.
conditionsObjectNoThe condition object.
actionsArrayYesAction object
Note An action is required. The trigger and condition are optional.

Response parameters

ParameterTypeDescription
sceneIdStringThe ID of the new scene.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.2",
            "iotToken": "token"
        },
        "params": {
            "actions": [{
                "params": {
                    "compareValue": 1,
                    "iotId": "zjoOvFxxxxc4dc00",
                    "compareType": ">",
                    "propertyName": "Qxxxxat",
                    "propertyValue": 1
                },
                "uri": "action/device/setProperty"
            }],
            "iotId":"zjoOvFZxxxx4dc00",
            "enable": true,
            "icon": "https://g.aliplus.com/scene_icons/default.png",
            "name": "Same",
            "triggers": {
                "params": {},
                "items": [{
                    "params": {
                        "cron": "1 1 * * *",
                        "cronType": "linux",
                        "timezoneID": "Asia/Shanghai"
                    },
                    "uri": "trigger/timer"
                }],
                "uri": "logical/or"
            }
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "data": "0c9653xxxx645c5306a6657",
        "message": "success"
    }
                        

Update a scheduled timed scene

Description

PathVersionDescriptionUser identity authentication required
/scene/timing/update1.0.2Update a scheduled timed scene for a device.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesDevice ID.
sceneIdStringYesScene ID.
enableBooleanYestrue for on, false for off.
nameStringYesThe name of the scene given by the user.
iconStringYesScene icon.
descriptionStringNoA description of the scene.
triggersObjectNoThe trigger object.
conditionsObjectNoCondition object
actionsArrayYesTarget object
Note An action is required. The trigger and condition are optional.

Response parameters

ParameterTypeDescription
sceneIdStringScene ID.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.2",
            "iotToken": "token"
        },
        "params": {
            "actions": [{
                "params": {
                    "compareValue": 0,
                    "iotId": "gaI0CRxxxx09b3700",
                    "compareType": {
                        "i18nKey": "scene.common.compareType.equal",
                        "type": "=="
                    },
                    "propertyName": "Nigxxxxwitch",
                    "propertyValue": 0
                },
                "uri": "action/device/setProperty",
                "status": 1
            }],
            "conditions": {
                "params": {},
                "items": [{
                    "params": {
                        "compareValue": 0,
                        "iotId": "gaI0Cxxxx09b3700",
                        "compareType": "==",
                        "propertyName": "LightSwitch",
                        "propertyValue": 0
                    },
                    "uri": "condition/device/property",
                    "status": 1
                }],
                "uri": "logical/and"
            },
            "enable": true,
            "icon": "https://g.aliplus.com/scene_icons/default.png",
            "name": "",
            "sceneId": "bdc60xxxx7d617697",
            "iotId": "gaI0CRKxxxx09b3700",
            "triggers": {
                "params": {},
                "items": [{
                    "params": {
                        "cron": "0 0 * * *",
                        "cronType": "linux",
                        "timezoneID": "Asia/Shanghai"
                    },
                    "uri": "trigger/timer",
                    "status": 1
                }],
                "uri": "logical/or"
            }
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "data": "0c9653xxxx06a6657",
        "message": "success"
    }
                        

Delete a scheduled timed scene

Description

PathVersionDescriptionUser identity authentication required
/scene/timing/delete1.0.2Delete a timed scene.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesDevice ID.
sceneIdStringYesScene ID.

Response parameters

ParameterTypeDescription
sceneIdStringThe ID of the deleted scene.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.2",
            "iotToken": "token"
        },
        "params": {
            "sceneId": "0c96xxxx306a6657",
            "iotId": "gaI0Cxxxx109b3700"
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "data": "0c9653xxxx06a6657",
        "message": "success"
    }
                        

Get scheduled timed scene details

Description

PathVersionDescriptionUser identity authentication required
/scene/timing/info/get1.0.2Get timed scene details.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesDevice ID.
sceneIdStringYesThe ID of the scene to query.

Response parameters

ParameterTypeDescription
sceneIdStringScene ID.
enableBooleanScene switch: true - On. false - Off.
statusIntegerScene runtime status: 1 - Running. 2 - Invalid.
nameStringThe name of the scene given by the user.
iconStringScene icon.
triggersObjectA string of the triggers object. The trigger object is defined below.
conditionsObjectA string of the conditions object.
actionsArrayA string of the actions object.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.2",
            "iotToken": "token"
        },
        "params": {
            "sceneId": "260de8xxxx4691be22",
            "iotId": "gaI0Cxxxx9b3700"
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "data": {
            "actions": [{
                "params": {
                    "compareValue": -127,
                    "localizedProductName": "Electric blanket-hy",
                    "iotId": "SY7a6Ixxxx0c00",
                    "compareType": "==",
                    "propertyName": "WiFI_SNR",
                    "localizedPropertyName": "Signal-to-noise ratio",
                    "deviceNickName": "Electric blanket-hy",
                    "propertyValue": -127,
                    "localizedCompareValueName": "-127",
                    "productKey": "b1xxxxql",
                    "propertyItems": {
                        "WiFI_SNR": -127
                    },
                    "deviceName": "hyhyhy4"
                },
                "uri": "action/device/setProperty",
                "status": 0
            }],
            "enable": true,
            "icon": "https://g.aliplus.com/scene_icons/default.png",
            "name": "Electric Blanket",
            "sceneId": "260de82dxxxx4691be22",
            "status": 2
        },
        "message": "success"
    }
    

Query a list of scheduled timed scenes for a device

Description

PathVersionDescriptionUser identity authentication required
/scene/timing/list/get1.0.2Query a list of timed scenes.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesDevice ID.
pageNoIntegerYesThe page number. Must be greater than or equal to 1.
pageSizeIntegerYesThe number of items per page. Must be between 1 and 50.

Response parameters

ParameterSub-parameterTypeDescription
totalIntegerTotal number of items.
pageNoIntegerThe page number, starting from 1.
pageSizeIntegerThe number of items per page.
scenesArrayReturns the entries on the current page.
scenes.idStringScene ID.
scene.statusIntegerThe runtime status of the scene: 1 - Scene is online. 2 - Scene is offline.
scene.enableBooleanThe scene switch (the switch in the app): true - Scene is on. false - Scene is off.
scene.iconStringScenario Icon Link
scene.nameStringScene name.
scene.descriptionStringScene description.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.2",
            "iotToken": "token"
        },
        "params": {
            "pageSize": 20,
            "pageNo": 1,
            "iotId": "zjoOvFZxxxx0c4dc00"
        }
    }   
  • Example of a successful response
    {
        "code": 200,
        "data": {
            "pageNo": 1,
            "pageSize": 20,
            "scenes": [{
                "description": "Electric blanket-hy-Signal-to-noise ratio--127 ",
                "enable": true,
                "icon": "https://g.aliplus.com/scene_icons/default.png",
                "id": "260de82xxxx691be22",
                "name": "Electric Blanket",
                "status": 2
            }, {
                "description": "light-hy-LightSwitch-1, shuijin-hy-WiFI_SNR--127 ",
                "enable": true,
                "icon": "https://g.aliplus.com/scene_icons/default.png",
                "id": "45dc6fcxxxx6974e5f7",
                "name": "Liang Gong",
                "status": 1
            }],
            "total": 2
        },
        "message": "success"
    }  

Get scene details in batches

Description

PathVersionDescriptionUser identity authentication required
/living/scene/batchget1.0.0Request scene information in batches.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
sceneIdListlistYesA list of scene IDs to query.

Response parameters

ParameterTypeDescription
sceneIdStringScene ID.
enableBooleanScene switch: true - On. false - Off.
nameStringThe name of the scene given by the user.
iconStringScene icon.
triggersStringA string of the triggers object.
conditionsStringA string of the conditions object.
actionsStringA string of the actions object.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.0",
            "iotToken": "token"
        },
        "params": 
      {"sceneIdList":["b8fe2xxxx26b76c31"]}
    }
                        
  • Example of a successful response
    {
      "code":200,
      "data":
      [
      {"sceneType":"IFTTT",
      "name":"Main Light Switch On - Light Mode mono - On",
      "icon":"https://img.alicdn.com/tfs/TB10G8xxxxUVXa-144-144.png",
      "sceneId":"b8fexxxx26b76c31",
      "sceneSwitch":1,
      "triggers":"{\"params\":{},\"items\":[{\"params\":{\"eventCode\":\"\",\"compareValue\":1,\"iotId\":\"z8nxxxx00101\",\"compareType\":\"==\",\"propertyName\":\"LightSwitch\",\"propertyValue\":1,\"productKey\":\"a1B0kMs35NW\",\"deviceName\":\"z8nxxxx6SFY\"},\"uri\":\"trigger/device/property\"}],\"uri\":\"logical/or\"}",
      "conditions":"{\"params\":{},\"items\":[{\"params\":{\"eventCode\":\"\",\"compareValue\":0,\"iotId\":\"z8nqxxxx000101\",\"compareType\":\"==\",\"propertyName\":\"LightMode\",\"propertyValue\":0,\"productKey\":\"a1B0kMs35NW\",\"deviceName\":\"z8nxxxx6SFY\"},\"uri\":\"condition/device/property\"}],\"uri\":\"logical/and\"}",
      "actions":"[{\"params\":{\"switchStatus\":1,\"automationRuleId\":\"50xxxx520ceed\"},\"uri\":\"action/automation/setSwitch\"}]"}
      ],
      "id":"1509086454180"
    }
                        

Push message to mobile phone action

Description

PathDescriptionUser identity authentication required
/action/mq/sendPush message to mobile phone actionYes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
customDataCustomDataYesPush message model.
customData. messageStringYesThe content of the message to push to the mobile phone. Up to 60 characters.
msgTagStringYesPush message model. Default value: IlopBusiness_CustomMsg.

Return parameters

Examples

  • Example request
    "actions": [
        {
            "uri":"action/mq/send",
            "params":{
                "customData":{
                    "message":"Power is on"
                },
                "msgTag":"IlopBusiness_CustomMsg"
            }
        }
    ]
                        
  • Example of a successful response

    None.

Query scenes for smart widgets

Description

PathVersionDescriptionLogon required
/living/appwidget/list1.0.0Smart widget query. Used to query component information in the scene quick trigger widget of the app.Yes

Request parameters

Response parameters

ParameterTypeDescription
idStringScene ID.
nameStringScene name.
descriptionStringScene description.
enableBooleanIndicates whether the scene is enabled.
iconStringScene icon.
iconColorStringThe color of the scene icon.
validBooleanIndicates whether the scene is valid.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.0",
            "iotToken": "token"
        },
        "params": {
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "message": "success"
          "data":[{
            "id": "d5edf3xxxxb15e2028",
            "iconColor": "#19BBFF",
            "name": "Send notification to mobile phone",
            "description": " Description ",
            "enable": true
        },
        {
            "id": "debf2dxxxx1496c2",
            "iconColor": "#FFBBFF",
            "name": "Turn on light",
            "description": "Description",
            "enable": false
        }
    ]
    }
                        

Add scenes for smart widgets

Description

PathVersionDescriptionLogon required
/living/appwidget/create1.0.0Smart widget add. Used to add components in the scene quick trigger widget of the app.Yes

Request parameters

Response parameters

ParameterTypeDescription
sceneIdsArrayA list of scene IDs. Up to 8 scenes.

Examples

  • Example request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.0",
            "iotToken": "token"
        },
        "params": {
          "sceneIds":["d5edfxxxx5e2028","debfxxxx496c2"]
        }
    }
                        
  • Example of a successful response
    {
        "code": 200,
        "message": "success"
    }
                        

Create a scene in a home

Description

PathVersionDescriptionLogon required
/living/scene/create1.0.1Create a scene in a home.Yes
Note

The platform provides a home space management service. You can use the related APIs to build a home space model for your app. The scene service also supports home spaces and provides the ability to manage scenes within a home.

After you use the home space service to create a home for an app user, the scenes that the user previously created are automatically assigned to this home. The app user must then use the home scene APIs to manage scenes. The following APIs cannot be used to access scenes in a home space:

  • /scene/create
  • /scene/info/get

Request parameters

ParameterTypeRequiredDescription
homeIdStringYesThe unique identifier of the home where the scene is located.
catalogIdStringYesUsed to classify scenes.
  • 0 indicates a manual scene, which contains only an action.
  • 1 indicates an automation scene, which contains a Trigger and a Condition.
enableBooleanYesSpecifies whether to enable the scene upon creation. true indicates enable, and false indicates disable.
nameStringYesThe name of the scene given by the user.
descriptionStringNoA description of the scene.
iconStringYesThe download link for the scene icon.
iconColorStringYesThe color of the scene icon, for example, #FFFFFF.
triggersObjectNoThe trigger object of the IFTTT rule.
conditionsObjectNoThe condition object of the IFTTT rule.
caConditionsJSON ArrayNoThe condition object of the CA rule.
actionsJSON ArrayYesThe action object.
sceneTypeStringNoThe scene rule type. Valid values are IFTTT and CA. The default value is IFTTT.
modeStringNoThe mode of the CA rule.
  • all

    The action is executed only when all conditions in caConditions are met.

  • any

    The action is executed if any condition in caConditions is met.

Response parameters

ParameterTypeDescription
sceneIdStringThe ID of the created scene.

Request example

{
    "homeId": "testHomeId"
    "catalogId":"1",
    "enable":true,
    "name":"testScene",
    "icon":"http://www.aliyundoc.com/***.png",
    "iconColor":"#FFFFFF",
    "caConditions":[
        {
            "params":{
                "cron":"42 00 * * *",
                "cronType":"linux",
                "timezoneId":"Asia/Shanghai"
            },
            "uri":"condition/timer"
        },
        {
            "params":{
                "compareValue":0,
                "compareType":"==",
                "propertyName":"PowerSwitch",
                "productKey":"xxxx",
                "deviceName":"xxxx"
            },
            "uri":"condition/device/property"
        }
    ],
    "actions":[
        {
            "params":{
                "iotId":"xxxx",
                "propertyName":"PowerSwitch",
                "propertyValue":1
            },
            "uri":"action/device/setProperty"
        }
    ],
    "sceneType":"CA",
    "mode":"all"
}

Response example

{
    "code": 200,
    "data": "sceneId",
    "message": "success"
}

Update a scene in a home

Description

PathVersionDescriptionLogon required
/living/scene/update1.0.0Update scenarioYes

Request parameters

ParameterTypeRequiredDescription
catalogIdStringYesUsed to classify scenes.
  • 0 indicates a manual scene, which contains only an action.
  • 1 indicates an automation scene, which contains a Trigger and a Condition.
Note The catalogId is specified when the scene is created and cannot be modified afterward. You cannot change a manual scene to an automation scene by modifying the catalogId.
sceneIdStringYesScene ID.
enableBooleanYestrue indicates enable the scene. false indicates disable the scene.
nameStringYesThe name of the scene.
iconStringYesScenario Icon URL
iconColorStringYesThe color of the scene icon.
descriptionStringNoA description of the scene.
triggersObjectNoThe trigger object of the IFTTT rule.
conditionsObjectNoThe condition object of the IFTTT rule.
caConditionsArrayNoThe condition object of the CA rule.
actionsArrayYesThe action object.
sceneTypeStringNoThe scene rule type. Valid values are IFTTT and CA. The default value is IFTTT.
modeStringNoThe mode of the CA rule.
  • all

    The action is executed only when all conditions in caConditions are met.

  • any

    The action is executed if any condition in caConditions is met.

Response parameters

ParameterTypeDescription
sceneIdStringThe ID of the updated scene.

Request example

{
    "id": "1509086454180",
    "version": "1.0",
    "request": {
        "apiVer": "1.0.1",
        "iotToken": "token"
    },
    "params": {
    "enable" : true,
    "iconColor" : "#DE4545",
    "reBind" : true,
    "mode" : "any",
    "caConditions" : [
      {
        "uri" : "condition\/timer",
        "params" : {
          "cron" : "3g3 10 * * 1,2,3,4",
          "cronType" : "linux"
        }
      }
    ],
    "sceneType" : "CA",
    "icon" : "http:\\www.aliyundoc.com/***.png",
    "sceneId" : "2420d2xxxxf93c54fc4e",
    "catalogId" : "1",
    "name" : "10:27 Mon Tue - Power Switch On",
    "actions" : [
      {
        "uri" : "action\/device\/setProperty",
        "params" : {
          "iotId" : "uumR5xxxx00101",
          "propertyName" : "PowerSwitch",
          "propertyValue" : 1
        }
      }
    ]
  }
}          

Response example

{
    "code": 200,
    "data": "bdc60bexxxxd617697",
    "message": "success"
}
            

Delete a scene in a home

Description

PathVersionDescriptionLogon required
/living/scene/delete1.0.0Delete a scene.Yes

Request parameters

ParameterTypeRequiredDescription
sceneIdStringYesScene ID.

Response parameters

ParameterTypeDescription
sceneIdStringScenario I: Deletion

Request example

{
    "id": "1509086454180",
    "version": "1.0",
    "request": {
        "apiVer": "1.0.1",
        "iotToken": "token"
    },
    "params": {
        "sceneId": "0c965xxxx5306a6657",
        "groupId": null
    }
}                

Example of a successful response

{
    "code": 200,
    "data": "0c9653xxxx06a6657",
    "message": "success"
}

Query a list of scenes in a home

Description

PathVersionDescriptionLogon required
/living/scene/query1.0.1Query a list of scenes.Yes

Request parameters

ParameterTypeRequiredDescription
homeIdStringYesThe unique identifier of the home where the scene is located.
catalogIdStringYes
  • 0 indicates a manual scene, which contains only an action.
  • 1 indicates an automation scene, which contains a Trigger and a Condition.
pageNoIntegerYesThe page number. Must be greater than or equal to 1.
pageSizeIntegerYesThe number of items per page. Must be between 1 and 50.

Response parameters

ParameterSub-parameterTypeDescription
totalIntegerTotal number of items.
pageNoIntegerThe page number, starting from 1.
pageSizeIntegerThe number of items per page.
scenesArrayReturns the entries on the current page.
scenes.idStringScene ID.
scene.statusIntegerThe runtime status of the scene: 1 indicates the scene is online. 2 indicates the scene is offline.
scene.enableBooleanThe scene switch (the switch in the app): true - Scene is on. false - Scene is off.
scene.iconStringThe link to the scene icon.
scene.iconColorStringThe color of the scene icon.
scene.nameStringScene name.
scene.descriptionStringScene description.
scene.validBooleanValid
scene.catalogIdStringType: null - Scene 1.0. 0 - Scene. 1 - Automation.

Request example

{
  "id": "1509086454180",
  "version": "1.0",
  "request": {
    "apiVer": "1.0.1",
    "iotToken": "token"
  },
  "params": {
    "homeId": "testHomeId",
    "catalogId": "1",
    "pageSize": 20,
    "pageNo": 1,
  }
}

Example of a successful response

{
  "code": 200,
  "data": {
    "pageNo": 1,
    "pageSize": 20,
    "scenes": [{
      "description": "Electric blanket-hy-Signal-to-noise ratio--127 ",
      "enable": true,
      "icon": "https://g.aliplus.com/scene_icons/default.png",
      "id": "260de82dxxxx691be22",
      "name": "Electric Blanket",
      "status": 2,
      "iconColor":"#19BBFF",
      "valid":false,
      "catalogId":"1"

    }, {
      "description": "light-hy-LightSwitch-1, shuijin-hy-WiFI_SNR--127 ",
      "enable": true,
      "icon": "https://g.aliplus.com/scene_icons/default.png",
      "id": "45dc6fcxxxx6974e5f7",
      "name": "Liang Gong",
      "status": 1,
        "iconColor":"#19BBFF",
      "valid":true,
      "catalogId":"1"
    }, {
      "description": "fan-hy-PowerSwitch-Off, light-hy-LightSwitch-1 ",
      "enable": true,
      "icon": "https://g.aliplus.com/scene_icons/default.png",
      "id": "3ce636xxxx1367f2dc88",
      "name": "Fan Light 0522",
      "status": 1,
       "iconColor":"#19BBFF",
      "valid":false,
      "catalogId":"1"
    }, {
      "description": "light-hy-LightSwitch-1 ",
      "enable": true,
      "icon": "https://g.aliplus.com/scene_icons/default.png",
      "id": "5b4bdexxxx2612f81",
      "name": "Light 0522",
      "status": 2,
        "iconColor":"#19BBFF",
      "valid":false,
      "catalogId":"1"
    }],
    "total": 4
  },
  "message": "success"
}

Change the sort order of items in a home scene list

Description

PathVersionDescriptionLogon required
/scene/list/reorder1.0.6Change the sort order of items in a scene list.Yes

Request parameters

ParameterTypeRequiredDescription
homeIdStringYesThe unique identifier of the home to which the scene belongs.
groupIdStringYes
  • 0 indicates a manual scene, which contains only an action.
  • 1 indicates an automation scene, which contains a Trigger and a Condition.
newOrdersArrayYesAn array of scenes with changed ordinal numbers.
newOrders.sceneIdStringYesScene ID.
newOrders.targetOrderIntegerYesThe position to which the scene needs to be adjusted. The ordinal number starts from 0.

Response parameters

ParameterTypeDescription
codeIntegerThe status of a successful operation.

Request example

{
    "id": "1509086454180",
    "version": "1.0",
    "request": {
        "apiVer": "1.0.1",
        "iotToken": "token"
    },
    "params": {
        "groupId": "1",
        "newOrders": [{
            "sceneId": "a596dexxxx9685d25",
            "targetOrder": 2
        }, {
            "sceneId": "c1a8de4xxxxb473c3",
            "targetOrder": 1
        }]
    }
}

Example of a successful response

{
    "code": 200,
    "message": "success"
}

Get home scene details

Description

PathVersionDescriptionLogon required
/living/scene/info/get1.0.0Get scene details.Yes

Request parameters

ParameterTypeRequiredDescription
sceneIdStringYesThe ID of the scene to query.
catalogIdStringNo
  • 0 indicates a manual scene, which contains only an action.
  • 1 indicates an automation scene, which contains a Trigger and a Condition.

Response parameters

ParameterTypeDescription
idStringScene ID.
enableBooleanThe status of the scene switch.
  • true: On. The scene can be triggered and executed normally.
  • false: Off. The scene will not be executed even if the trigger conditions are met.
nameStringThe name of the scene given by the user.
descriptionStringA description of the scene.
iconStringScene icon.
iconColorStringThe color of the scene icon.
triggersJsonObjectThe JSON serialization of the complex object within the Trigger of an IFTTT rule. Used for frontend display.
conditionsJsonObjectThe condition object of the IFTTT rule.
caConditionsJsonArraySince Scene Service 2.0. The JSON serialization of the complex object within the Condition of a CA rule. Used for frontend display.
actionsJsonStringThe JSON serialization of the complex object within the Action. Used for frontend display.
sceneTypeStringSince Scene Service 2.0. Scene rule: IFTTT or CA (default is IFTTT).
modeStringSince Scene Service 2.0. The mode of the CA rule.
  • all

    The action is executed only when all conditions in caConditions are met.

  • any

    The action is executed if any condition in caConditions is met.

validBooleanIndicates whether the scene is valid.

Request example

{
    "id": "1509086454180",
    "version": "1.0",
    "request": {
        "apiVer": "1.0.1",
        "iotToken": "token"
    },
    "params": {
        "catalogId": "0",
        "sceneId": "debf2dxxxx51496c2"
    }
}

Response example

{
    "code":200,
    "data":{
        "id":"testSceneId",
        "name":"Test Scene Name",
        "description":"This is a test scene",
        "enable":true,
        "icon":"https://www.aliyundoc.com/***.png",
        "iconColor":"#FFFFFF",
        "sceneId":"testSceneId",
        "valid":true,
        "triggersJson":"{\"items\":[{\"params\":{\"cron\":\"0 7 * * 1,2,3,4,5,6,7\",\"cronType\":\"linux\",\"timezoneID\":\"Asia/Shanghai\"},\"uri\":\"trigger/timer\"}],\"uri\":\"logical/or\"}",
        "actionsJson":"[{\"uri\":\"action/device/setProperty\",\"params\":{\"propertyName\":\"PowerSwitch_2\",\"propertyValue\":1,\"iotId\":\"testDeviceIotId01\",\"productKey\":\"testProduct\",\"deviceName\":\"testDeviceName01\"}}]"
    },
    "message":"success"
}