定时说明文档
1.通用联合定时
{
"directive": {
"header": {
"namespace": "DNA.PowerControl",
"name": "TimerChangePowerState",
"interfaceVersion": "2",
"messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
},
"endpoint": {
"endpointId": "780f777ea494",
"cookie": {
"did": "780f777ea494",
"pid": "0000000000000000000000000d7d0000",
"devpid": "0000000000000000000000000d7d0000",
"devdid": "780f777ea494",
"tokeninfo": "01000000c77d4c255bd31377ef0e06c9772ca4ac"
}
},
"payload": {
"timer":{
"type" : "delay",
"time":"2019-01-11T19:12:05+08:00",
"name":"测试1"
},
"powerState":"OFF"
}
}
}
目前对所有设备仅开放type为delay的定时控制接口
根据设备支持的不同定时类别,云端还提供特殊的设备定时接口
2.老版本sp mini特殊定时云端老接口说明
1.sp设置定时
{
"directive": {
"header": {
"namespace": "DNA.PowerControl",
"name": "TimingChangePowerState",
"interfaceVersion": "2",
"messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
},
"endpoint": {
"endpointId": "appliance-001",
"cookie": {}
},
"payload": {
"timingPowerState": {
"params":["tmr_tsk"] ,
"vals":[
[
{“val”:”+0800@20150824-193900|0@20150824-193900|1”,”idx”:1},
{“val”:”+0800@20150824-193900|0@20150824-193900|1”,”idx”:1},
{“val”:”+0800@0150824-193900|0@20150824-
193900|1”,”idx”:1}
]
],
"act":"set"
}
}
}
}
2.定时查询
{
"directive": {
"header": {
"namespace": "DNA",
"name": "timingPowerState",
"interfaceVersion": "2",
"messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
},
"endpoint": {
"endpointId": "appliance-001",
"cookie": {}
},
"payload": {
}
}
}
payload中参数值参考” SP 接口控制指令定义最终版“
3.通用设备定时接口
通用定时控制命令与其他控制命令一直,区别在于payload中有timer结构标示定时信息
如以下控制接口
POST https://(OpenproxyURL)/openproxy/v3/opencontrol?license=(license)
请求:
{
"directive": {
"header": {
"namespace": "DNA.PowerControl",//控制能力 //DNA
"name": "ChangePowerState",//控制动作 查询//ReportState
"interfaceVersion": "2",//目前版本标识
"messageId": "1bd5d003-31b9-476f-ad03-71d471922820"//请求id,返回信息中会保持一致。
},
"endpoint": {
"endpointId": "Some-Device-ID",//注册返回
"cookie": {}//注册返回的cookie,第三方云端透传
},
"payload": {
"timer":{
"type" : "xx", //定时类型,目前使用delay标示延时定时
"class" : "xx", //所属类,可选,目前暂时为空即可
"id" : xx, //定时索引(由固件统一管理,添加的时候设为0或者为空)
"en" : xx, //定时使能:0 - 关闭,1 - 打开
"name" : "xx" , //定时名称
"time" : "xx", //时间定义//0_1_22_26_2_*_2018
"act":0
},//目前只是支持开关
"powerState":"OFF"//控制属性和属性值
}
}
}
响应:
{
"context": {//控制参数
"properties": [ {} ]
},
"event": {
"header": {
"namespace": "DNA.PowerControl",
"name": "Response",//成功返回标识
"interfaceVersion": "2",
"messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
},
"endpoint": {
"endpointId": "appliance-001"//控制设备
},
"payload": {
}
}
}
以下为各字段信息:
1.act
值 | 含义 |
---|---|
0 | 添加 |
1 | 删除 |
2 | 编辑 |
3 | 获取定时列表 |
2.type
值 | 含义 |
---|---|
comm | 普通定时 |
delay | 延时 |
period | 周期 |
cycle | 循环 |
rand | 防盗 |
sleep | 睡眠曲线 |
all | 所有定时 |
3.时间格式:
秒_分_时_日_月_周_年
举例
编号 任务类型 表达式 说明
1 定时执行一次 0_1_22_26_2_*_2018 2018年的2月26号22点01分执行
2 每周定时执行 0_1_22_*_*_0,1,3,5_* 每周日,周1,周3,周5的22点01分执行
3 每天定时执行 0_1_22_*_*_*_* 每天22点01分执行
4.通用云端定时控制接口
/注释/
云定时接口保留设备控制请求的所有结构,只增加cloudtimer结构。
云端通过是否有cloudtimer结构判断是否是定时任务,并在相应时间下发directive的控制请求。
请求:
{
"directive": {
"header": {},
"endpoint": {},
"payload": {},
},
cloudtimer{
"command":"upsert",
"type":2,
"index":1,//0 增加定时,非0 修改定时
"name":"开关定时",
"enable":true,
"timer":{
"weekdays":"1234567",
"time":"2006-07-02T19:12:05.999999999+08:00"
}
}
}
cloudtimer详解;cloudtimer包含如下字段
key | 类型 | 解释 |
---|---|---|
command | string | 包含 upsert(增加及更新,增加是index设置为0,修改时,index填返回列表里的idnex值),delete |
type | int | 定时类型(0:普通定时;2:周期定时) |
index | int | 定时主键,修改时携带,增加为0 |
name | string | 第三方设置的名称 |
enable | bool | true代表开。false代表关 |
timer | 结构体 | 时间描述结构 |
返回:
{
"event": {
"endpoint": {
"endpointId": "00000000000000000000780f774e7f13"
},
"header": {
"interfaceVersion": "2",
"messageId": "28d0022d-134e-421d-b5c5-7d4f2c5e0226",
"name": "Response",
"namespace": ""
},
"payload": {//定时列表
"timerlist": [
{
"enable": true,
"extern": "",
"index": 1,//定时序号
"name": "开关定时",
"timer": {
"time": "2020-10-22T17:22:00.999999999+08:00",
"weekdays": "1234567"
},
"type": 2
},
{
"enable": true,
"extern": "",
"index": 4,
"name": "开关定时",
"timer": {
"time": "2020-10-22T17:22:00.999999999+08:00",
"weekdays": "1234567"
},
"type": 2
},
{
"enable": true,
"extern": "",
"index": 3,
"name": "开关定时",
"timer": {
"time": "2019-10-22T18:04:00.999999999+08:00",
"weekdays": "1234567"
},
"type": 2
}
]
}
}
}