Skip to content

​

名词说明 ​

  • device_id: 即设备ID。每个设备,比如智能配电箱、气象站等,都有一个唯一的设备ID值。
  • agri_id: 即子设备ID。每个设备下连接多个子设备。比如一个智能配电箱有4个智能开关控制,则对应有4个子设备ID。
  • token: 系统分配的操作设备的验证值。在调用接口时,需要携带该值。

token:{token} ​


详细接口文档 ​

https://www.holdingbyte.com/doc/index.html

设备信息 ​

设备device_idagri_id类型单位
device_namedevice_idagri_idthe_typeunit

接口示例 ​

获取设备数据 ​

获取设备的最近一次提交的数据,比如温度传感器的温度值。如果设备离线,则返回空数据。

Python示例:

python
import requests
	
url = "https://agri-dl.holdingbyte.com/api/device/{device_id}/data/"
	
payload = ""
headers = {
	"token":"{token}"
}
	
response = requests.request("GET", url, headers=headers, data=payload)
	
print(response.text)

控制设备 ​

对设备进行关闭、开启等操作。

Python示例:

python

import requests
import json

url = "https://agri-dl.holdingbyte.com/api/command/"

payload = json.dumps({
  "t_agri_id": "{switch_agri_id}",
  "cmd_type": 9012,
  "r_token": "test token",
  "info": "测试",
  "callback_url": "https://agri-dl.holdingbyte.com/api/command/callback_test/"
})

headers = {
  'Content-Type': 'application/json',
  "token":"{token}"
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)