场景管理
字段路径以消息数组中的单个对象为起点。[] 表示数组元素,例如 services[].rid 表示每个服务的 rid;value 对象中的字段使用 value.name、value.color_arr[].x 等路径表示。
一. 场景新增
1. topic
res/scene/add
2. payload
json
[
{
"id": "AE017B91-75BF-4CC6-9EC7-F2C48DDC11FD",
"type": "scene",
"name": "瓦尔登湖",
"parent_id": "2F0B3B6D-CE40-4A2F-A529-A2DE3EDD9C62",
"parent_type": "group_light",
"room_uuid": "6B703F4A-A2A2-4F3C-82D6-BDD4E8BA8B1C",
"brightness": 0,
"scene_type": 2,
"is_active": 0,
"sequence": 0,
"number": 4885848,
"icon": "",
"background": "",
"colors": [
4293473571,
4293687116,
4294026836,
4294432128,
4287352825
],
"picture_id": "25967925-FC78-4C1F-A8CB-33E5A3DD17A5",
"picture_type": "file",
"picture_url": "http://192.168.41.104:8000/33E5A3DD17A5.png",
"device_arr": [
{
"ext_light": [],
"id": "10E48D35-0ABD-47EB-BA4B-C150D68C4B23",
"type": "device"
}
]
}
]3. 字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 场景的UUID |
type | string | 资源类型, 此处固定为 "scene" |
name | string | 场景名称 |
parent_id | string | 父节点, 即group_light 的UUID |
parent_type | string | 此处固定为 group_light |
room_uuid | string | 房间的UUID |
brightness | integer | 场景的亮度 |
scene_type | integer | 1颜色场景, 2图片场景 |
is_active | integer | 是否激活, 1是, 0否 |
sequence | integer | 场景序号 |
number | integer | 场景库的编号 |
icon | string | 场景图标, 实际没用到 |
background | string | 场景背景, 实际没用到 |
colors | integer[] | 场景5个颜色 |
picture_id | string | 图片资源的UUID |
picture_type | string | 此处固定为 file |
picture_url | string | 图片的URL |
device_arr | object[] | 场景中每个设备的颜色, 详见API文档 |
4. 功能说明
- 此topic会在创建场景时 触发
二. 场景删除
1. topic
res/scene/remove
2. payload
json
[
{
"id": "AE017B91-75BF-4CC6-9EC7-F2C48DDC11FD",
"type": "scene"
}
]3. 字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 场景的UUID |
type | string | 资源类型, 此处固定为 "scene" |
4. 功能说明
- 此topic会在场景删除时触发
三. 场景更新
1. topic
res/scene/update
2. payload
json
[
{
"id": "AE017B91-75BF-4CC6-9EC7-F2C48DDC11FD",
"room_id": "6B703F4A-A2A2-4F3C-82D6-BDD4E8BA8B1C",
"value": {
"is_active": 1
}
}
]3. 字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 场景的 UUID |
room_id | string | 房间的 UUID |
value | object | 有更新的字段 |
value对象
| 字段 | 类型 | 说明 |
|---|---|---|
value.name | string | 场景名称 |
value.picture_id | string | 图片UUID |
value.picture_type | string | 此处固定为 file |
value.picture_url | string | 图片的 URL |
value.sequence | integer | 场景序号 |
value.icon | string | 场景图标 |
value.background | string | 场景背景图 |
value.colors | integer[] | 场景的5个颜色 |
value.is_active | integer | 场景激活状态, 1激活, 0未激活 |
4. 功能说明
- 在场景信息变更时, 会触发此 topic
- value对象中, key存在代表有更新, key不存在代表未更新