Cloud Open API
Get task info
POST: cloud-control-url/openapi/getTask
Example: http://192.168.1.182:8099/openapi/getTask
Content-Type: application/json
{ "dataSecret": "API cloud communication secret from backend" // config.toml → appkey; default is test123}- Response:
[ { "cacheScript": 1, "delaySecond": 0, "execNumber": 9999, "cronText": "* * * * * ?", "deviceNos": "006,001,003x,test222", // devices that run this task "downloadUrl": "http://192.168.2.7:8098/pub_upload/2022-10-07/cnfdy1l2biiwpl8qcm.iec", "execType": 1, "scheduleTime": null, "scheduleType": 0, "execStatus": 1, "endTime": null, "scriptId": 16, "scriptMd5": "b7ec603dffd9527c98e505bdd0eea137", "scriptName": "html5", "scriptVersion": "1", "sort": 1, "taskId": 11, // task ID — usually all you need "taskName": "23", // task name "tenantId": 1, // tenant id // parameter config "valueConfig": "[{\"id\":3,\"key\":\"我是多选框\",\"options\":[\"111\",\"2222\",\"333\"],\"type\":\"3\",\"value\":[\"111\",\"222\",\"333\"]},{\"id\":2,\"type\":\"2\",\"key\":\"b\",\"value\":\"111\",\"options\":[\"111\",\"2\"]},{\"id\":1,\"type\":\"\",\"key\":\"a\",\"value\":\"111333\",\"options\":\"111\"},{\"id\":1,\"key\":\"我是文本\",\"options\":\"\",\"type\":\"\",\"value\":\"我是文本的值\"},{\"id\":2,\"key\":\"我是单选框\",\"options\":[\"我是选中\",\"2222\"],\"type\":\"2\",\"value\":\"我是选中\"}]", // formatted parameter values "valueJson": { "a": "111333", "b": "111", "我是单选框": "我是选中", "我是多选框": [ "111", "222", "333" ], "我是文本": "我是文本的值" } }, { "cacheScript": 1, "delaySecond": 222, "execNumber": 133, "cronText": "* * * * * ?", "deviceNos": "003,test222,001,002", "downloadUrl": "http://192.168.2.7:8098/pub_upload/2022-10-07/cnfdy1l2biiwpl8qcm.iec", "execType": 2, "scheduleTime": null, "scheduleType": 3, "execStatus": 1, "endTime": null, "scriptId": 16, "scriptMd5": "b7ec603dffd9527c98e505bdd0eea137", "scriptName": "html5", "scriptVersion": "1", "sort": 1, "taskId": 10, "taskName": "33", "tenantId": 1, "valueConfig": "[{\"id\":3,\"key\":\"我是多选框\",\"options\":[\"111\",\"2222\",\"333\"],\"type\":\"3\",\"value\":[\"111\",\"222\",\"333\"]},{\"id\":2,\"type\":\"2\",\"key\":\"b\",\"value\":\"111\",\"options\":[\"111\",\"2\"]},{\"id\":1,\"type\":\"\",\"key\":\"a\",\"value\":\"111333\",\"options\":\"111\"},{\"id\":1,\"key\":\"我是文本\",\"options\":\"\",\"type\":\"\",\"value\":\"我是文本的值\"},{\"id\":2,\"key\":\"我是单选框\",\"options\":[\"我是选中\",\"2222\"],\"type\":\"2\",\"value\":\"我是选中\"}]", "valueJson": { "a": "111333", "b": "111", "我是单选框": "我是选中", "我是多选框": [ "111", "222", "333" ], "我是文本": "我是文本的值" } }]Task control
- Start a task
- Stop a task
- Add / remove devices
- Add / remove parameters
POST: cloud-control-url/openapi/changeTask
Example: http://192.168.1.182:8099/openapi/changeTask
Content-Type: application/json
{ "dataSecret":"API cloud communication secret from backend", // config.toml → appkey; default test123 "taskId":"1",// task ID created in cloud control "status":"0",// 1 stop local, 2 stop remote, 0 start "addDevices":"001,002,003",// devices to add "removeDevices":"007,009",// devices to remove // addParamEx fields: // key = parameter name // type = 1 text, 2 radio, 3 checkbox // value = string for text/radio; JSON array for checkbox // options = candidates; ignore for text; JSON array for radio/checkbox "addParamEx":[ { "key":"我是文本", "type":"1", "value":"我是文本的值" }, { "key":"我是单选框", "type":"2", "value":"2222", "options":["我是选中","2222"] }, { "key":"我是多选框", "type":"3", "value":["111","222"], "options":["111","2222","333"] } ], "removeParam":["ke1"]}title: Auto-run after order flowparticipant Customerparticipant OrderSystemparticipant CloudControlparticipant Device
Customer->OrderSystem: Place order and payOrderSystem->CloudControl: Call (/api/changeTask) to start a task,\nadd devices and parametersCloudControl->CloudControl: Update task status,\nparameters, devicesCloudControl->Device: Dispatch task to deviceDevice->Device: Loop scriptDevice->CloudControl: Call (/api/changeTask) when done\nto remove itself from the task devicesWebHook heartbeat / log push
- Pushes heartbeat and script logs to an external system
- HTTP or WebSocket (pick one)
- Configure in
config/config.toml - Set
mode, thenhttpUrlorwsUrl, and restart cloud control
# Heartbeat forward (push heartbeat data and script logs to an external system)[heartbeatForward]# Enableenabled = true# Mode: http or websocketmode = "http"
# HTTP mode (POST JSON)# e.g. http://192.168.2.26:8199/heartbeathttpUrl = ""httpTimeoutMs = 3000# Optional custom header (e.g. Authorization)httpHeaderKey = "ecloud_token"httpHeaderValue = "90284kdf9i4k"
# WebSocket mode (TextMessage JSON)# e.g. ws://192.168.2.26:8199/wstestwsUrl = ""wsDialTimeoutMs = 3000wsWriteTimeoutMs = 1500wsReconnectWaitMs = 2000# Header authwsHeaderKey = "ecloud_token"wsHeaderValue = "90284kdf9i4k"
# Queue (async send, does not block main flow)queueSize = 10240# When full: true = drop + warn; false = block RecordHeartBeatdropWhenFull = true