美文网首页
雁飞•格物DMP平台设备属性数据上传(HTTP协议)

雁飞•格物DMP平台设备属性数据上传(HTTP协议)

作者: 羋学僧 | 来源:发表于2022-02-17 15:43 被阅读0次

雁飞•格物DMP平台设备属性数据上传(HTTP协议)

属性上报

import requests
import time
import json

timestamp = str(round(time.time() * 1000))
productKey = "cu3dvw7f1ql1lxDa"
deviceKey = "20220217"

url = "https://dmp-https.cuiot.cn:8943/topic/sys/{productKey}/{deviceKey}/property/pub".format(productKey = productKey,deviceKey = deviceKey)


payload = json.dumps({

        "messageId": "12345",

        "params":
            {"key": "Uc", "value": 20.4,"ts": timestamp}
})
headers = {
    'Content-Type': 'application/octet-stream',
    'Authorization':"2936c67e98324255a4f0918c78bf1012"
}

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

print(response.text)

属性批量上报

import requests
import time
import json

timestamp = str(round(time.time() * 1000))
productKey = "cu3dvw7f1ql1lxDa"
deviceKey = "20220217"

url = "https://dmp-https.cuiot.cn:8943/topic/sys/{productKey}/{deviceKey}/property/batch".format(productKey = productKey,deviceKey = deviceKey)


payload = json.dumps({

        "messageId": "12345",

        "params":
            {"data":[{"key": "Uc", "value": 28.4,"ts": timestamp},{"key": "Ub", "value": 25.4,"ts": timestamp}]}
})
headers = {
    'Content-Type': 'application/octet-stream',
    'Authorization':"2936c67e98324255a4f0918c78bf1012"
}

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

print(response.text)

相关文章

网友评论

      本文标题:雁飞•格物DMP平台设备属性数据上传(HTTP协议)

      本文链接:https://www.haomeiwen.com/subject/xrrslrtx.html