Scene Service 2.0

更新时间:
复制 MD 格式

This service provides a set of APIs for clients to create and configure automated scenarios. These APIs let you execute tasks when specific conditions are met, such as automatically turning on a device at a scheduled time.

Note Scene Service 2.0 is an upgrade that includes new features, such as home, space, and group control. If you do not need these features, see the previous version of Scene Service 2.0.

Scene rule descriptions

Create, edit, delete, and query scenarios

Trigger conditions and execution tasks Scenario and automation execution Scheduled scenarios App widgets

Scene rule descriptions

A scene rule describes what triggers an action (Trigger), what conditions must be met (Condition), and what 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 combines the Trigger and Condition into a single "condition".

IFTTT rules

The following example shows a typical scene rule. The scenario is triggered (Trigger) when the someone_exist property of the device `sensor_01` is equal to 1. The system then checks if the current time is between 06:00 and 22:00 (Condition). If it is, the switch property of the `light` device 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":"0-0 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 preceding example shows an IFTTT scene rule. The rule includes the following four nodes:

NameDescription
typeThe type of the scene rule. Valid values are IFTTT and CA.
triggerThe trigger for the scenario, such as a specific time or a device property. A scenario can have multiple triggers. These triggers have an "OR" relationship. A scenario can also have no triggers. In this case, you can manually trigger the scenario by calling an API.
conditionThe filter condition after the scenario is triggered, such as a time range or a device property. A scenario can have multiple filter conditions. These conditions have an "AND" relationship. A scenario can also have no filter conditions. In this case, the corresponding actions are executed directly after the scenario is triggered.
actionThe action to execute when the scenario is triggered and the filter conditions are met. Examples include setting a device property or triggering another scenario. A scenario can have multiple actions. A scenario 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-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"
            }
        }
    ]
}

The preceding rule means that the scenario is triggered at 10:00 every day or when the `someone_exist` property of the device `sensor_01` is equal to 1. If the `some_property` of the device `test_device` is less than 10 and the current time is between 09:00 and 12:00, the actions are executed. The `onOff` property of `test_device` is set to `on`, and another scenario 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 includes `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`, which means the action is executed if any condition is met, and `all`, which means the action is executed only when all conditions are met.
conditionThe trigger conditions for the scenario, such as a specific time, a device property, or a time range. A scenario can have multiple trigger conditions.
actionThe action to execute when the scenario is triggered. Examples include setting a device property or triggering another scenario. A scenario can have multiple actions. A scenario 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/setProperty",
            "params":{
                "productKey":"pk_action",
                "deviceName":"test_device",
                "propertyName":"LightStatus",
                "propertyValue": 1
            }
        }
    ]
}

The preceding rule means that if the `some_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 components

The supported Trigger components include the following:

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

trigger/timer parameter descriptions

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

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

`quartz_cron`: A 7-field Quartz cron expression. The year is supported. Currently, the minimum precision is minutes. The first field for 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 you do not set this parameter, the time zone of the region where the IoT Platform service is located is used by default. 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 Past times that cannot be reached are not allowed.
  • 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 parameter descriptions

ParameterTypeDescription
productKeyStringProductKey
deviceNameStringDevice Name
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 parameter descriptions

ParameterTypeDescription
productKeyStringThe ProductKey of the device.
deviceNameStringThe name of the device.
eventCodeStringThe event code of the device. This parameter is optional.
propertyNameStringThe name 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 components

The supported Condition components include the following:

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

condition/timeRange parameter descriptions

ParameterTypeDescription
cronString`20-25 11-23 * * 1,2,3` indicates that the action is allowed to be executed from 11:20 to 23:25 on Monday, Tuesday, and Wednesday of every week.
cronTypeStringThe cron expression type. The value is `linux`.
timezoneIDStringExample: Asia/Shanghai

condition/timeRange example

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

condition/device/property parameter descriptions

ParameterTypeDescription
productKeyStringThe ProductKey of the device.
deviceNameStringThe name of the device.
propertyNameStringDevice property.
compareTypeStringThe comparison type, such as >, <, >=, ==, <=, !=, in, or like.
compareValueObjectComparison value.

condition/device/property example

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

Action components

The supported Action components include the following:

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

action/scene/trigger parameter descriptions

ParameterTypeDescriptionExample
sceneIdStringThe scenario ID.None

action/scene/trigger example

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

action/device/invokeService parameter descriptions

ParameterTypeDescriptionExample
iotIdStringThe device ID.None
serviceNameStringThe service name.None
serviceArgsJSONThe service 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 parameter descriptions

ParameterTypeDescriptionExample
iotIdStringThe device ID.None
propertyNameStringThe name of the property to set.PowerSwitch
propertyValueObjectThe value of the property to set.1
delayedExecutionSecondsIntegerThe delayed execution time. This parameter is optional. By default, the action is executed immediately. If you set this parameter, the action is executed after the specified delay. Unit: seconds. The value must be between 1 and 86400 (24 hours).10

action/device/setProperty example

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

action/automation/setSwitch parameter descriptions

ParameterTypeDescriptionExample
automationRuleIdStringThe ID of the scenario to enable or disable.None
switchStatusInteger`0` indicates disable, and `1` indicates enable.1

action/automation/setSwitch example

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

CaCondition components

The supported CaCondition components include the following:

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

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

Note The parameter format of the `condition/timeRange` node in CA rules is different from that in IFTTT rules.
condition/device/propertyDevice property. The function and parameters are the same as `trigger/device/property` in IFTTT rules.

condition/timeRange parameter descriptions

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 you do not set this parameter, the time zone of the region where the IoT Platform service is located is used by default. We recommend that you set this parameter to specify a time zone.
beginDateStringThe start time. The format must match the one specified by `format`. For example, if `format` is `HH:mm`, you can set `beginDate` to `12:30`.
endDateStringThe end time. The format must match the one specified by `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 spans across midnight. For example, if `beginDate` is `22:00` and `endDate` is `06:00`, the time range is from 22:00 to 06:00 the next day.
repeatStringThe days of the week for repetition. This is a string of comma-separated numbers from 1 to 7. This parameter is optional. If you do not set it, the action does not repeat. For example, `1,2,3` indicates that the action repeats on Monday, Tuesday, and Wednesday.

condition/timeRange format value descriptions

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

Scene rules have the following limits:

  • A Trigger component is optional. If a scenario has no trigger, it is not automatically triggered. You can call the Execute a scenario API to manually trigger it. For example, if you only set `condition/timeRange` but no trigger, the scenario is not automatically triggered.
  • A Condition component is optional. If a scenario has no condition, the Action is executed directly when the Trigger is activated.
  • An Action component is required.
  • A user can create up to 200 scenarios.
  • 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 30 Actions.
  • A device can be the target of an Action in a maximum of 20 scenarios.
  • A rule can have only one `trigger/timer` component.
  • A rule can have only one `condition/timeRange` component.
  • In CA rules, only `all` mode supports the `condition/timeRange` component. This component is ignored in `any` mode.

Create a scenario

Description

pathVersionDescriptionLogon required
/scene/create1.0.5Creates a scenario.Yes

Request parameters

ParameterTypeRequiredDescription
groupIdStringYesUsed to classify scenarios.
  • `0` indicates a manual scenario, which contains only actions.
  • `1` indicates an automated scenario, which contains triggers and conditions.
enableBooleanYesSpecifies whether to enable the scenario upon creation. `true` indicates enabled, and `false` indicates disabled.
nameStringYesThe name of the scenario.
iconStringYesThe download link for the scenario icon.
iconColorStringYesThe color of the scenario icon, such as #FFFFFF.
descriptionStringNoThe description of the scenario.
triggersObjectNoThe trigger object for an IFTTT rule.
conditionsObjectNoThe condition object for an IFTTT rule.
caConditionsJSON ArrayNoThe condition object for a CA rule.
actionsJSON ArrayYesThe action object.
sceneTypeStringNoThe type of the scene rule. Valid values are `IFTTT` and `CA`. The default value is `IFTTT`.
modeStringNoThe mode for a CA rule.
  • `all`:

    The actions are executed only when all conditions in `caConditions` are met.

  • `any`:

    The actions are executed if any condition in `caConditions` is met.

Response parameters

ParameterTypeDescription
sceneIdStringThe ID of the created scenario.

Examples

  • Request example for creating a CA rule scenario
    {
        "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"
    }
  • Request example for creating an IFTTT rule scenario (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"
            }
        ]
    }
  • Request example for creating an IFTTT rule scenario (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"
            }
        ]
    }
  • Successful response example
    {
        "code": 200,
        "data": "sceneId",
        "message": "success"
    }

Update a scenario

Description

PathVersionDescriptionLogon required
/scene/update1.0.5Updates a scenario.Yes

Request parameters

ParameterTypeRequiredDescription
groupIdStringYesUsed to classify scenarios.
  • `0` indicates a manual scenario, which contains only actions.
  • `1` indicates an automated scenario, which contains triggers and conditions.
Note You specify `groupId` when you create a scenario. After the scenario is created, you cannot change the `groupId`. This means you cannot change a manual scenario to an automated scenario by modifying the `groupId`.
sceneIdStringYesThe scenario ID.
enableBooleanYes`true` indicates that the scenario is enabled. `false` indicates that the scenario is disabled.
nameStringYesThe name of the scenario.
iconStringYesScenario icon URL
iconColorStringYesThe color of the scenario icon.
descriptionStringNoThe description of the scenario.
triggersObjectNoThe trigger object for an IFTTT rule.
conditionsObjectNoThe condition object for an IFTTT rule.
caConditionsArrayNoThe condition object for a CA rule.
actionsArrayYesAction object
sceneTypeStringNoThe type of the scene rule. Valid values are `IFTTT` and `CA`. The default value is `IFTTT`.
modeStringNoThe mode for a CA rule. Valid values are `all` and `any`.

Response parameters

ParameterTypeDescription
sceneIdStringThe ID of the updated scenario.

Examples

  • 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" : "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
            }
          }
        ]
      }
    }          
  • Successful response example
    {
        "code": 200,
        "data": "bdc60bexxxxd617697",
        "message": "success"
    }
                        

Delete a scenario

Description

PathVersionDescriptionLogon required
/scene/delete1.0.2Delete ScenarioYes

Request parameters

ParameterTypeRequiredDescription
sceneIdStringYesThe scenario ID.

Response parameters

ParameterTypeDescription
sceneIdStringThe ID of the deleted scenario.

Examples

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

Query a list of scenarios or automations

Description

PathVersionDescriptionLogon required
/scene/list/get1.0.5Query scenariosYes

Request parameters

ParameterTypeRequiredDescription
groupIdStringYes`0`: scenario. `1`: automation.
pageNoIntegerYesThe page number. It must be greater than or equal to 1.
pageSizeIntegerYesThe number of entries per page. The value must be between 1 and 50.

Response parameters

ParameterSub-parameterTypeDescription
totalIntegerThe total number of entries.
pageNoIntegerThe page number, starting from 1.
pageSizeIntegerThe number of entries per page.
scenesArrayReturns the entries on the current page.
scenes.idStringThe scenario ID.
scene.statusIntegerThe runtime status of the scenario. `1`: online. `2`: offline.
scene.enableBooleanThe switch for the scenario (the switch in the app). `true`: The scenario is turned on. `false`: The scenario is turned off.
scene.iconStringThe link to the scenario icon.
scene.iconColorStringThe color of the scenario icon.
scene.nameStringThe name of the scenario.
scene.descriptionStringThe description of the scenario.
scene.validBooleanIndicates whether the scenario is valid.
scene.groupIdStringThe type. `null`: an old version scenario. `0`: a scenario. `1`: an automation.

Examples

  • Request example
    {
      "id": "1509086454180",
      "version": "1.0",
      "request": {
        "apiVer": "1.0.1",
        "iotToken": "token"
      },
      "params": {
        "groupId": "1",
        "pageSize": 20,
        "pageNo": 1,
      }
    }
  • Successful response example
    {
      "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": "fengsan-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 scenarios and automations at the same time

Description

PathVersionDescriptionLogon required
/scene/list/all1.0.0Queries all scenario information on the My Smart page, including scenarios and automations.Yes. The client software development kit (SDK) must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
pageNoIntegerNoThe current page number. The default value is 1.
pageSizeIntegerYesThe number of entries per page. The value 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
dataStringA list of scenarios and automations.
scene0StringInformation about the list of scenarios.
totalIntegerThe total number of scenarios.
pageNoIntegerReturns the current page number.
pageSizeIntegerThe number of entries returned on the page.
scenesStringScenarios
idStringThe scenario ID.
nameStringThe name of the scenario.
descriptionStringThe description of the scenario.
enableBooleanThe switch for the scenario (the switch in the app). `true`: The scenario is turned on. `false`: The scenario is turned off.
iconStringScenario Icon Link
iconColorStringThe color of the scenario icon.
groupIdStringThe classification. `0`: scenario. `1`: automation.
validBooleanIndicates whether the scenario is valid. When a device in the scenario is detached, the automation becomes invalid.
scene1StringInformation about the list of automations.
totalIntegerThe total number of automations.
pageNoIntegerThe current page number.
pageSizeIntegerThe number of entries per page.
scenesStringA list of automations.
idStringAutomation ID
nameStringThe name of the automation.
descriptionStringThe description of the automation.
enableBooleanThe switch for the automation (the switch in the app). `true`: The scenario is turned on. `false`: The scenario is turned off.
iconStringThe automation icon.
iconColorStringAutomation Icon Color
groupIdStringThe classification. `0`: scenario. `1`: automation.
validBooleanIndicates whether the automation is valid. When a device in the automation is detached, the automation becomes invalid.

Examples

  • Request example
    {
     "id": "1509086454180",
     "version": "1.0",
     "request": {
      "apiVer": "1.0.0",
      "iotToken": "token"
     },
     "params": {
     "pageNum": 1,
      "pageSize": 10
     }
    }
  • Successful response example
    {
     "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 scenario list

Description

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

Request parameters

ParameterSub-parameterTypeRequiredDescription
groupIdStringYes`0`: scenario. `1`: automation.
newOrdersArrayYesAn array of scenarios whose sort order has changed.
sceneIdStringYesThe scenario ID.
fromOrderIntegerYesThe original ordinal number before the order change.
toOrderIntegerYesThe new ordinal number.

Response parameters

ParameterTypeDescription
codeIntegerOperation successful

Examples

  • Request example
    {
        "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
            }]
        }
    }
                        
  • Successful response example
    {
        "code": 200,
        "message": "success"
    }
                        

Execute a scenario

Description

PathVersionDescriptionLogon required
/scene/fire1.0.2Executes a scenario.Yes

Request parameters

ParameterTypeRequiredDescription
sceneIdStringYesThe ID of the scenario to trigger.

Response parameters

ParameterTypeDescription
sceneIdStringThe ID of the triggered scenario.

Examples

  • Request example
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.1",
            "iotToken": "token"
        },
        "params": {
            "groupId": null,
            "sceneId": "debf2dxxxx51496c2"
        }
    }
                        
  • Successful response example
    {
        "code": 200,
        "data": "debf2dxxxx51496c2",
        "message": "success"
    }
                        

Get a list of scenario logs

Description

PathVersionDescriptionLogon required
/scene/log/list/get1.0.2Gets a list of scenario logs.Yes

Request parameters

ParameterTypeRequiredDescription
pageNoIntegerYesThe page number. It must be greater than or equal to 1.
pageSizeIntegerYesThe number of entries to retrieve at a time.
nowTimeLongYesThe start time of the log query, in milliseconds. The format is the same as that of a scenario log query.

The `nowTime` parameter sets the end of the time range for the log query. The API returns logs from the 15-day period before this time. To start a new query from a different time, provide a new `nowTime` value and reset `pageNo` to 1.

Response parameters

ParameterTypeDescription
pageNoIntegerThe page number. It must be greater than or equal to 1.
pageSizeIntegerThe number of entries retrieved at a time.
totalIntegerThe total number of entries.
logsArrayA list of logs, returned in descending order of time.
logs.timeLongThe log time, as a timestamp in milliseconds.
logs.iconStringThe scenario icon.
logs.sceneIdStringThe scenario ID.
logs.idStringThe log ID.
logs.sceneNameStringThe name of the scenario.
logs.resultIntegerThe execution result. `0`: failed. `1`: successful.

Examples

  • Request example
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.1",
            "iotToken": "token"
        },
        "params": {
            "pageNo": 1,
            "pageSize": 5,
            "groupId": null,
            "nowTime": 1527129084824
        }
    }
                        
  • Successful response example
    {
        "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 the details of a failed log

Description

PathVersionDescriptionLogon required
/scene/failedlog/get1.0.4Gets the details of a failed log.Yes

Request parameters

ParameterTypeRequiredDescription
logIdStringYesThe ID of the log to query.
sceneIdStringYesThe scenario ID.
timeLongYesThe `logs.time` returned by `/scene/log/list/get`, in milliseconds.
pageNoIntegerYesThe page number. The first page is 1.
pageSizeIntegerYesThe number of entries to retrieve at a time.

Response parameters

ParameterTypeDescription
totalIntegerTotal
pageSizeIntegerThe number of entries retrieved at a time.
pageNoIntegerThe page number. It must be greater than or equal to 1.
detailsArrayNone
details.productKeyStringA list of details for the failed device.
details.localizedProductNameStringLocalized product information.
details.deviceNameStringThe deviceName of the device.
details.aliasNameStringThe name given to the device by the user.
details.failedReasonStringThe error message. If the action was to set a property, the format is: {Product Name}-{Property Name}-{Property Value} execution failed. If the action was to call a service, the format is: {Product Name}-{Service Name} execution failed.
details.detailStringSubscript Annotation Reason
details.iconStringThe icon.

Examples

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

Get scenario details

Description

PathVersionDescriptionLogon required
/scene/info/get1.0.5Gets the details of a scenario.Yes

Request parameters

ParameterTypeRequiredDescription
sceneIdStringYesThe ID of the scenario to query.
groupIdStringNoThe scenario type:
  • `0`: scenario
  • `1`: automation

Response parameters

ParameterTypeDescription
sceneIdStringScenario ID
enableBooleanThe status of the scenario switch. Valid values:
  • `true`: on. The scenario can be triggered and executed.
  • `false`: off. The scenario is not executed even if the trigger conditions are met.
nameStringThe name of the scenario.
iconStringThe scenario icon.
iconColorStringThe color of the scenario icon.
descriptionStringThe description of the scenario.
triggersJsonObjectJSON serialization of the complex object in the Trigger of an IFTTT rule, used for frontend display.
conditionsObjectThe condition object for an IFTTT rule.
caConditionsJsonArraySince Scene Service 2.0, this is the JSON serialization of the complex object in the Condition of a CA rule, used for frontend display.
actionsJsonStringJSON serialization of the complex object in the Action, used for frontend display.
sceneTypeStringSince Scene Service 2.0, this is the scene rule type. Valid values are `IFTTT` and `CA`. The default value is `IFTTT`.
modeStringSince Scene Service 2.0, this is the mode for a CA rule. Valid values are `all` and `any`.
validBooleanIndicates whether the scenario is valid.

Enable and disable a scenario

Description

PathVersionDescriptionLogon required
/living/scene/switch1.0.0Enables or disables a scenario automation.Yes

Request parameters

ParameterTypeRequiredDescription
sceneIdStringYesThe scenario ID.
enableBooleanYesThe status of the scenario switch. Valid values:
  • `true`: on. The scenario can be triggered and executed.
  • `false`: off. The scenario is not executed even if the trigger conditions are met.

Response parameters

Examples

  • Request example
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.0",
            "iotToken": "token"
        },
        "params": {
            "sceneId": "0c96536xxxxc5306a6657",
            "enable": true
        }
    }
                        
  • Successful response example
    {
        "code": 200,
        "message": "success"
    }
                        

Get a list of devices under the current user that support trigger, condition, or action configurations

Description

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

Request parameters

ParameterTypeRequiredDescription
flowTypeIntegerYesThe flow type. `0`: trigger. `1`: condition. `2`: action.
pageNumIntegerYesThe page number, starting from 1.
pageSizeIntegerYesThe number of entries per page.

Response parameters

ParameterTypeDescription
pageNoIntegerThe page number, starting from 1.
pageSizeIntegerThe maximum number of items per page.
totalLongThe total number of records.
dataListDevice List
Data list structure
ParameterTypeDescription
iotIdStringThe device ID.
deviceNameStringDevice name
productKeyStringProduct key
nickNameStringThe nickname of the device.
imageStringThe URL of the category icon.

Examples

  • Request example
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.1",
            "iotToken": "token"
        },
        "params": {
            "flowType": 0,
            "pageNum": 1,
            "pageSize": 20
        }
    }
                        
  • Successful response example
    {
        "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 feature properties that support trigger, condition, or action configurations on a device

Description

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

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesThe device ID.
flowTypeIntegerYesThe flow type. `0`: trigger. `1`: condition. `2`: action.

Response parameters

ParameterTypeDescription
nameStringThe feature name.
identifierStringThe feature identifier.
categoryTypeStringThe category name.
typeIntegerThe feature type. `1`: property. `2`: service. `3`: event.

Examples

  • Request example
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.1",
            "iotToken": "token"
        },
        "params": {
            "iotId": "45dc6fxxxx29f6974e5f7",
            "flowType": 0
        }
    }
                        
  • Successful response example
    {
        "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.2Queries for a list of features that support Trigger/Condition/Action (T/C/A) and the corresponding Thing Specification Language (TSL) information for a device.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesThe device ID.
flowTypeIntegerYesThe flow type. `0`: trigger. `1`: condition. `2`: action.

Response parameters

ParameterTypeDescription
simplifyAbilityDTOsListA list of feature definitions.
abilityDslJSONObjectThe TSL of the product features (for reference).
simplifyAbilityDTOs structure
ParameterTypeDescription
nameStringThe feature name.
identifierStringThe feature identifier.
categoryTypeStringThe category name.
typeIntegerThe feature type. `1`: property. `2`: service. `3`: event.

Examples

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

Create a scheduled scenario for a device

Description

PathVersionDescriptionUser identity authentication required
/scene/timing/create1.0.2Creates a scheduled scenario for a device.Yes. The client SDK must enable identity authentication.
Note Scheduled scenarios are associated with specific devices. Therefore, you cannot use APIs such as `/scene/update` or `/living/scene/switch` to update, enable, or disable them. You must use the `/scene/timing/update` API for these operations. Additionally, the action to push a message to a mobile phone is not supported.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesThe device ID.
enableBooleanYes`true`: on. `false`: off.
nameStringYesThe name that you specify for the scenario.
iconStringYesThe scenario icon.
descriptionStringNoThe description of the scenario.
triggersObjectNoThe trigger object.
conditionsObjectNoThe condition object.
actionsArrayYesThe action object.
Note The `actions` parameter is required. The `triggers` and `conditions` parameters are optional.

Response parameters

ParameterTypeDescription
sceneIdStringThe ID of the new scenario.

Examples

  • Request example
    {
        "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"
            }
        }
    }
                        
  • Successful response example
    {
        "code": 200,
        "data": "0c9653xxxx645c5306a6657",
        "message": "success"
    }
                        

Update a scheduled scenario for a device

Description

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

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesThe device ID.
sceneIdStringYesThe scenario ID.
enableBooleanYes`true`: on. `false`: off.
nameStringYesThe name of the scenario.
iconStringYesThe scenario icon.
descriptionStringNoThe description of the scenario.
triggersObjectNoThe trigger object.
conditionsObjectNoCondition object
actionsArrayYesThe action object.
Note The `actions` parameter is required. The `triggers` and `conditions` parameters are optional.

Response parameters

ParameterTypeDescription
sceneIdStringThe scenario ID.

Examples

  • Request example
    {
        "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"
            }
        }
    }
                        
  • Successful response example
    {
        "code": 200,
        "data": "0c9653xxxx06a6657",
        "message": "success"
    }
                        

Delete a scheduled scenario for a device

Description

PathVersionDescriptionUser identity authentication required
/scene/timing/delete1.0.2Deletes a scheduled scenario.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesDevice ID
sceneIdStringYesThe scenario ID.

Response parameters

ParameterTypeDescription
sceneIdStringThe ID of the deleted scenario.

Examples

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

Get the details of a scheduled scenario for a device

Description

PathVersionDescriptionUser identity authentication required
/scene/timing/info/get1.0.2Gets the details of a scheduled scenario.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesThe device ID.
sceneIdStringYesThe ID of the scenario to query.

Response parameters

ParameterTypeDescription
sceneIdStringThe scenario ID.
enableBooleanThe scenario switch. `true`: on. `false`: off.
statusIntegerThe runtime status of the scenario. `1`: running. `2`: invalid.
nameStringThe name of the scenario.
iconStringThe scenario icon.
triggersObjectA string representation of the triggers object. The trigger object is defined below.
conditionsObjectA string representation of the conditions object.
actionsArrayA string representation of the actions object.

Examples

  • Request example
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.2",
            "iotToken": "token"
        },
        "params": {
            "sceneId": "260de8xxxx4691be22",
            "iotId": "gaI0Cxxxx9b3700"
        }
    }
                        
  • Successful response example
    {
        "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 scenarios for a device

Description

PathVersionDescriptionUser identity authentication required
/scene/timing/list/get1.0.2Queries a list of scheduled scenarios.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesThe device ID.
pageNoIntegerYesThe page number. It must be greater than or equal to 1.
pageSizeIntegerYesThe number of entries per page. The value must be between 1 and 50.

Response parameters

ParameterSub-parameterTypeDescription
totalIntegerThe total number of entries.
pageNoIntegerThe page number, starting from 1.
pageSizeIntegerThe number of entries per page.
scenesArrayThe entries on the current page.
scenes.idStringThe scenario ID.
scene.statusIntegerThe runtime status of the scenario. `1`: online. `2`: offline.
scene.enableBooleanThe switch for the scenario (the switch in the app). `true`: The scenario is turned on. `false`: The scenario is turned off.
scene.iconStringScenario Icon Link
scene.nameStringThe name of the scenario.
scene.descriptionStringThe description of the scenario.

Examples

  • Request example
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.2",
            "iotToken": "token"
        },
        "params": {
            "pageSize": 20,
            "pageNo": 1,
            "iotId": "zjoOvFZxxxx0c4dc00"
        }
    }   
  • Successful response example
    {
        "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 the details of multiple scenarios in a batch

Description

PathVersionDescriptionUser identity authentication required
/living/scene/batchget1.0.0Requests scenario information in a batch.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
sceneIdListlistYesA list of scenario IDs to query.

Response parameters

ParameterTypeDescription
sceneIdStringThe scenario ID.
enableBooleanThe scenario switch. `true`: on. `false`: off.
nameStringScenario name
iconStringScenario Icon
triggersStringA string representation of the triggers object.
conditionsStringA string representation of the conditions object.
actionsStringA string representation of the actions object.

Examples

  • Request example
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.0",
            "iotToken": "token"
        },
        "params": 
      {"sceneIdList":["b8fe2xxxx26b76c31"]}
    }
                        
  • Successful response example
    {
      "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/sendAn action to push a message to a mobile phone.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
customDataCustomDataYesThe push message model.
customData. messageStringYesThe content of the message to push to the mobile phone. It can be up to 60 characters long.
msgTagStringYesThe push message model. The default value is `IlopBusiness_CustomMsg`.

Return Parameters

Examples

  • Request example
    "actions": [
        {
            "uri":"action/mq/send",
            "params":{
                "customData":{
                    "message":"The power is on"
                },
                "msgTag":"IlopBusiness_CustomMsg"
            }
        }
    ]
                        
  • Successful response example

    None

Query scenarios for a smart widget

Description

PathVersionDescriptionLogon required
/living/appwidget/list1.0.0Queries for smart widget information. This is used to query component information in the app's quick scenario trigger widget.Yes

Request parameters

Response parameters

ParameterTypeDescription
idStringThe scenario ID.
nameStringThe name of the scenario.
descriptionStringThe description of the scenario.
enableBooleanIndicates whether the scenario is enabled.
iconStringThe scenario icon.
iconColorStringThe color of the scenario icon.
validBooleanIndicates whether the scenario is valid.

Examples

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

Add a scenario to a smart widget

Description

PathVersionDescriptionLogon required
/living/appwidget/create1.0.0Adds a smart widget. This is used to add a component to the app's quick scenario trigger widget.Yes

Request parameters

Response parameters

ParameterTypeDescription
sceneIdsArrayA list of scenario IDs. You can add up to 8 scenarios.

Examples

  • Request example
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.0",
            "iotToken": "token"
        },
        "params": {
          "sceneIds":["d5edfxxxx5e2028","debfxxxx496c2"]
        }
    }
                        
  • Successful response example
    {
        "code": 200,
        "message": "success"
    }