APIs Related to Scenario Management

Last Updated on : 2025-05-30 01:56:03download

API List

Request method API description
GET /v1.0/osaas/rooms/{room_id}/scenes API for Querying the Scene List.
POST /v1.0/osaas/rooms/{room_id}/scenes/{scene_id}/trigger API for Trigger a Scene.
GET /v1.0/osaas/rooms/{room_id}/scene/devices API for Querying the Support Scene Device List.
POST /v1.0/osaas/rooms/{room_id}/scene API for Adding a Scene.
PUT /v1.0/osaas/rooms/{room_id}/scenes/{scene_id} API for Modifying Scene.
DELETE /v1.0/osaas/rooms/{room_id}/scenes/{scene_id} API for Deleting a Scene.

API for Querying the Scene List

API Description

You can use this API to query the list of scenes.

API Address

GET /v1.0/osaas/rooms/{room_id}/scenes

Request Parameters

Parameter Type Position Description Mandatory
room_id String URI Unique ID of a room. Yes

Response Parameters

Parameter Type Description
code Integer Response code.Null indicates success.
success Boolean Request result.
true: success
false: failure
msg String Exception message.It is null when the request result is success.
t Long Response time, which is a 13-digit timestamp.
result Array List of scenes

Parameters in result

Parameter Type Description
scene_id String Scene ID
scene_name String Scene name
actions Array List of actions

Parameters in actions

Parameter Type Description
entity_id String Target ID, device ID
executor_property Object Action parameters
action_executor String Action type,Currently only supports: dpIssue

Request Example

GET {url}/v1.0/osaas/rooms/122233331111111/scenes

Success Response Example

{ "success": true, "t": 1541071460239, "result": [ { "scene_id": "53IYSXI3gE******", "scene_name": "Test Scene", "actions": [ { "entity_id": "0120090568******", "executor_property": { "switch_led": true }, "action_executor": "dpIssue" } ] } ] }

Failure Response Example

{ "code": 500, "msg": "system error,please contact the admin", "success": false, "t": 1561378856383 }

API for Trigger a Scene

API Description

You can use this API to trigger a scene.

API Address

POST /v1.0/osaas/rooms/{room_id}/scenes/{scene_id}/trigger

Request Parameters

Parameter Type Position Description Mandatory
room_id String URI Unique ID of a room. Yes
scene_id String URI Unique ID of a scene. Yes

Response Parameters

Parameter Type Description
code Integer Response code.Null indicates success.
success Boolean Request result.
true: success
false: failure
msg String Exception message.It is null when the request result is success.
t Long Response time, which is a 13-digit timestamp.
result Boolean Operation result

Request Example

POST {url}/v1.0/osaas/rooms/12223333111/scenes/53IY3gEn******/trigger

Success Response Example

{ "success": true, "result": true, "t": 1566053034624 }

Failure Response Example

{ "code": 500, "msg": "system error,please contact the admin", "success": false, "t": 1561378856383 }

API for Querying the Support Scene Device List

API Description

You can use this API to query the list of devices that support scenarios.

API Address

GET /v1.0/osaas/rooms/{room_id}/scene/devices

Request Parameters

Parameter Type Position Description Mandatory
room_id String URI Unique ID of a room. Yes
page_no Integer URL Page number. The default value is 1. No
page_size Integer URL Number of records on a page, which is greater than 0 and less than 100. If this parameter is not set, the number is 20 by default. No

Response Parameters

Parameter Type Description
code Integer Response code.Null indicates success.
success Boolean Request result.
true: success
false: failure
msg String Exception message.It is null when the request result is success.
t Long Response time, which is a 13-digit timestamp.
result Object Result object.

Parameters in result

Parameter Type Description
total Integer Total number of records.
page_no Integer Page number.
page_size Integer Number of records on a page.
devices Arrays List of devices.

Parameters in devices

Parameter Type Description
device_id String Device ID.
device_name String Device name.
product_id String Product ID.

Request Example

GET {url}/v1.0/osaas/rooms/12223******/scene/devices?page_no=1&page_size=20

Success Response Example

{ "result": { "total": 1, "page_no": 1, "page_size": 20, "devices": [ { "device_id": "vedo******", "device_name": "Test Device", "product_id": "r45675******" } ] }, "success": true, "t": 1572936751228 }

Failure Response Example

{ "code": 500, "msg": "system error,please contact the admin", "success": false, "t": 1561378856383 }

API for Adding a Scene

API Description

You can use this API to add a scene.

API Address

POST /v1.0/osaas/rooms/{room_id}/scene

Request Parameters

Parameter Type Position Description Mandatory
room_id String URI Unique ID of a room. Yes
scene_name String BODY Scene name. Yes
actions Arrays BODY List of actions. Yes

Parameters in actions

Parameter Type Position Description Mandatory
entity_id string BODY Unique ID of a device. Yes
executor_property Object BODY Action parameters. Yes
action_executor String BODY Action type , Currently only supports: dpIssue. Yes

Response Parameters

Parameter Type Description
code Integer Response code.Null indicates success.
success Boolean Request result.
true: success
false: failure
msg String Exception message.It is null when the request result is success.
t Long Response time, which is a 13-digit timestamp.
result String Unique ID of a scene

Request Example

POST {url}/v1.0/osaas/rooms/122233******/scene
{ "scene_name": "Test scene", "actions": [ { "executor_property": { "work_mode": "auto" }, "action_executor": "dpIssue", "entity_id": "0120090568c6******" } ] }

Success Response Example

{ "success": true, "result": "1112382******", "t": 1566053034624 }

Failure Response Example

{ "code": 500, "msg": "system error,please contact the admin", "success": false, "t": 1561378856383 }

API for Modifying Scene

API Description

You can use this API to modify information about a space based on the unique IDs of the project and the space.

API Address

PUT /v1.0/osaas/rooms/{room_id}/scenes/{scene_id}

Request Parameters

Parameter Type Position Description Mandatory
room_id String URI Unique ID of a room. Yes
scene_id String URI Unique ID of a scene. Yes
scene_name String BODY Scene name. No
actions Arrays BODY List of actions. No

Parameters in actions

Parameter Type Position Description Mandatory
entity_id String BODY Unique ID of a device. Yes
executor_property Object BODY Action parameters. Yes
action_executor String BODY Action type,Currently only supports: dpIssue. Yes

Response Parameters

Parameter Type Description
code Integer Response code.Null indicates success.
success Boolean Request result.
true: success
false: failure
msg String Exception message.It is null when the request result is success.
t Long Response time, which is a 13-digit timestamp.
result Boolean Result object.

Request Example

PUT {url}/v1.0/osaas/rooms/12223******/scenes/53IY3gE******
{ "scene_name": "Test Scene", "actions": [ { "executor_property": { "work_mode": "auto" }, "action_executor": "dpIssue", "entity_id": "0120090568c63******" } ] }

Success Response Example

{ "success": true, "result": true, "t": 1566053034624 }

Failure Response Example

{ "code": 500, "msg": "system error,please contact the admin", "success": false, "t": 1561378856383 }

API for Deleting a Scene

API Description

You can use this API to delete a scene.

API Address

DELETE /v1.0/osaas/rooms/{room_id}/scenes/{scene_id}

Request Parameters

Parameter Type Position Description Mandatory
room_id String URI Unique ID of a room. Yes
scene_id String URI Unique ID of a scene. Yes

Response Parameters

Parameter Type Description
code Integer Response code.Null indicates success.
success Boolean Request result.
true: success
false: failure
msg String Exception message.It is null when the request result is success.
t Long Response time, which is a 13-digit timestamp.
result Object Result object.

Request Example

DELETE {url}/v1.0/osaas/rooms/12223******/scenes/53IY3gE******

Success Response Example

{ "success": true, "result": true, "t": 1566053034624 }

Failure Response Example

{ "code": 500, "msg": "system error,please contact the admin", "success": false, "t": 1561378856383 }

Error Code

The following are common business exceptions for this interface. For more exception errors, see Global Error Codes.

error code explain
500 system error