文档管理中心
API参考智慧生活App JSAPI参考Wi-Fi设备JSAPI接口参考JSAPI参考规则接口修改自动规则

修改自动规则

适用平台

Android、iOS

请求消息

当需要修改自动规则时,WEB中调用js方法如下:

收起
自动换行
深色代码主题
复制
  1. hilink.updateRule(
  2. "json_body", // body,string, 规则json字符串
  3. "resultCallback" // resultCallback,成功或失败时,将调用传入resultStr返回结果
  4. );
  5. // web页面中需实现该函数,用来获取执行结果
  6. function resultCallback (resultStr) {
  7. var result = resultStr; // REST请求的返回结果
  8. }

json_body中携带需要修改的规则,格式如下:

收起
自动换行
深色代码主题
复制
  1. {
  2. "name": "Rule01",
  3. "conditions": [
  4. {
  5. "type": "DEVICE_DATA",
  6. "deviceInfo": {
  7. "devId": "2323-1221-...",
  8. "devType": "005",
  9. "path": "switch/on"
  10. },
  11. "operator": "=",
  12. "value": "1"
  13. }
  14. ],
  15. "author": "12222",
  16. "actions": [
  17. {
  18. "type": "DEVICE_CMD",
  19. "devId": "2323-1221-...",
  20. "devType": "01B",
  21. "cmd": {
  22. "sid": "switch",
  23. "messageType": "POST",
  24. "messageBody": {
  25. "on": 1
  26. }
  27. }
  28. }
  29. ]
  30. }

Body不能为空,否则将失败。

响应消息

当调用成功时,JSSDK将调用success对应的回调函数,将如下结果返回到resultStr中。

收起
自动换行
深色代码主题
复制
  1. {
  2. "ruleId": "*******",
  3. "name": "Rule01",
  4. "conditions": [
  5. {
  6. "id": "****",
  7. "type": "DEVICE_DATA",
  8. "deviceInfo": {
  9. "devId": "2323-1221-...",
  10. "devType": "005",
  11. "path": "switch/on"
  12. },
  13. "operator": "=",
  14. "value": "1"
  15. }
  16. ],
  17. "author": "12222",
  18. "actions": [
  19. {
  20. "type": "DEVICE_CMD",
  21. "id": "****",
  22. "devId": "2323-1221-...",
  23. "devType": "01B",
  24. "cmd": {
  25. "sid": "switch",
  26. "messageType": "POST",
  27. "messageBody": {
  28. "on": 1
  29. }
  30. }
  31. }
  32. ]
  33. }

错误码

收起
自动换行
深色代码主题
复制
  1. {
  2. "errcode": 11
  3. }

错误码说明参见错误码

在 API参考 中进行搜索
请输入您想要搜索的关键词